X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/a362b4b2c4abbf2da6ec14cb44a8685a81107f6a..6f6da1abb22dff69dbb710bd2fd9d95f083f2b43:/lunaix-os/includes/lunaix/fs.h diff --git a/lunaix-os/includes/lunaix/fs.h b/lunaix-os/includes/lunaix/fs.h index 8e6961d..d599023 100644 --- a/lunaix-os/includes/lunaix/fs.h +++ b/lunaix-os/includes/lunaix/fs.h @@ -6,25 +6,42 @@ #include #include #include +#include #include #include #include -#include #include + #include +#include + #define VFS_NAME_MAXLEN 128 #define VFS_MAX_FD 32 -#define VFS_IFDIR 0x1 -#define VFS_IFFILE 0x2 -#define VFS_IFSEQDEV 0x4 -#define VFS_IFVOLDEV 0x8 -#define VFS_IFSYMLINK 0x16 +#define VFS_IFDIR F_DIR +#define VFS_IFFILE F_FILE +#define VFS_IFDEV (F_DEV | F_FILE) +#define VFS_IFSEQDEV (F_SEQDEV | F_FILE) +#define VFS_IFVOLDEV (F_VOLDEV | F_FILE) +#define VFS_IFSYMLINK (F_SYMLINK | F_FILE) +#define VFS_DEVFILE(type) ((type) & F_DEV) +#define VFS_DEVTYPE(type) ((type) & ((F_SEQDEV | F_VOLDEV) ^ F_DEV)) + +// Walk, mkdir if component encountered is non-exists. #define VFS_WALK_MKPARENT 0x1 + +// Walk, relative to current FS. #define VFS_WALK_FSRELATIVE 0x2 + +/* + Terminate the walk on the immediate parent, + name of child (last component) is returned through `component` +*/ #define VFS_WALK_PARENT 0x4 + +// Do not follow the symbolic link #define VFS_WALK_NOFOLLOW 0x8 #define VFS_HASHTABLE_BITS 10 @@ -36,11 +53,11 @@ #define FSTYPE_ROFS 0x1 -#define DO_STATUS(errno) SYSCALL_ESTATUS(__current->k_status = errno) -#define DO_STATUS_OR_RETURN(errno) ({ errno < 0 ? DO_STATUS(errno) : errno; }) - #define TEST_FD(fd) (fd >= 0 && fd < VFS_MAX_FD) +#define EXPORT_FILE_SYSTEM(fs_id, init_fn) \ + export_ldga_el(fs, fs_id, ptr_t, init_fn) + #define VFS_VALID_CHAR(chr) \ (('A' <= (chr) && (chr) <= 'Z') || ('a' <= (chr) && (chr) <= 'z') || \ ('0' <= (chr) && (chr) <= '9') || (chr) == '.' || (chr) == '_' || \ @@ -95,9 +112,9 @@ struct v_superblock struct device* dev; struct v_dnode* root; struct filesystem* fs; - u32_t iobuf_size; struct hbucket* i_cache; void* data; + size_t blksize; struct { u32_t (*read_capacity)(struct v_superblock* vsb); @@ -218,6 +235,8 @@ struct v_inode struct pcache* pg_cache; struct v_inode_ops* ops; struct v_file_ops* default_fops; + + void (*destruct)(struct v_inode* inode); }; struct v_mount @@ -399,6 +418,9 @@ vfs_get_dtype(int itype); void vfs_ref_dnode(struct v_dnode* dnode); +void +vfs_ref_file(struct v_file* file); + void vfs_unref_dnode(struct v_dnode* dnode);