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