// vfs.h // Virtual file system subsystem for HOS // Author: Josh Holtrop // Date: 05/10/05 // Modified: 05/10/05 #ifndef __HOS_VFS_H__ #define __HOS_VFS_H__ __HOS_VFS_H__ #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 #define VFS_PERMS_OX 0x0001 #define VFS_PERMS_OW 0x0002 #define VFS_PERMS_OR 0x0004 #define VFS_PERMS_GX 0x0008 #define VFS_PERMS_GW 0x0010 #define VFS_PERMS_GR 0x0020 #define VFS_PERMS_UX 0x0040 #define VFS_PERMS_UW 0x0080 #define VFS_PERMS_UR 0x0100 #define VFS_PERMS_STICKY 0x0200 #define VFS_PERMS_SGID 0x0400 #define VFS_PERMS_SUID 0x0800 #define EOF 1000000 #include "hos_defines.h" #include "devices.h" 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; u32_t dev; } vfs_stat_t; typedef u64_t inode_num_t; #ifdef _HOS_CPP_ extern "C" { #endif int vfs_init(); int vfs_mount(device_t device, char *fsType, char *mountPoint); int vfs_stat(char *name, vfs_stat_t *buff); #ifdef _HOS_CPP_ } #include "lang/string.h" #include "fs/FileSystem.h" #include "fs/VFSMount.h" typedef struct { string name; FileSystem *(*mount_func)(device_t); } FSHandle; typedef FileSystem *(*mount_func_t)(device_t); FileSystem *vfs_attempt_mount(device_t device, char *fsType); int vfs_register(char *fs, mount_func_t mount_func); mount_func_t vfs_get_mount_func(const string & fsName); inode_num_t vfs_get_inode(const string & path); #endif #endif