// vfs.h // Author: Josh Holtrop // Date: 08/22/04 // Modified: 12/21/04 #ifndef __HOS_VFS_H__ #define __HOS_VFS_H__ __HOS_VFS_H__ #include "hos_defines.h" #include "fs/devices.h" #define FS_EXT2 1 #define VFS_MAX_FS 10 #define VFS_FT_UNKNOWN 0 #define VFS_FT_FILE 1 #define VFS_FT_DIR 2 #define VFS_FT_CHAR 3 #define VFS_FT_BLOCK 4 #define VFS_FT_FIFO 5 #define VFS_FT_SOCK 6 #define VFS_FT_SYMLINK 7 /* Structure to hold information about a mount point */ typedef struct { int refs; void *super; int fs; major_t major; minor_t minor; } vfs_mount_t; /* Every filesystem must provide pointers to its respective functions in a structure like this */ typedef struct { void *(*mount_super)(major_t major, minor_t minor); int (*umount_super)(vfs_mount_t *mount); int (*mkfs)(major_t major, minor_t minor); } vfs_fs_t; /* This structure represents a node of the "VFS Mount Tree" */ struct vfs_node_s { char chr; // the character we are at vfs_mount_t *mount; // is there a mount at this character? struct vfs_node_s *up; // the parent struct vfs_node_s *next; // the next sibling struct vfs_node_s *down; // subtree for submounts }; typedef struct vfs_node_s vfs_node_t; /* This structure is generated when a path is matched. For example, if /dev is mounted on device (4,2) and '/dev/yoda' is looked up, the structure returned would be {4, 2, 4} and then the lookup could continue on device (4,2) with 4 characters stripped off the front of the initial path (ex '/yoda') */ typedef struct { vfs_mount_t *mount; int length; } vfs_mount_match_t; typedef struct { u16_t type; // file type, of VFS_FILE_TYPE_* u32_t size; u32_t inode; u16_t permissions; u16_t uid; u16_t gid; u32_t atime; u32_t mtime; u32_t ctime; u16_t links; } vfs_stat_t; int vfs_init(); int vfs_mount(major_t maj, minor_t min, int fsType, char *mountPoint); int vfs_register_fs(int fsn, vfs_fs_t *fs); int vfs_add_mount(vfs_mount_t *mnt, char *mountPoint); vfs_mount_t *vfs_find_mount(char *mountPoint); vfs_mount_match_t vfs_get_rel_path(char *path); int vfs_umount(char *mountPoint); int vfs_retire_node(vfs_node_t *node); void vfs_dump_tree(); void vfs_dump_node(vfs_node_t *node, int level); #endif