MOS Source Code
|
The Virtual File System (VFS) is an abstraction layer that allows the kernel to interact with different filesystems in a uniform way. More...
Topics | |
Directory Entry | |
Directory entry. | |
Functions | |
should_inline const file_ops_t * | file_get_ops (file_t *file) |
file_t * | vfs_do_open_dentry (dentry_t *entry, bool created, bool read, bool write, bool exec, bool truncate) |
Open an directory dentry. | |
void | vfs_register_filesystem (filesystem_t *fs) |
long | vfs_mount (const char *device, const char *path, const char *fs, const char *options) |
Mount a filesystem at a given existing path. | |
long | vfs_unmount (const char *path) |
Unmount a filesystem at a given path. | |
file_t * | vfs_openat (int fd, const char *path, open_flags flags) |
Open a file at a given path. | |
long | vfs_fstatat (fd_t fd, const char *path, file_stat_t *restrict stat, fstatat_flags flags) |
Stat a file. | |
size_t | vfs_readlinkat (fd_t dirfd, const char *path, char *buf, size_t size) |
Read a symbolic link. | |
long | vfs_symlink (const char *path, const char *target) |
Create a symbolic link. | |
long | vfs_mkdir (const char *path) |
Create a directory. | |
long | vfs_rmdir (const char *path) |
size_t | vfs_list_dir (io_t *io, void *buf, size_t size) |
Get the content of a directory. | |
long | vfs_chdirat (fd_t dirfd, const char *path) |
Change the current working directory. | |
ssize_t | vfs_getcwd (char *buf, size_t size) |
Get the current working directory. | |
long | vfs_fchmodat (fd_t fd, const char *path, int perm, int flags) |
Change the permissions of a file. | |
long | vfs_unlinkat (fd_t dirfd, const char *path) |
Remove the name of a file, and possibly the file itself. | |
long | vfs_fsync (io_t *io, bool sync_metadata, off_t start, off_t end) |
Synchronize a file with the filesystem. | |
Variables | |
dentry_t * | root_dentry |
The Virtual File System (VFS) is an abstraction layer that allows the kernel to interact with different filesystems in a uniform way.
should_inline const file_ops_t * file_get_ops | ( | file_t * | file | ) |
Definition at line 18 of file vfs.h.
Referenced by vfs_do_open_dentry(), vfs_io_ops_close(), vfs_io_ops_mmap(), vfs_io_ops_munmap(), vfs_io_ops_read(), vfs_io_ops_seek(), and vfs_io_ops_write().
file_t * vfs_do_open_dentry | ( | dentry_t * | entry, |
bool | created, | ||
bool | read, | ||
bool | write, | ||
bool | exec, | ||
bool | truncate ) |
Open an directory dentry.
entry | |
created | |
read | |
write | |
exec | |
truncate |
Definition at line 413 of file vfs.c.
Referenced by memfd_create(), and vfs_do_open().
void vfs_register_filesystem | ( | filesystem_t * | fs | ) |
Definition at line 452 of file vfs.c.
Referenced by MOS_INIT(), and userfs_manager_register_filesystem().
long vfs_mount | ( | const char * | device, |
const char * | path, | ||
const char * | fs, | ||
const char * | options ) |
Mount a filesystem at a given existing path.
device | The device to mount |
path | The path to mount the filesystem at, this absolute path to a directory must exist |
fs | The filesystem type, e.g. "tmpfs" |
options | The options to pass to the filesystem |
Definition at line 466 of file vfs.c.
Referenced by mos_start_kernel(), MOS_STATIC_ASSERT(), and MOS_TEST_DECL_PTEST().
long vfs_unmount | ( | const char * | path | ) |
Unmount a filesystem at a given path.
path | The path to the filesystem |
Definition at line 536 of file vfs.c.
Referenced by MOS_STATIC_ASSERT(), and MOS_TEST_DECL_PTEST().
file_t * vfs_openat | ( | int | fd, |
const char * | path, | ||
open_flags | flags ) |
Open a file at a given path.
fd | The fd of an open directory, or AT_FDCWD to use the current working directory |
path | The path to the file, can be absolute or relative |
flags | open_flags flags |
Definition at line 578 of file vfs.c.
Referenced by elf_create_process(), elf_map_interpreter(), and process_do_execveat().
long vfs_fstatat | ( | fd_t | fd, |
const char * | path, | ||
file_stat_t *restrict | stat, | ||
fstatat_flags | flags ) |
Stat a file.
fd | The directory, or a file if FSTATAT_FILE is set |
path | The path to the file |
flags | fstat_flags flags |
stat | The stat struct to store the file information in |
If the FSTATAT_FILE is set, the fd is a file, and the path will be ignored. If it is not set: If the path is absolute, the fd will be ignored. If the path is relative, the fd will be used as the directory to resolve the path from. If FSTATAT_NOFOLLOW is set, when the path is used, symlinks will not be followed.
Definition at line 588 of file vfs.c.
Read a symbolic link.
dirfd | The file descriptor of the directory containing the symbolic link |
path | The path to the symbolic link |
buf | The buffer to store the link in |
size | The size of the buffer |
Definition at line 623 of file vfs.c.
Referenced by MOS_STATIC_ASSERT().
long vfs_symlink | ( | const char * | path, |
const char * | target ) |
Create a symbolic link.
path | The path to the symbolic link |
target | The target of the symbolic link |
Definition at line 646 of file vfs.c.
Referenced by MOS_STATIC_ASSERT().
long vfs_mkdir | ( | const char * | path | ) |
Create a directory.
path | The path to the directory |
Definition at line 664 of file vfs.c.
Referenced by mos_start_kernel(), MOS_STATIC_ASSERT(), and MOS_TEST_DECL_PTEST().
long vfs_rmdir | ( | const char * | path | ) |
Definition at line 689 of file vfs.c.
Referenced by MOS_TEST_DECL_PTEST().
Get the content of a directory.
io | The io object of a file_t, must be a directory and opened with FILE_OPEN_READ |
buf | The buffer to store the directory entries in |
size | The size of the buffer |
Definition at line 713 of file vfs.c.
long vfs_chdirat | ( | fd_t | dirfd, |
const char * | path ) |
Change the current working directory.
dirfd | The file descriptor of the directory to change to |
path | The path to the directory, relative to the dirfd |
Definition at line 764 of file vfs.c.
Referenced by MOS_STATIC_ASSERT().
Get the current working directory.
buf | The buffer to store the path in |
size | The size of the buffer |
Definition at line 780 of file vfs.c.
Referenced by MOS_STATIC_ASSERT().
Change the permissions of a file.
fd | The directory, or a file if FSTATAT_FILE is set |
path | The path to the file |
perm | The new permissions |
flags | fstat_flags flags |
Definition at line 789 of file vfs.c.
Referenced by MOS_STATIC_ASSERT().
long vfs_unlinkat | ( | fd_t | dirfd, |
const char * | path ) |
Remove the name of a file, and possibly the file itself.
dirfd | The file descriptor of the directory containing the file (or the file itself if AT_EMPTY_PATH is set) |
path | The path to the file |
Definition at line 803 of file vfs.c.
Referenced by MOS_STATIC_ASSERT().
Synchronize a file with the filesystem.
io | The io object of a file_t |
sync_metadata | Whether to sync the metadata |
start | The start of the range to sync |
end | The end of the range to sync |
Definition at line 830 of file vfs.c.