1#ifndef _FSPROTO_H
2#define _FSPROTO_H
3
4#include <sys/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#include <OS.h>
11#include <fs_attr.h>
12#include <fs_info.h>
13#include <BeBuild.h>
14
15typedef dev_t		nspace_id;
16typedef ino_t		vnode_id;
17
18/* UGLY UGLY UGLY */
19#ifndef _DRIVERS_H
20struct selectsync;
21typedef struct selectsync selectsync;
22#endif
23
24
25/*
26 * PUBLIC PART OF THE FILE SYSTEM PROTOCOL
27 */
28
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
36
37#define		WFSSTAT_NAME	0x0001
38
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
46
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
52
53#define		SELECT_READ			1
54#define		SELECT_WRITE		2
55#define 	SELECT_EXCEPTION	3
56
57#define		B_CUR_FS_API_VERSION	2
58
59struct attr_info;
60struct index_info;
61
62typedef int	op_read_vnode(void *ns, vnode_id vnid, char r, void **node);
63typedef int	op_write_vnode(void *ns, void *node, char r);
64typedef int	op_remove_vnode(void *ns, void *node, char r);
65typedef int	op_secure_vnode(void *ns, void *node);
66
67typedef int	op_walk(void *ns, void *base, const char *file, char **newpath,
68					vnode_id *vnid);
69
70typedef int	op_access(void *ns, void *node, int mode);
71
72typedef int	op_create(void *ns, void *dir, const char *name,
73					int omode, int perms, vnode_id *vnid, void **cookie);
74typedef int	op_mkdir(void *ns, void *dir, const char *name,	int perms);
75typedef int	op_symlink(void *ns, void *dir, const char *name,
76					const char *path);
77typedef int op_link(void *ns, void *dir, const char *name, void *node);
78
79typedef int	op_rename(void *ns, void *olddir, const char *oldname,
80					void *newdir, const char *newname);
81typedef int	op_unlink(void *ns, void *dir, const char *name);
82typedef int	op_rmdir(void *ns, void *dir, const char *name);
83
84typedef int	op_readlink(void *ns, void *node, char *buf, size_t *bufsize);
85
86typedef int op_opendir(void *ns, void *node, void **cookie);
87typedef int	op_closedir(void *ns, void *node, void *cookie);
88typedef int	op_rewinddir(void *ns, void *node, void *cookie);
89typedef int	op_readdir(void *ns, void *node, void *cookie, long *num,
90					struct dirent *buf, size_t bufsize);
91
92typedef int	op_open(void *ns, void *node, int omode, void **cookie);
93typedef int	op_close(void *ns, void *node, void *cookie);
94typedef int op_free_cookie(void *ns, void *node, void *cookie);
95typedef int op_read(void *ns, void *node, void *cookie, off_t pos, void *buf,
96					size_t *len);
97typedef int op_write(void *ns, void *node, void *cookie, off_t pos,
98					const void *buf, size_t *len);
99typedef int op_readv(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
100					size_t count, size_t *len);
101typedef int op_writev(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
102					size_t count, size_t *len);
103typedef int	op_ioctl(void *ns, void *node, void *cookie, int cmd, void *buf,
104					size_t len);
105typedef	int	op_setflags(void *ns, void *node, void *cookie, int flags);
106
107typedef int	op_rstat(void *ns, void *node, struct stat *);
108typedef int op_wstat(void *ns, void *node, struct stat *, long mask);
109typedef int	op_fsync(void *ns, void *node);
110
111typedef int	op_select(void *ns, void *node, void *cookie, uint8 event,
112				uint32 ref, selectsync *sync);
113typedef int	op_deselect(void *ns, void *node, void *cookie, uint8 event,
114				selectsync *sync);
115
116typedef int	op_initialize(const char *devname, void *parms, size_t len);
117typedef int	op_mount(nspace_id nsid, const char *devname, ulong flags,
118					void *parms, size_t len, void **data, vnode_id *vnid);
119typedef int	op_unmount(void *ns);
120typedef int	op_sync(void *ns);
121typedef int op_rfsstat(void *ns, struct fs_info *);
122typedef int op_wfsstat(void *ns, struct fs_info *, long mask);
123
124
125typedef int	op_open_attrdir(void *ns, void *node, void **cookie);
126typedef int	op_close_attrdir(void *ns, void *node, void *cookie);
127typedef int	op_rewind_attrdir(void *ns, void *node, void *cookie);
128typedef int	op_read_attrdir(void *ns, void *node, void *cookie, long *num,
129					struct dirent *buf, size_t bufsize);
130typedef int	op_remove_attr(void *ns, void *node, const char *name);
131typedef	int	op_rename_attr(void *ns, void *node, const char *oldname,
132					const char *newname);
133typedef int	op_stat_attr(void *ns, void *node, const char *name,
134					struct attr_info *buf);
135
136typedef int	op_write_attr(void *ns, void *node, const char *name, int type,
137					const void *buf, size_t *len, off_t pos);
138typedef int	op_read_attr(void *ns, void *node, const char *name, int type,
139					void *buf, size_t *len, off_t pos);
140
141typedef int	op_open_indexdir(void *ns, void **cookie);
142typedef int	op_close_indexdir(void *ns, void *cookie);
143typedef int	op_rewind_indexdir(void *ns, void *cookie);
144typedef int	op_read_indexdir(void *ns, void *cookie, long *num,
145					struct dirent *buf, size_t bufsize);
146typedef int	op_create_index(void *ns, const char *name, int type, int flags);
147typedef int	op_remove_index(void *ns, const char *name);
148typedef	int	op_rename_index(void *ns, const char *oldname,
149					const char *newname);
150typedef int	op_stat_index(void *ns, const char *name, struct index_info *buf);
151
152typedef int	op_open_query(void *ns, const char *query, ulong flags,
153					port_id port, long token, void **cookie);
154typedef int	op_close_query(void *ns, void *cookie);
155typedef int	op_read_query(void *ns, void *cookie, long *num,
156					struct dirent *buf, size_t bufsize);
157
158typedef 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;
222
223extern _IMPEXP_KERNEL int	new_path(const char *path, char **copy);
224extern _IMPEXP_KERNEL void	free_path(char *p);
225
226extern _IMPEXP_KERNEL int	notify_listener(int op, nspace_id nsid,
227									vnode_id vnida,	vnode_id vnidb,
228									vnode_id vnidc, const char *name);
229extern _IMPEXP_KERNEL void	notify_select_event(selectsync *sync, uint32 ref);
230extern _IMPEXP_KERNEL int	send_notification(port_id port, long token,
231									ulong what, long op, nspace_id nsida,
232									nspace_id nsidb, vnode_id vnida,
233									vnode_id vnidb, vnode_id vnidc,
234									const char *name);
235extern _IMPEXP_KERNEL int	get_vnode(nspace_id nsid, vnode_id vnid, void **data);
236extern _IMPEXP_KERNEL int	put_vnode(nspace_id nsid, vnode_id vnid);
237extern _IMPEXP_KERNEL int	new_vnode(nspace_id nsid, vnode_id vnid, void *data);
238extern _IMPEXP_KERNEL int	remove_vnode(nspace_id nsid, vnode_id vnid);
239extern _IMPEXP_KERNEL int	unremove_vnode(nspace_id nsid, vnode_id vnid);
240extern _IMPEXP_KERNEL int	is_vnode_removed(nspace_id nsid, vnode_id vnid);
241
242
243extern _EXPORT vnode_ops	fs_entry;
244extern _EXPORT int32		api_version;
245
246#endif
247