123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- #pragma once
- #include <common/glib.h>
- #include <common/fcntl.h>
- struct vfs_superblock_t *vfs_root_sb = NULL;
- #define VFS_DPT_MBR 0
- #define VFS_DPT_GPT 1
- #define VFS_SUCCESS 0
- #define VFS_E_FS_EXISTED 1
- #define VFS_E_FS_NOT_EXIST 2
- #define VFS_ATTR_FILE (1UL << 0)
- #define VFS_ATTR_DIR (1UL << 1)
- #define VFS_ATTR_DEVICE (1UL << 2)
- struct vfs_super_block_operations_t;
- struct vfs_inode_operations_t;
- struct vfs_index_node_t;
- struct vfs_dir_entry_operations_t;
- struct vfs_dir_entry_t
- {
- char *name;
- int name_length;
- struct List child_node_list;
- struct List subdirs_list;
- struct vfs_index_node_t *dir_inode;
- struct vfs_dir_entry_t *parent;
- struct vfs_dir_entry_operations_t *dir_ops;
- };
- struct vfs_superblock_t
- {
- struct vfs_dir_entry_t *root;
- struct vfs_super_block_operations_t *sb_ops;
- void *private_sb_info;
- };
- struct vfs_index_node_t
- {
- uint64_t file_size;
- uint64_t blocks;
- uint64_t attribute;
- struct vfs_superblock_t *sb;
- struct vfs_file_operations_t *file_ops;
- struct vfs_inode_operations_t *inode_ops;
- void *private_inode_info;
- };
- struct vfs_file_t
- {
- long position;
- uint64_t mode;
- struct vfs_dir_entry_t *dEntry;
- struct vfs_file_operations_t *file_ops;
- void *private_data;
- };
- struct vfs_filesystem_type_t
- {
- char *name;
- int fs_flags;
- struct vfs_superblock_t *(*read_superblock)(void *DPTE, uint8_t DPT_type, void *buf, int8_t ahci_ctrl_num, int8_t ahci_port_num, int8_t part_num);
- struct vfs_filesystem_type_t *next;
- };
- struct vfs_super_block_operations_t
- {
- void (*write_superblock)(struct vfs_superblock_t *sb);
- void (*put_superblock)(struct vfs_superblock_t *sb);
- void (*write_inode)(struct vfs_index_node_t *inode);
- };
- struct vfs_inode_operations_t
- {
-
- long (*create)(struct vfs_index_node_t *parent_inode, struct vfs_dir_entry_t *dest_dEntry, int mode);
-
- struct vfs_dir_entry_t *(*lookup)(struct vfs_index_node_t *parent_inode, struct vfs_dir_entry_t *dest_dEntry);
-
- long (*mkdir)(struct vfs_index_node_t *inode, struct vfs_dir_entry_t *dEntry, int mode);
- long (*rmdir)(struct vfs_index_node_t *inode, struct vfs_dir_entry_t *dEntry);
- long (*rename)(struct vfs_index_node_t *old_inode, struct vfs_dir_entry_t *old_dEntry, struct vfs_index_node_t *new_inode, struct vfs_dir_entry_t *new_dEntry);
- long (*getAttr)(struct vfs_dir_entry_t *dEntry, uint64_t *attr);
- long (*setAttr)(struct vfs_dir_entry_t *dEntry, uint64_t *attr);
- };
- struct vfs_dir_entry_operations_t
- {
- long (*compare)(struct vfs_dir_entry_t *parent_dEntry, char *source_filename, char *dest_filename);
- long (*hash)(struct vfs_dir_entry_t *dEntry, char *filename);
- long (*release)(struct vfs_dir_entry_t *dEntry);
- long (*iput)(struct vfs_dir_entry_t *dEntry, struct vfs_index_node_t *inode);
- };
- typedef int (*vfs_filldir_t)(void *buf, ino_t d_ino, char *name, int namelen, unsigned char type, off_t offset);
- struct vfs_file_operations_t
- {
- long (*open)(struct vfs_index_node_t *inode, struct vfs_file_t *file_ptr);
- long (*close)(struct vfs_index_node_t *inode, struct vfs_file_t *file_ptr);
- long (*read)(struct vfs_file_t *file_ptr, char *buf, int64_t count, long *position);
- long (*write)(struct vfs_file_t *file_ptr, char *buf, int64_t count, long *position);
- long (*lseek)(struct vfs_file_t *file_ptr, long offset, long origin);
- long (*ioctl)(struct vfs_index_node_t *inode, struct vfs_file_t *file_ptr, uint64_t cmd, uint64_t arg);
- long (*readdir)(struct vfs_file_t *file_ptr, void *dirent, vfs_filldir_t filler);
- };
- uint64_t vfs_register_filesystem(struct vfs_filesystem_type_t *fs);
- uint64_t vfs_unregister_filesystem(struct vfs_filesystem_type_t *fs);
- struct vfs_superblock_t *vfs_mount_fs(char *name, void *DPTE, uint8_t DPT_type, void *buf, int8_t ahci_ctrl_num, int8_t ahci_port_num, int8_t part_num);
- struct vfs_dir_entry_t *vfs_path_walk(const char *path, uint64_t flags);
- int vfs_fill_dentry(void *buf, ino_t d_ino, char *name, int namelen, unsigned char type, off_t offset);
|