MOS Source Code
Loading...
Searching...
No Matches
vfs.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2// Virtual File System Public API
3
4#pragma once
5
9#include <mos/types.h>
10
19{
20 if (!file)
21 goto error;
22
23 if (!file->dentry)
24 goto error;
25
26 if (!file->dentry->inode)
27 goto error;
28
29 if (!file->dentry->inode->file_ops)
30 goto error;
31
32 return file->dentry->inode->file_ops;
33
34error:
35 pr_warn("no file_ops for file %p", (void *) file);
36 return NULL;
37}
38
39extern dentry_t *root_dentry;
40
52file_t *vfs_do_open_dentry(dentry_t *entry, bool created, bool read, bool write, bool exec, bool truncate);
53
55
66long vfs_mount(const char *device, const char *path, const char *fs, const char *options);
67
75long vfs_unmount(const char *path);
76
85file_t *vfs_openat(int fd, const char *path, open_flags flags);
86
102long vfs_fstatat(fd_t fd, const char *path, file_stat_t *restrict stat, fstatat_flags flags);
103
113size_t vfs_readlinkat(fd_t dirfd, const char *path, char *buf, size_t size);
114
123long vfs_symlink(const char *path, const char *target);
124
132long vfs_mkdir(const char *path);
133long vfs_rmdir(const char *path);
134
144size_t vfs_list_dir(io_t *io, void *buf, size_t size);
145
153long vfs_chdirat(fd_t dirfd, const char *path);
154
162ssize_t vfs_getcwd(char *buf, size_t size);
163
173long vfs_fchmodat(fd_t fd, const char *path, int perm, int flags);
174
182long vfs_unlinkat(fd_t dirfd, const char *path);
183
193long vfs_fsync(io_t *io, bool sync_metadata, off_t start, off_t end);
194
fstatat_flags
Definition fs_types.h:40
open_flags
Definition fs_types.h:26
dentry_t * root_dentry
Definition vfs.c:36
long vfs_chdirat(fd_t dirfd, const char *path)
Change the current working directory.
Definition vfs.c:764
size_t vfs_list_dir(io_t *io, void *buf, size_t size)
Get the content of a directory.
Definition vfs.c:713
long vfs_symlink(const char *path, const char *target)
Create a symbolic link.
Definition vfs.c:646
long vfs_unmount(const char *path)
Unmount a filesystem at a given path.
Definition vfs.c:536
long vfs_rmdir(const char *path)
Definition vfs.c:689
should_inline const file_ops_t * file_get_ops(file_t *file)
Definition vfs.h:18
file_t * vfs_openat(int fd, const char *path, open_flags flags)
Open a file at a given path.
Definition vfs.c:578
ssize_t vfs_getcwd(char *buf, size_t size)
Get the current working directory.
Definition vfs.c:780
long vfs_unlinkat(fd_t dirfd, const char *path)
Remove the name of a file, and possibly the file itself.
Definition vfs.c:803
long vfs_fstatat(fd_t fd, const char *path, file_stat_t *restrict stat, fstatat_flags flags)
Stat a file.
Definition vfs.c:588
long vfs_mount(const char *device, const char *path, const char *fs, const char *options)
Mount a filesystem at a given existing path.
Definition vfs.c:466
void vfs_register_filesystem(filesystem_t *fs)
Definition vfs.c:452
long vfs_fsync(io_t *io, bool sync_metadata, off_t start, off_t end)
Synchronize a file with the filesystem.
Definition vfs.c:830
long vfs_mkdir(const char *path)
Create a directory.
Definition vfs.c:664
long vfs_fchmodat(fd_t fd, const char *path, int perm, int flags)
Change the permissions of a file.
Definition vfs.c:789
file_t * vfs_do_open_dentry(dentry_t *entry, bool created, bool read, bool write, bool exec, bool truncate)
Open an directory dentry.
Definition vfs.c:413
size_t vfs_readlinkat(fd_t dirfd, const char *path, char *buf, size_t size)
Read a symbolic link.
Definition vfs.c:623
static vmap_global_mstat_t stat[_MEM_MAX_TYPES]
Definition mmstat.c:23
#define should_inline
Definition mos_global.h:37
#define NULL
Definition pb_syshdr.h:46
#define pr_warn(fmt,...)
Definition printk.h:38
size_t size
Definition slab.c:30
inode_t * inode
Definition vfs_types.h:117
dentry_t * dentry
Definition vfs_types.h:200
const file_ops_t * file_ops
Definition vfs_types.h:173
Definition io.h:46
ssize_t off_t
Definition types.h:84
s32 fd_t
Definition types.h:81
signed long ssize_t
Definition types.h:83