6 #define FS_DEBUG //printk
8 #define MAX_NAME_LEN 255
10 #define BLOCK_SIZE(fs) (1 << (fs)->block_shift)
11 #define SECTOR_SIZE(fs) (1 << (fs)->sector_shift)
13 /* namei: path lookup flags */
14 #define LOOKUP_PARENT 0x1
15 #define LOOKUP_CREATE 0x2
19 #define IS_DIR(dir) ((dir)->i_mode == TFS_DIR)
21 #define MAX_CWD_LEN 255
25 void *sb
; /* The fs-specific information */
29 uint32_t offset
; /* Disk offset as sectors */
31 char cwd
[MAX_CWD_LEN
];
37 void * (*mount
)(void);
38 int (*get_blk_shift
)(void *);
51 struct file_operations
*f_op
;
55 * The inode structure of VFS layer
58 int i_mode
; /* FILE or DIR */
60 uint32_t i_ino
; /* Inode number */
61 uint32_t i_atime
; /* Access time */
62 uint32_t i_mtime
; /* Modify time */
63 uint32_t i_ctime
; /* Create time */
64 uint32_t i_dtime
; /* Delete time */
65 uint32_t * i_data
; /* The block address array where the file stores */
73 struct inode_operations
* i_op
;
74 struct file_operations
* i_fop
;
77 struct inode_operations
{
78 struct inode
* (*iget
) (const char *, struct inode
*);
79 struct inode
* (*iget_root
)(struct fs
*fs
);
80 struct inode
* (*iget_by_inr
)(int);
81 int (*iwrite
) (struct inode
*);
83 int (*mkdir
)(struct inode
*, const char *);
84 int (*rmdir
)(struct inode
*, const char *);
85 int (*unlink
)(struct inode
*, const char *);
86 struct inode
*(*mknod
)(struct inode
*, const char *, int);
91 struct file_operations
{
92 int (*read
) (struct file
*, void *, int);
93 int (*write
) (struct file
*, void *, int);
94 void (*close
) (struct file
*);
95 struct dirent
* (*readdir
)(struct file
*);
98 extern struct fs
* current_root_fs
;
100 static inline struct fs
* root_fs(void)
102 return current_root_fs
;
105 extern uint8_t fds
[];
106 extern struct file
*files
[];
113 struct inode
*new_inode(int, int);
114 void free_inode(struct inode
*);
115 struct inode
* iget(const char *, struct inode
*);
118 int sys_open(const char *, uint32_t);
119 int sys_read(int, void *, int);
120 int sys_write(int, void *, int);
122 int sys_lseek(int, int, int);
125 struct inode
*namei(const char *, uint32_t);
126 struct inode
*namei_parent(const char *);
127 int sys_mkdir(const char *);
128 int sys_rmdir(const char *);
129 int sys_chdir(const char *);
130 int sys_getcwd(char *, int);
131 int sys_unlink(const char *);
134 int sys_execve(const char *, char **);
137 const char *get_base_name(const char *);
140 struct fs
*fs_init(void);