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