25 #define FS_DEFAULT_FILE_MODE 0644
26 #define FS_DEFAULT_DIR_MODE 0755
31 #define FS_DEFAULT_UMASK 022
37 extern struct file *thread_pipe[THREAD_MAX];
58 typedef void (*drv_init_func_t)(void);
92 struct file *dev_file;
120 uint32_t reserved[2];
126 char d_name[NAME_MAX];
133 uint32_t reserved[2];
137 struct inode *f_inode;
150 off_t (*lseek)(
struct file *filp, off_t offset,
int whence);
151 ssize_t (*
read)(
struct file *filp,
char *buf,
size_t size, off_t offset);
156 int (*
ioctl)(
struct file *,
unsigned int cmd,
unsigned long arg);
172 void rootfs_init(
void);
174 void link_stdin_dev(
char *path);
175 void link_stdout_dev(
char *path);
176 void link_stderr_dev(
char *path);
181 bool file_is_opened(
struct file *filp);
184 uint32_t fs_get_block_addr(
struct inode *
inode,
int blk_index);
185 uint32_t fs_file_append_block(
struct inode *
inode);
188 static inline uint32_t fs_now(
void)
194 return (uint32_t) tp.tv_sec;
200 static inline void fs_fill_stat(
struct stat *statbuf,
const struct inode *
inode)
202 memset(statbuf, 0,
sizeof(*statbuf));
204 statbuf->st_dev =
inode->i_rdev;
205 statbuf->st_ino =
inode->i_ino;
206 statbuf->st_mode =
inode->i_mode;
207 statbuf->st_nlink = 1;
208 statbuf->st_rdev =
inode->i_rdev;
209 statbuf->st_size =
inode->i_size;
210 statbuf->st_blksize = FS_BLK_SIZE;
211 statbuf->st_blocks =
inode->i_blocks;
212 statbuf->st_mtim.tv_sec =
inode->i_mtime;
215 void request_create_file(
int thread_id,
const char *path, mode_t mode);
216 void request_mkdir(
int thread_id,
const char *path, mode_t mode);
217 void request_chmod(
int thread_id,
const char *path, mode_t mode);
218 void request_utime(
int thread_id,
const char *path, uint32_t mtime);
219 void request_remove(
int thread_id,
const char *path,
bool rm_dir);
220 void request_stat(
int thread_id,
const char *path,
struct stat *statbuf);
221 void request_rename(
int thread_id,
const char *oldpath,
const char *newpath);
222 void request_open_file(
int thread_id,
const char *path);
223 void request_open_directory(
int reply_fd,
const char *path);
224 void request_mount(
int thread_id,
const char *source,
const char *target);
225 void request_getcwd(
int thread_id,
char *buf,
size_t len);
226 void request_chdir(
int thread_id,
const char *path);
231 void fs_print_block_bitmap(
void);
int open(const char *pathname, int flags,...)
Open the file specified by the pathname.
Definition: file.c:36
void fs_print_inode_bitmap(void)
Definition: fs.c:1772
int ioctl(int fd, unsigned long request,...)
Perform device-specific control.
Definition: file.c:147
ssize_t write(int fd, const void *buf, size_t count)
Write up to count bytes from the buffer starting at buf to the file referred to by the file descripto...
Definition: file.c:132
ssize_t read(int fd, void *buf, size_t count)
Attempt to read up to count bytes from file descriptor fd into the buffer starting at buf.
Definition: file.c:117