![]() |
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 | |
PtrResult< BasicFile > | 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) |
PtrResult< void > | 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. | |
PtrResult< BasicFile > | vfs_openat (int fd, const char *path, OpenFlags flags) |
Open a file at a given path. | |
long | vfs_fstatat (fd_t fd, const char *path, file_stat_t *__restrict stat, FStatAtFlags 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. | |
PtrResult< void > | vfs_mkdir (const char *path) |
Create a directory. | |
PtrResult< void > | vfs_rmdir (const char *path) |
size_t | vfs_list_dir (IO *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 *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.
PtrResult< BasicFile > 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 411 of file vfs.cpp.
Referenced by memfd_create(), and vfs_do_open().
void vfs_register_filesystem | ( | filesystem_t * | fs | ) |
Definition at line 452 of file vfs.cpp.
Referenced by MOS_INIT(), and userfs_manager_register_filesystem().
PtrResult< void > 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.cpp.
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 545 of file vfs.cpp.
Referenced by MOS_STATIC_ASSERT(), and MOS_TEST_DECL_PTEST().
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 587 of file vfs.cpp.
Referenced by elf_create_process(), elf_map_interpreter(), MOS_STATIC_ASSERT(), and process_do_execveat().
long vfs_fstatat | ( | fd_t | fd, |
const char * | path, | ||
file_stat_t *__restrict | stat, | ||
FStatAtFlags | 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 598 of file vfs.cpp.
Referenced by MOS_STATIC_ASSERT().
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 634 of file vfs.cpp.
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 660 of file vfs.cpp.
Referenced by MOS_STATIC_ASSERT().
Create a directory.
path | The path to the directory |
Definition at line 681 of file vfs.cpp.
Referenced by mos_start_kernel(), MOS_STATIC_ASSERT(), and MOS_TEST_DECL_PTEST().
Definition at line 710 of file vfs.cpp.
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 737 of file vfs.cpp.
Referenced by MOS_STATIC_ASSERT(), and Directory::on_read().
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 789 of file vfs.cpp.
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 808 of file vfs.cpp.
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 817 of file vfs.cpp.
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 834 of file vfs.cpp.
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 864 of file vfs.cpp.
Referenced by MOS_STATIC_ASSERT().