vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / file_systems / nfs / fsproto.h
blob1099f2eac3d1a87842df5dc06cdd8c33f06f2f0a
1 #ifndef _FSPROTO_H
2 #define _FSPROTO_H
4 //#include <sys/dirent.h>
5 #include <dirent.h>
6 #include <sys/types.h>
7 #include <sys/param.h>
8 #include <sys/stat.h>
9 #include <unistd.h>
10 #include <iovec.h>
11 #include <OS.h>
12 #include <fs_attr.h>
13 #include <fs_info.h>
14 #include <BeBuild.h>
16 typedef dev_t nspace_id;
18 /* UGLY UGLY UGLY */
19 #ifndef _DRIVERS_H
20 struct selectsync;
21 typedef struct selectsync selectsync;
22 #endif
26 * PUBLIC PART OF THE FILE SYSTEM PROTOCOL
29 #define WSTAT_MODE 0x0001
30 #define WSTAT_UID 0x0002
31 #define WSTAT_GID 0x0004
32 #define WSTAT_SIZE 0x0008
33 #define WSTAT_ATIME 0x0010
34 #define WSTAT_MTIME 0x0020
35 #define WSTAT_CRTIME 0x0040
37 #define WFSSTAT_NAME 0x0001
39 #define B_ENTRY_CREATED 1
40 #define B_ENTRY_REMOVED 2
41 #define B_ENTRY_MOVED 3
42 #define B_STAT_CHANGED 4
43 #define B_ATTR_CHANGED 5
44 #define B_DEVICE_MOUNTED 6
45 #define B_DEVICE_UNMOUNTED 7
47 #define B_STOP_WATCHING 0x0000
48 #define B_WATCH_NAME 0x0001
49 #define B_WATCH_STAT 0x0002
50 #define B_WATCH_ATTR 0x0004
51 #define B_WATCH_DIRECTORY 0x0008
53 #define SELECT_READ 1
54 #define SELECT_WRITE 2
55 #define SELECT_EXCEPTION 3
57 #define B_CUR_FS_API_VERSION 2
59 struct attr_info;
60 struct index_info;
62 typedef int op_read_vnode(void *ns, ino_t vnid, char r, void **node);
63 typedef int op_write_vnode(void *ns, void *node, char r);
64 typedef int op_remove_vnode(void *ns, void *node, char r);
65 typedef int op_secure_vnode(void *ns, void *node);
67 typedef int op_walk(void *ns, void *base, const char *file, char **newpath,
68 ino_t *vnid);
70 typedef int op_access(void *ns, void *node, int mode);
72 typedef int op_create(void *ns, void *dir, const char *name,
73 int omode, int perms, ino_t *vnid, void **cookie);
74 typedef int op_mkdir(void *ns, void *dir, const char *name, int perms);
75 typedef int op_symlink(void *ns, void *dir, const char *name,
76 const char *path);
77 typedef int op_link(void *ns, void *dir, const char *name, void *node);
79 typedef int op_rename(void *ns, void *olddir, const char *oldname,
80 void *newdir, const char *newname);
81 typedef int op_unlink(void *ns, void *dir, const char *name);
82 typedef int op_rmdir(void *ns, void *dir, const char *name);
84 typedef int op_readlink(void *ns, void *node, char *buf, size_t *bufsize);
86 typedef int op_opendir(void *ns, void *node, void **cookie);
87 typedef int op_closedir(void *ns, void *node, void *cookie);
88 typedef int op_rewinddir(void *ns, void *node, void *cookie);
89 typedef int op_readdir(void *ns, void *node, void *cookie, long *num,
90 struct dirent *buf, size_t bufsize);
92 typedef int op_open(void *ns, void *node, int omode, void **cookie);
93 typedef int op_close(void *ns, void *node, void *cookie);
94 typedef int op_free_cookie(void *ns, void *node, void *cookie);
95 typedef int op_read(void *ns, void *node, void *cookie, off_t pos, void *buf,
96 size_t *len);
97 typedef int op_write(void *ns, void *node, void *cookie, off_t pos,
98 const void *buf, size_t *len);
99 typedef int op_readv(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
100 size_t count, size_t *len);
101 typedef int op_writev(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
102 size_t count, size_t *len);
103 typedef int op_ioctl(void *ns, void *node, void *cookie, int cmd, void *buf,
104 size_t len);
105 typedef int op_setflags(void *ns, void *node, void *cookie, int flags);
107 typedef int op_rstat(void *ns, void *node, struct stat *);
108 typedef int op_wstat(void *ns, void *node, struct stat *, long mask);
109 typedef int op_fsync(void *ns, void *node);
111 typedef int op_select(void *ns, void *node, void *cookie, uint8 event,
112 uint32 ref, selectsync *sync);
113 typedef int op_deselect(void *ns, void *node, void *cookie, uint8 event,
114 selectsync *sync);
116 typedef int op_initialize(const char *devname, void *parms, size_t len);
117 typedef int op_mount(nspace_id nsid, const char *devname, ulong flags,
118 void *parms, size_t len, void **data, ino_t *vnid);
119 typedef int op_unmount(void *ns);
120 typedef int op_sync(void *ns);
121 typedef int op_rfsstat(void *ns, struct fs_info *);
122 typedef int op_wfsstat(void *ns, struct fs_info *, long mask);
125 typedef int op_open_attrdir(void *ns, void *node, void **cookie);
126 typedef int op_close_attrdir(void *ns, void *node, void *cookie);
127 typedef int op_rewind_attrdir(void *ns, void *node, void *cookie);
128 typedef int op_read_attrdir(void *ns, void *node, void *cookie, long *num,
129 struct dirent *buf, size_t bufsize);
130 typedef int op_remove_attr(void *ns, void *node, const char *name);
131 typedef int op_rename_attr(void *ns, void *node, const char *oldname,
132 const char *newname);
133 typedef int op_stat_attr(void *ns, void *node, const char *name,
134 struct attr_info *buf);
136 typedef int op_write_attr(void *ns, void *node, const char *name, int type,
137 const void *buf, size_t *len, off_t pos);
138 typedef int op_read_attr(void *ns, void *node, const char *name, int type,
139 void *buf, size_t *len, off_t pos);
141 typedef int op_open_indexdir(void *ns, void **cookie);
142 typedef int op_close_indexdir(void *ns, void *cookie);
143 typedef int op_rewind_indexdir(void *ns, void *cookie);
144 typedef int op_read_indexdir(void *ns, void *cookie, long *num,
145 struct dirent *buf, size_t bufsize);
146 typedef int op_create_index(void *ns, const char *name, int type, int flags);
147 typedef int op_remove_index(void *ns, const char *name);
148 typedef int op_rename_index(void *ns, const char *oldname,
149 const char *newname);
150 typedef int op_stat_index(void *ns, const char *name, struct index_info *buf);
152 typedef int op_open_query(void *ns, const char *query, ulong flags,
153 port_id port, long token, void **cookie);
154 typedef int op_close_query(void *ns, void *cookie);
155 typedef int op_read_query(void *ns, void *cookie, long *num,
156 struct dirent *buf, size_t bufsize);
158 typedef struct vnode_ops {
159 op_read_vnode (*read_vnode);
160 op_write_vnode (*write_vnode);
161 op_remove_vnode (*remove_vnode);
162 op_secure_vnode (*secure_vnode);
163 op_walk (*walk);
164 op_access (*access);
165 op_create (*create);
166 op_mkdir (*mkdir);
167 op_symlink (*symlink);
168 op_link (*link);
169 op_rename (*rename);
170 op_unlink (*unlink);
171 op_rmdir (*rmdir);
172 op_readlink (*readlink);
173 op_opendir (*opendir);
174 op_closedir (*closedir);
175 op_free_cookie (*free_dircookie);
176 op_rewinddir (*rewinddir);
177 op_readdir (*readdir);
178 op_open (*open);
179 op_close (*close);
180 op_free_cookie (*free_cookie);
181 op_read (*read);
182 op_write (*write);
183 op_readv (*readv);
184 op_writev (*writev);
185 op_ioctl (*ioctl);
186 op_setflags (*setflags);
187 op_rstat (*rstat);
188 op_wstat (*wstat);
189 op_fsync (*fsync);
190 op_initialize (*initialize);
191 op_mount (*mount);
192 op_unmount (*unmount);
193 op_sync (*sync);
194 op_rfsstat (*rfsstat);
195 op_wfsstat (*wfsstat);
196 op_select (*select);
197 op_deselect (*deselect);
198 op_open_indexdir (*open_indexdir);
199 op_close_indexdir (*close_indexdir);
200 op_free_cookie (*free_indexdircookie);
201 op_rewind_indexdir (*rewind_indexdir);
202 op_read_indexdir (*read_indexdir);
203 op_create_index (*create_index);
204 op_remove_index (*remove_index);
205 op_rename_index (*rename_index);
206 op_stat_index (*stat_index);
207 op_open_attrdir (*open_attrdir);
208 op_close_attrdir (*close_attrdir);
209 op_free_cookie (*free_attrdircookie);
210 op_rewind_attrdir (*rewind_attrdir);
211 op_read_attrdir (*read_attrdir);
212 op_write_attr (*write_attr);
213 op_read_attr (*read_attr);
214 op_remove_attr (*remove_attr);
215 op_rename_attr (*rename_attr);
216 op_stat_attr (*stat_attr);
217 op_open_query (*open_query);
218 op_close_query (*close_query);
219 op_free_cookie (*free_querycookie);
220 op_read_query (*read_query);
221 } vnode_ops;
223 extern int new_path(const char *path, char **copy);
224 extern void free_path(char *p);
226 extern int notify_listener(int op, nspace_id nsid,
227 ino_t vnida, ino_t vnidb,
228 ino_t vnidc, const char *name);
229 extern void notify_select_event(selectsync *sync, uint32 ref);
230 extern int send_notification(port_id port, long token,
231 ulong what, long op, nspace_id nsida,
232 nspace_id nsidb, ino_t vnida,
233 ino_t vnidb, ino_t vnidc,
234 const char *name);
235 extern int get_vnode(nspace_id nsid, ino_t vnid, void **data);
236 extern int put_vnode(nspace_id nsid, ino_t vnid);
237 extern int new_vnode(nspace_id nsid, ino_t vnid, void *data);
238 extern int remove_vnode(nspace_id nsid, ino_t vnid);
239 extern int unremove_vnode(nspace_id nsid, ino_t vnid);
240 extern int is_vnode_removed(nspace_id nsid, ino_t vnid);
243 extern _EXPORT vnode_ops fs_entry;
244 extern _EXPORT int32 api_version;
246 #endif