--- a/src/server/daemon/vfs.h Sat Mar 16 23:11:34 2013 +0100 +++ b/src/server/daemon/vfs.h Sun Mar 17 12:47:59 2013 +0100 @@ -36,13 +36,20 @@ extern "C" { #endif -typedef struct VFS_IO VFS_IO; -typedef struct VFSFile VFSFile; +typedef struct VFS_IO VFS_IO; +typedef struct VFS_DIRIO VFS_DIRIO; +typedef struct VFSFile VFSFile; +typedef struct VFSDir VFSDir; +typedef struct VFSEntry VFSEntry; + +#define VFS_DIR VFSDir* +#define VFS_ENTRY VFSEntry struct VFS { SYS_FILE (*open)(VFSContext *ctx, char *path, int oflags); int (*stat)(VFSContext *ctx, char *path, struct stat *buf); int (*fstat)(VFSContext *ctx, SYS_FILE fd, struct stat *buf); + VFS_DIR (*opendir)(VFSContext *ctx, char *path); }; struct VFSContext { @@ -63,12 +70,30 @@ int fd; // native file descriptor if available, or -1 }; +struct VFSDir { + VFSContext *ctx; + VFS_DIRIO *io; + void *data; // private data used by the VFSDir implementation + int fd; // native file descriptor if available, or -1 +}; + +struct VFSEntry { + char *name; + struct stat stat; + int stat_errno; +}; + struct VFS_IO { ssize_t (*read)(SYS_FILE fd, void *buf, size_t nbyte); ssize_t (*write)(SYS_FILE fd, const void *buf, size_t nbyte); void (*close)(SYS_FILE fd); }; +struct VFS_DIRIO { + int (*readdir)(VFS_DIR dir, VFS_ENTRY *entry, int getstat); + void (*close)(VFS_DIR dir); +}; + /* * creates a VFSContext for a Request * vfs calls will do ACL checks @@ -82,6 +107,10 @@ int vfs_stat(VFSContext *ctx, char *path, struct stat *buf); int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf); void vfs_close(SYS_FILE fd); +VFS_DIR vfs_opendir(VFSContext *ctx, char *path); +int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry); +int vfs_readdir_stat(VFS_DIR dir, VFS_ENTRY *entry); +void vfs_closedir(VFS_DIR dir); // private int sys_acl_check(VFSContext *ctx, uint32_t acm, uid_t *uid, gid_t *gid); @@ -89,6 +118,8 @@ ssize_t sys_file_read(SYS_FILE fd, void *buf, size_t nbyte); ssize_t sys_file_write(SYS_FILE fd, const void *buf, size_t nbyte); void sys_file_close(SYS_FILE fd); +int sys_dir_read(VFS_DIR dir, VFS_ENTRY *entry, int getstat); +void sys_dir_close(VFS_DIR dir); #ifdef __cplusplus }