kernel: add filesystem model definitions
This commit is contained in:
71
include/socks/fs.h
Normal file
71
include/socks/fs.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#ifndef SOCKS_FS_H_
|
||||||
|
#define SOCKS_FS_H_
|
||||||
|
|
||||||
|
#include <socks/device.h>
|
||||||
|
#include <socks/queue.h>
|
||||||
|
|
||||||
|
#define SUPERBLOCK_ID_MAX 32
|
||||||
|
|
||||||
|
struct kext;
|
||||||
|
struct inode;
|
||||||
|
struct dentry;
|
||||||
|
struct super_block;
|
||||||
|
|
||||||
|
enum filesystem_flags {
|
||||||
|
FS_REQUIRES_DEV = 0x01u,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct super_block_ops {
|
||||||
|
kern_status_t(*write_inode)(struct inode *);
|
||||||
|
kern_status_t(*alloc_inode)(struct super_block *, struct inode **);
|
||||||
|
void(*destroy_inode)(struct inode *);
|
||||||
|
|
||||||
|
void(*destroy_super)(struct super_block *);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct super_block {
|
||||||
|
struct device *s_dev;
|
||||||
|
unsigned long s_blocksize;
|
||||||
|
unsigned long s_flags;
|
||||||
|
struct dentry *s_root;
|
||||||
|
struct super_block_ops *s_ops;
|
||||||
|
char s_id[SUPERBLOCK_ID_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct inode_ops {
|
||||||
|
kern_status_t(*create)(struct inode *, struct dentry *, umode_t);
|
||||||
|
kern_status_t(*mkdir)(struct inode *, struct dentry *, umode_t);
|
||||||
|
kern_status_t(*lookup)(struct inode *, struct dentry *, unsigned int);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dname {
|
||||||
|
uint64_t n_hash;
|
||||||
|
const char *n_str;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct inode {
|
||||||
|
struct super_block *i_sb;
|
||||||
|
unsigned long i_ino;
|
||||||
|
unsigned long i_mode;
|
||||||
|
unsigned long i_uid;
|
||||||
|
unsigned long i_gid;
|
||||||
|
unsigned long i_nlink;
|
||||||
|
struct inode_ops *i_ops;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct dentry {
|
||||||
|
struct dname d_name;
|
||||||
|
struct dentry *d_parent;
|
||||||
|
struct inode *d_inode;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct filesystem_driver {
|
||||||
|
const char *fs_name;
|
||||||
|
struct kext *fs_owner;
|
||||||
|
struct queue_entry fs_head;
|
||||||
|
enum filesystem_flags fs_flags;
|
||||||
|
|
||||||
|
struct dentry *(*mount)(struct filesystem_driver *, struct device *, int flags);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -8,4 +8,6 @@
|
|||||||
typedef uintptr_t phys_addr_t;
|
typedef uintptr_t phys_addr_t;
|
||||||
typedef uint64_t cycles_t;
|
typedef uint64_t cycles_t;
|
||||||
|
|
||||||
|
typedef unsigned int umode_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user