1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef WS_VFS_H
30 #define WS_VFS_H
31
32 #include "nsapi.h"
33 #include "acl.h"
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #define VFS_CHECKS_ACL 0x0001
40
41 typedef struct VFS_IO VFS_IO;
42 typedef struct VFS_DIRIO VFS_DIRIO;
43 typedef struct VFSFile VFSFile;
44 typedef struct VFSDir VFSDir;
45 typedef struct VFSEntry VFSEntry;
46
47 #define VFS_DIR VFSDir*
48 #define VFS_ENTRY VFSEntry
49
50 struct VFS {
51 SYS_FILE (*open)(VFSContext *ctx,
char *path,
int oflags);
52 int (*stat)(VFSContext *ctx,
char *path,
struct stat *buf);
53 int (*fstat)(VFSContext *ctx,
SYS_FILE fd,
struct stat *buf);
54 VFS_DIR (*opendir)(VFSContext *ctx,
char *path);
55 int (*mkdir)(VFSContext *ctx,
char *path);
56 int (*unlink)(VFSContext *ctx,
char *path);
57 uint32_t flags;
58 };
59
60 struct VFSContext {
61 pool_handle_t *pool;
62 Session *sn;
63 Request *rq;
64 VFS *vfs;
65 User *user;
66 ACLListHandle *acllist;
67 uint32_t aclreqaccess;
68 int vfs_errno;
69 };
70
71 struct VFSFile {
72 VFSContext *ctx;
73 VFS_IO *io;
74 void *data;
75 int fd;
76 };
77
78 struct VFSDir {
79 VFSContext *ctx;
80 VFS_DIRIO *io;
81 void *data;
82 int fd;
83 };
84
85 struct VFSEntry {
86 char *name;
87 struct stat stat;
88 void *stat_extra;
89 int stat_errno;
90 };
91
92 struct VFS_IO {
93 ssize_t (*read)(
SYS_FILE fd,
void *buf,
size_t nbyte);
94 ssize_t (*write)(
SYS_FILE fd,
const void *buf,
size_t nbyte);
95 ssize_t (*pread)(
SYS_FILE fd,
void *buf,
size_t nbyte,
off_t offset);
96 ssize_t (*pwrite)(
SYS_FILE fd,
const void *buf,
size_t nbyte,
off_t offset);
97 off_t (*seek)(
SYS_FILE fd,
off_t offset,
int whence);
98 void (*close)(
SYS_FILE fd);
99 int (*opt_aioread)(aiocb_s *aiocb);
100 int (*opt_aiowrite)(aiocb_s *aiocb);
101 };
102
103 struct VFS_DIRIO {
104 int (*readdir)(
VFS_DIR dir,
VFS_ENTRY *entry,
int getstat);
105 void (*close)(
VFS_DIR dir);
106 };
107
108
109
110
111 void vfs_add(
char *name,
VFS *vfs);
112
113
114
115
116
117 VFSContext* vfs_request_context(Session *sn, Request *rq);
118
119 SYS_FILE vfs_open(VFSContext *ctx,
char *path,
int oflags);
120 SYS_FILE vfs_openRO(VFSContext *ctx,
char *path);
121 SYS_FILE vfs_openWO(VFSContext *ctx,
char *path);
122 SYS_FILE vfs_openRW(VFSContext *ctx,
char *path);
123 int vfs_stat(VFSContext *ctx,
char *path,
struct stat *buf);
124 int vfs_fstat(VFSContext *ctx,
SYS_FILE fd,
struct stat *buf);
125 void vfs_close(
SYS_FILE fd);
126 VFS_DIR vfs_opendir(VFSContext *ctx,
char *path);
127 int vfs_readdir(
VFS_DIR dir,
VFS_ENTRY *entry);
128 int vfs_readdir_stat(
VFS_DIR dir,
VFS_ENTRY *entry);
129 void vfs_closedir(
VFS_DIR dir);
130 int vfs_mkdir(VFSContext *ctx,
char *path);
131 int vfs_unlink(VFSContext *ctx,
char *path);
132
133 #ifdef __cplusplus
134 }
135 #endif
136
137 #endif
138
139