1 /* Part of libsffs - (c) 2012, D.C. van Moolenbroek */ 2 3 #ifndef _MINIX_SFFS_H 4 #define _MINIX_SFFS_H 5 6 #include <sys/types.h> 7 #include <sys/time.h> 8 #include <minix/u64.h> 9 10 typedef void *sffs_file_t; /* handle to open file */ 11 typedef void *sffs_dir_t; /* handle to directory search */ 12 13 struct sffs_attr { 14 u32_t a_mask; /* which fields to retrieve/set */ 15 mode_t a_mode; /* file type and permissions */ 16 u64_t a_size; /* file size */ 17 struct timespec a_crtime; /* file creation time */ 18 struct timespec a_atime; /* file access time */ 19 struct timespec a_mtime; /* file modification time */ 20 struct timespec a_ctime; /* file change time */ 21 }; 22 23 #define SFFS_ATTR_SIZE 0x01 /* get/set file size */ 24 #define SFFS_ATTR_CRTIME 0x02 /* get/set file creation time */ 25 #define SFFS_ATTR_ATIME 0x04 /* get/set file access time */ 26 #define SFFS_ATTR_MTIME 0x08 /* get/set file modification time */ 27 #define SFFS_ATTR_CTIME 0x10 /* get/set file change time */ 28 #define SFFS_ATTR_MODE 0x20 /* get/set file mode */ 29 30 struct sffs_table { 31 int (*t_open)(const char *path, int flags, int mode, sffs_file_t *handle); 32 ssize_t (*t_read)(sffs_file_t handle, char *buf, size_t size, u64_t pos); 33 ssize_t (*t_write)(sffs_file_t handle, char *buf, size_t size, u64_t pos); 34 int (*t_close)(sffs_file_t handle); 35 36 size_t (*t_readbuf)(char **ptr); 37 size_t (*t_writebuf)(char **ptr); 38 39 int (*t_opendir)(const char *path, sffs_dir_t *handle); 40 int (*t_readdir)(sffs_dir_t handle, unsigned int index, char *buf, 41 size_t size, struct sffs_attr *attr); 42 int (*t_closedir)(sffs_dir_t handle); 43 44 int (*t_getattr)(const char *path, struct sffs_attr *attr); 45 int (*t_setattr)(const char *path, struct sffs_attr *attr); 46 47 int (*t_mkdir)(const char *path, int mode); 48 int (*t_unlink)(const char *path); 49 int (*t_rmdir)(const char *path); 50 int (*t_rename)(const char *opath, const char *npath); 51 52 int (*t_queryvol)(const char *path, u64_t *free, u64_t *total); 53 }; 54 55 struct sffs_params { 56 char p_prefix[PATH_MAX]; /* prefix for all paths used */ 57 uid_t p_uid; /* UID that owns all files */ 58 gid_t p_gid; /* GID that owns all files */ 59 unsigned int p_file_mask; /* AND-mask to apply to file permissions */ 60 unsigned int p_dir_mask; /* AND-mask to apply to directory perms */ 61 int p_case_insens; /* case insensitivity flag */ 62 }; 63 64 int sffs_init(char *name, const struct sffs_table *table, 65 struct sffs_params *params); 66 void sffs_signal(int signo); 67 void sffs_loop(void); 68 69 #endif /* _MINIX_SFFS_H */ 70