// // Created by rick on 19-09-21. // #ifndef NEW_KERNEL_VFS_H #define NEW_KERNEL_VFS_H #include #include #define VFS_MOUNT_OK 0 #define VFS_MOUNT_ERROR 1 #define VFS_OPEN_ERROR 1 #define VFS_OPEN_OK 0 #define VFS_CLOSE_OK 1 #define VFS_READ_ERROR (-1) #define VFS_DGETENTS_ERR 1 struct vfs_mount; typedef struct vfs_mount { struct { } flags; const char *prefix; const char *device; void *driver; // vfs_mount_driver_t void *global_driver_data; struct vfs_mount *next; } vfs_mount_t; typedef struct vfs_fd { struct { } flags; vfs_mount_t *mount; void *driver_data; } vfs_fd_t; #define VFS_DIRENT_BASE_SIZE (4 + 4 + 2 + 1) #define VFS_DIRENT_SIZE(name_length) ((VFS_DIRENT_BASE_SIZE + (name_length) + 1 + 15) & (~0xF)) #define VFS_DIRENT_MAX_SIZE (VFS_DIRENT_BASE_SIZE + 256 + 1) typedef struct vfs_dirent { uint32_t inode; uint32_t offset_next; uint16_t reclen; uint8_t type; char name[]; } vfs_dirent_t; int vfs_mount(const char *path, const char *device, const char *driver); // https://man7.org/linux/man-pages/man2/open.2.html vfs_fd_t *vfs_open(const char *path, int flags, int mode); void vfs_close(vfs_fd_t *fd); // https://man7.org/linux/man-pages/man2/stat.2.html int vfs_fstat(vfs_fd_t *fd, stat_t *target, int flags); // https://man7.org/linux/man-pages/man2/read.2.html int vfs_read(vfs_fd_t *fd, void *target, size_t size); // inspiration https://man7.org/linux/man-pages/man2/getdents.2.html int vfs_getdents(vfs_fd_t *fd, void *target, int count); #endif //NEW_KERNEL_VFS_H