MOS Source Code
Loading...
Searching...
No Matches
Virtual File System

The Virtual File System (VFS) is an abstraction layer that allows the kernel to interact with different filesystems in a uniform way. More...

+ Collaboration diagram for Virtual File System:

Topics

 Directory Entry
 Directory entry.
 

Functions

should_inline const file_ops_tfile_get_ops (file_t *file)
 
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_tvfs_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_chdir (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.
 

Variables

dentry_troot_dentry
 

Detailed Description

The Virtual File System (VFS) is an abstraction layer that allows the kernel to interact with different filesystems in a uniform way.

Function Documentation

◆ file_get_ops()

◆ vfs_register_filesystem()

void vfs_register_filesystem ( filesystem_t * fs)

Definition at line 372 of file vfs.c.

Referenced by register_cpiofs(), register_sysfs(), register_tmpfs(), and userfs_manager_register().

+ Here is the call graph for this function:

◆ vfs_mount()

long vfs_mount ( const char * device,
const char * path,
const char * fs,
const char * options )

Mount a filesystem at a given existing path.

Parameters
deviceThe device to mount
pathThe path to mount the filesystem at, this absolute path to a directory must exist
fsThe filesystem type, e.g. "tmpfs"
optionsThe options to pass to the filesystem
Returns
true if the filesystem was mounted successfully
false if the filesystem could not be mounted, see the kernel log for more information

Definition at line 381 of file vfs.c.

Referenced by DEFINE_SYSCALL(), mos_start_kernel(), and MOS_TEST_DECL_PTEST().

+ Here is the call graph for this function:

◆ vfs_unmount()

long vfs_unmount ( const char * path)

Unmount a filesystem at a given path.

Parameters
pathThe path to the filesystem
Returns
true
false

Definition at line 451 of file vfs.c.

Referenced by DEFINE_SYSCALL(), and MOS_TEST_DECL_PTEST().

+ Here is the call graph for this function:

◆ vfs_openat()

file_t * vfs_openat ( int fd,
const char * path,
open_flags flags )

Open a file at a given path.

Parameters
fdThe fd of an open directory, or AT_FDCWD to use the current working directory
pathThe path to the file, can be absolute or relative
flagsopen_flags flags
Returns
file_t* The file, or NULL if the file could not be opened

Definition at line 493 of file vfs.c.

Referenced by DEFINE_SYSCALL(), elf_create_process(), elf_map_interpreter(), and process_do_execveat().

+ Here is the call graph for this function:

◆ vfs_fstatat()

long vfs_fstatat ( fd_t fd,
const char * path,
file_stat_t *restrict stat,
fstatat_flags flags )

Stat a file.

Parameters
fdThe directory, or a file if FSTATAT_FILE is set
pathThe path to the file
flagsfstat_flags flags
statThe 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 501 of file vfs.c.

Referenced by DEFINE_SYSCALL().

+ Here is the call graph for this function:

◆ vfs_readlinkat()

size_t vfs_readlinkat ( fd_t dirfd,
const char * path,
char * buf,
size_t size )

Read a symbolic link.

Parameters
dirfdThe file descriptor of the directory containing the symbolic link
pathThe path to the symbolic link
bufThe buffer to store the link in
sizeThe size of the buffer
Returns
size_t The size of the link, or 0 if the link could not be read, or the buffer was too small

Definition at line 534 of file vfs.c.

Referenced by DEFINE_SYSCALL().

+ Here is the call graph for this function:

◆ vfs_symlink()

long vfs_symlink ( const char * path,
const char * target )

Create a symbolic link.

Parameters
pathThe path to the symbolic link
targetThe target of the symbolic link
Returns
true
false

Definition at line 557 of file vfs.c.

Referenced by DEFINE_SYSCALL().

+ Here is the call graph for this function:

◆ vfs_mkdir()

long vfs_mkdir ( const char * path)

Create a directory.

Parameters
pathThe path to the directory
Returns
true
false

Definition at line 575 of file vfs.c.

Referenced by DEFINE_SYSCALL(), mos_start_kernel(), and MOS_TEST_DECL_PTEST().

+ Here is the call graph for this function:

◆ vfs_rmdir()

long vfs_rmdir ( const char * path)

Definition at line 600 of file vfs.c.

Referenced by MOS_TEST_DECL_PTEST().

+ Here is the call graph for this function:

◆ vfs_list_dir()

size_t vfs_list_dir ( io_t * io,
void * buf,
size_t size )

Get the content of a directory.

Parameters
ioThe io object of a file_t, must be a directory and opened with FILE_OPEN_READ
bufThe buffer to store the directory entries in
sizeThe size of the buffer
Returns
size_t The number of bytes read, or 0 if the end of the directory was reached

Definition at line 624 of file vfs.c.

Referenced by DEFINE_SYSCALL().

+ Here is the call graph for this function:

◆ vfs_chdir()

long vfs_chdir ( const char * path)

Change the current working directory.

Parameters
pathThe path to the new working directory
Returns
true
false

Definition at line 675 of file vfs.c.

Referenced by DEFINE_SYSCALL().

+ Here is the call graph for this function:

◆ vfs_getcwd()

ssize_t vfs_getcwd ( char * buf,
size_t size )

Get the current working directory.

Parameters
bufThe buffer to store the path in
sizeThe size of the buffer
Returns
ssize_t The size of the path, or 0 if the buffer was too small

Definition at line 691 of file vfs.c.

Referenced by DEFINE_SYSCALL().

+ Here is the call graph for this function:

◆ vfs_fchmodat()

long vfs_fchmodat ( fd_t fd,
const char * path,
int perm,
int flags )

Change the permissions of a file.

Parameters
fdThe directory, or a file if FSTATAT_FILE is set
pathThe path to the file
permThe new permissions
flagsfstat_flags flags
Returns
long 0 on success, or errno on failure

Definition at line 700 of file vfs.c.

Referenced by DEFINE_SYSCALL().

+ Here is the call graph for this function:

Variable Documentation

◆ root_dentry

dentry_t* root_dentry
extern

Definition at line 33 of file vfs.c.