vfs: inode: add inode modes and filetypes
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
30c597c175
commit
2534c317f2
2 changed files with 30 additions and 8 deletions
|
|
@ -34,14 +34,14 @@ typedef struct _dirent dirent_t;
|
|||
typedef struct _fs fs_t;
|
||||
|
||||
struct inode_ops {
|
||||
/* for all files */
|
||||
/* FOR ALL FILES */
|
||||
ssize_t (*read)(inode_t *inode, char *buf, size_t size, size_t offset);
|
||||
ssize_t (*write)(inode_t *inode, char *buf, size_t size, size_t offset);
|
||||
/* for directory files */
|
||||
int (*creat)(inode_t *inode, const char *name, u64 mode, dirent_t **out);
|
||||
int (*mkdir)(inode_t *inode, const char *name, dirent_t **out);
|
||||
int (*link)(inode_t *inode, inode_t *link_inode, const char *name, dirent_t **out);
|
||||
int (*unlink)(inode_t *inode, const char *name);
|
||||
|
||||
/* FOR DIRECTORY FILES */
|
||||
|
||||
int (*link)(dirent_t *in, inode_t *to, const char *name, dirent_t **out);
|
||||
int (*unlink)(dirent_t *dent);
|
||||
ssize_t (*get_dents)(inode_t *parent, dirent_t **dents);
|
||||
};
|
||||
|
||||
|
|
@ -49,7 +49,7 @@ struct _inode {
|
|||
u64 mode;
|
||||
u64 ino_num;
|
||||
u64 file_size;
|
||||
dirent_t *dentry;
|
||||
dirent_t *dentry;
|
||||
|
||||
u64 flags;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,27 @@
|
|||
#include <lib/rwlock.h>
|
||||
#include <lib/list.h>
|
||||
|
||||
#define S_IFMT 0xF000
|
||||
#define S_IFREG 0x8000
|
||||
#define S_IFDIR 0x4000
|
||||
#define S_IFLNK 0xA000
|
||||
#define S_IFCHR 0x2000
|
||||
#define S_IFBLK 0x6000
|
||||
#define S_IFIFO 0x1000
|
||||
#define S_IFSOCK 0xC000
|
||||
|
||||
#define FT_MASK 0x07
|
||||
#define FT_UNKNOWN 0x00
|
||||
#define FT_REG_FILE 0x01
|
||||
#define FT_DIR 0x02
|
||||
#define FT_CHRDEV 0x03
|
||||
#define FT_BLKDEV 0x04
|
||||
#define FT_FIFO 0x05
|
||||
#define FT_SOCK 0x06
|
||||
#define FT_SYMLINK 0x07
|
||||
|
||||
#define FS_RDONLY 0x00000001
|
||||
|
||||
struct fs_type {
|
||||
char name[256];
|
||||
dirent_t *(*fs_mount)(int flags, struct block_device *bdev);
|
||||
|
|
@ -17,13 +38,14 @@ struct fs_type {
|
|||
};
|
||||
|
||||
struct fs_ops {
|
||||
int (*alloc_inode)(fs_t *fs, dirent_t **out);
|
||||
int (*alloc_inode)(fs_t *fs, u64 mode, inode_t **out);
|
||||
int (*free_inode)(fs_t *fs, inode_t *inode);
|
||||
int (*open_inode)(fs_t *fs, u64 id, dirent_t *dirent, inode_t **out);
|
||||
};
|
||||
|
||||
struct _fs {
|
||||
u64 type;
|
||||
u64 flags;
|
||||
size_t block_size;
|
||||
size_t n_blocks;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue