xref: /haiku/src/add-ons/kernel/file_systems/userlandfs/server/beos/fs_interface.h (revision 204ec4dec691a2d637997c13c6d8d9ecc66c97ce)
1 // beos_fs_interface.h
2 
3 #ifndef USERLAND_FS_BEOS_FS_INTERFACE_H
4 #define USERLAND_FS_BEOS_FS_INTERFACE_H
5 
6 #include <fs_interface.h>
7 
8 
9 // BeOS FS API version
10 #define		BEOS_FS_API_VERSION	2
11 
12 
13 /* helper struct allowing us to avoid problems with the st_*time macros */
14 typedef struct {
15     time_t  tv_sec;
16 } stat_beos_time;
17 
18 
19 // BeOS structures
20 
21 typedef struct beos_iovec {
22 	void	*iov_base;
23 	size_t	iov_len;
24 } beos_iovec;
25 
26 typedef struct beos_dirent {
27 	dev_t			d_dev;
28 	dev_t			d_pdev;
29 	ino_t			d_ino;
30 	ino_t			d_pino;
31 	unsigned short	d_reclen;
32 	char			d_name[1];
33 } beos_dirent_t;
34 
35 struct beos_stat {
36     dev_t			st_dev;
37     ino_t			st_ino;
38     mode_t			st_mode;
39     nlink_t			st_nlink;
40     uid_t			st_uid;
41     gid_t			st_gid;
42     off_t			st_size;
43     dev_t			st_rdev;
44     size_t			st_blksize;
45     stat_beos_time	st_atim;
46     stat_beos_time	st_mtim;
47     stat_beos_time	st_ctim;
48     stat_beos_time	st_crtim;
49 };
50 
51 struct beos_fs_info {
52 	dev_t	dev;
53 	ino_t	root;
54 	uint32	flags;
55 	off_t	block_size;
56 	off_t	io_size;
57 	off_t	total_blocks;
58 	off_t	free_blocks;
59 	off_t	total_nodes;
60 	off_t	free_nodes;
61 	char	device_name[128];
62 	char	volume_name[B_FILE_NAME_LENGTH];
63 	char	fsh_name[B_OS_NAME_LENGTH];
64 };
65 
66 typedef struct beos_attr_info {
67 	uint32     type;
68 	off_t      size;
69 } beos_attr_info;
70 
71 typedef struct beos_index_info {
72 	uint32     type;
73 	off_t      size;
74 	time_t     modification_time;
75 	time_t     creation_time;
76 	uid_t      uid;
77 	gid_t      gid;
78 } beos_index_info;
79 
80 
81 // FS interface hook types
82 
83 typedef int	beos_op_read_vnode(void *ns, ino_t vnid, char r, void **node);
84 typedef int	beos_op_write_vnode(void *ns, void *node, char r);
85 typedef int	beos_op_remove_vnode(void *ns, void *node, char r);
86 typedef int	beos_op_secure_vnode(void *ns, void *node);
87 
88 typedef int	beos_op_walk(void *ns, void *base, const char *file, char **newpath,
89 					ino_t *vnid);
90 
91 typedef int	beos_op_access(void *ns, void *node, int mode);
92 
93 typedef int	beos_op_create(void *ns, void *dir, const char *name,
94 					int omode, int perms, ino_t *vnid, void **cookie);
95 typedef int	beos_op_mkdir(void *ns, void *dir, const char *name, int perms);
96 typedef int	beos_op_symlink(void *ns, void *dir, const char *name,
97 					const char *path);
98 typedef int beos_op_link(void *ns, void *dir, const char *name, void *node);
99 
100 typedef int	beos_op_rename(void *ns, void *olddir, const char *oldname,
101 					void *newdir, const char *newname);
102 typedef int	beos_op_unlink(void *ns, void *dir, const char *name);
103 typedef int	beos_op_rmdir(void *ns, void *dir, const char *name);
104 
105 typedef int	beos_op_readlink(void *ns, void *node, char *buf, size_t *bufsize);
106 
107 typedef int beos_op_opendir(void *ns, void *node, void **cookie);
108 typedef int	beos_op_closedir(void *ns, void *node, void *cookie);
109 typedef int	beos_op_rewinddir(void *ns, void *node, void *cookie);
110 typedef int	beos_op_readdir(void *ns, void *node, void *cookie, long *num,
111 					struct beos_dirent *buf, size_t bufsize);
112 
113 typedef int	beos_op_open(void *ns, void *node, int omode, void **cookie);
114 typedef int	beos_op_close(void *ns, void *node, void *cookie);
115 typedef int beos_op_free_cookie(void *ns, void *node, void *cookie);
116 typedef int beos_op_read(void *ns, void *node, void *cookie, off_t pos,
117 					void *buf, size_t *len);
118 typedef int beos_op_write(void *ns, void *node, void *cookie, off_t pos,
119 					const void *buf, size_t *len);
120 typedef int beos_op_readv(void *ns, void *node, void *cookie, off_t pos,
121 					const beos_iovec *vec, size_t count, size_t *len);
122 typedef int beos_op_writev(void *ns, void *node, void *cookie, off_t pos,
123 					const beos_iovec *vec, size_t count, size_t *len);
124 typedef int	beos_op_ioctl(void *ns, void *node, void *cookie, int cmd,
125 					void *buf, size_t len);
126 typedef	int	beos_op_setflags(void *ns, void *node, void *cookie, int flags);
127 
128 typedef int	beos_op_rstat(void *ns, void *node, struct beos_stat *);
129 typedef int beos_op_wstat(void *ns, void *node, const struct beos_stat *,
130 					long mask);
131 typedef int	beos_op_fsync(void *ns, void *node);
132 
133 typedef int	beos_op_select(void *ns, void *node, void *cookie, uint8 event,
134 					uint32 ref, selectsync *sync);
135 typedef int	beos_op_deselect(void *ns, void *node, void *cookie, uint8 event,
136 					selectsync *sync);
137 
138 typedef int	beos_op_initialize(const char *devname, void *parms, size_t len);
139 typedef int	beos_op_mount(dev_t nsid, const char *devname, ulong flags,
140 					void *parms, size_t len, void **data, ino_t *vnid);
141 typedef int	beos_op_unmount(void *ns);
142 typedef int	beos_op_sync(void *ns);
143 typedef int beos_op_rfsstat(void *ns, struct beos_fs_info *);
144 typedef int beos_op_wfsstat(void *ns, struct beos_fs_info *, long mask);
145 
146 typedef int	beos_op_open_attrdir(void *ns, void *node, void **cookie);
147 typedef int	beos_op_close_attrdir(void *ns, void *node, void *cookie);
148 typedef int	beos_op_rewind_attrdir(void *ns, void *node, void *cookie);
149 typedef int	beos_op_read_attrdir(void *ns, void *node, void *cookie, long *num,
150 					struct beos_dirent *buf, size_t bufsize);
151 typedef int	beos_op_remove_attr(void *ns, void *node, const char *name);
152 typedef	int	beos_op_rename_attr(void *ns, void *node, const char *oldname,
153 					const char *newname);
154 typedef int	beos_op_stat_attr(void *ns, void *node, const char *name,
155 					struct beos_attr_info *buf);
156 
157 typedef int	beos_op_write_attr(void *ns, void *node, const char *name, int type,
158 					const void *buf, size_t *len, off_t pos);
159 typedef int	beos_op_read_attr(void *ns, void *node, const char *name, int type,
160 					void *buf, size_t *len, off_t pos);
161 
162 typedef int	beos_op_open_indexdir(void *ns, void **cookie);
163 typedef int	beos_op_close_indexdir(void *ns, void *cookie);
164 typedef int	beos_op_rewind_indexdir(void *ns, void *cookie);
165 typedef int	beos_op_read_indexdir(void *ns, void *cookie, long *num,
166 					struct beos_dirent *buf, size_t bufsize);
167 typedef int	beos_op_create_index(void *ns, const char *name, int type,
168 					int flags);
169 typedef int	beos_op_remove_index(void *ns, const char *name);
170 typedef	int	beos_op_rename_index(void *ns, const char *oldname,
171 					const char *newname);
172 typedef int	beos_op_stat_index(void *ns, const char *name,
173 					struct beos_index_info *buf);
174 
175 typedef int	beos_op_open_query(void *ns, const char *query, ulong flags,
176 					port_id port, long token, void **cookie);
177 typedef int	beos_op_close_query(void *ns, void *cookie);
178 typedef int	beos_op_read_query(void *ns, void *cookie, long *num,
179 					struct beos_dirent *buf, size_t bufsize);
180 
181 
182 // the FS interface structure
183 
184 typedef struct beos_vnode_ops {
185 	beos_op_read_vnode			*read_vnode;
186 	beos_op_write_vnode			*write_vnode;
187 	beos_op_remove_vnode		*remove_vnode;
188 	beos_op_secure_vnode		*secure_vnode;
189 	beos_op_walk				*walk;
190 	beos_op_access				*access;
191 	beos_op_create				*create;
192 	beos_op_mkdir				*mkdir;
193 	beos_op_symlink				*symlink;
194 	beos_op_link				*link;
195 	beos_op_rename				*rename;
196 	beos_op_unlink				*unlink;
197 	beos_op_rmdir				*rmdir;
198 	beos_op_readlink			*readlink;
199 	beos_op_opendir				*opendir;
200 	beos_op_closedir			*closedir;
201 	beos_op_free_cookie			*free_dircookie;
202 	beos_op_rewinddir			*rewinddir;
203 	beos_op_readdir				*readdir;
204 	beos_op_open				*open;
205 	beos_op_close				*close;
206 	beos_op_free_cookie			*free_cookie;
207 	beos_op_read				*read;
208 	beos_op_write				*write;
209 	beos_op_readv				*readv;
210 	beos_op_writev				*writev;
211 	beos_op_ioctl				*ioctl;
212 	beos_op_setflags			*setflags;
213 	beos_op_rstat				*rstat;
214 	beos_op_wstat				*wstat;
215 	beos_op_fsync				*fsync;
216 	beos_op_initialize			*initialize;
217 	beos_op_mount				*mount;
218 	beos_op_unmount				*unmount;
219 	beos_op_sync				*sync;
220 	beos_op_rfsstat				*rfsstat;
221 	beos_op_wfsstat				*wfsstat;
222 	beos_op_select				*select;
223 	beos_op_deselect			*deselect;
224 	beos_op_open_indexdir		*open_indexdir;
225 	beos_op_close_indexdir		*close_indexdir;
226 	beos_op_free_cookie			*free_indexdircookie;
227 	beos_op_rewind_indexdir		*rewind_indexdir;
228 	beos_op_read_indexdir		*read_indexdir;
229 	beos_op_create_index		*create_index;
230 	beos_op_remove_index		*remove_index;
231 	beos_op_rename_index		*rename_index;
232 	beos_op_stat_index			*stat_index;
233 	beos_op_open_attrdir		*open_attrdir;
234 	beos_op_close_attrdir		*close_attrdir;
235 	beos_op_free_cookie			*free_attrdircookie;
236 	beos_op_rewind_attrdir		*rewind_attrdir;
237 	beos_op_read_attrdir		*read_attrdir;
238 	beos_op_write_attr			*write_attr;
239 	beos_op_read_attr			*read_attr;
240 	beos_op_remove_attr			*remove_attr;
241 	beos_op_rename_attr			*rename_attr;
242 	beos_op_stat_attr			*stat_attr;
243 	beos_op_open_query			*open_query;
244 	beos_op_close_query			*close_query;
245 	beos_op_free_cookie			*free_querycookie;
246 	beos_op_read_query			*read_query;
247 } beos_vnode_ops;
248 
249 #endif	// USERLAND_FS_BEOS_FS_INTERFACE_H
250