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