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