PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
filesystem.c File Reference
#include <kernel/fs/filesystem.h>
#include <kernel/cpu/syscall.h>
#include <kernel/fs/cwd.h>
#include <kernel/fs/dentry.h>
#include <kernel/fs/file_table.h>
#include <kernel/fs/key.h>
#include <kernel/fs/mount.h>
#include <kernel/fs/path.h>
#include <kernel/fs/sysfs.h>
#include <kernel/fs/vfs.h>
#include <kernel/fs/vnode.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/mem/vmm.h>
#include <kernel/proc/process.h>
#include <kernel/sched/clock.h>
#include <kernel/sched/sched.h>
#include <kernel/sched/timer.h>
#include <kernel/sched/wait.h>
#include <kernel/sync/mutex.h>
#include <kernel/sync/rwlock.h>
#include <kernel/utils/ref.h>
#include <kernel/cpu/regs.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/fs.h>
#include <sys/list.h>
Include dependency graph for filesystem.c:

Go to the source code of this file.

Functions

static map_key_t filesystem_key (const char *name)
 
static size_t superblock_read (file_t *file, void *buffer, size_t count, size_t *offset)
 
static void superblock_cleanup (vnode_t *vnode)
 
static uint64_t filesystem_lookup (vnode_t *dir, dentry_t *dentry)
 
static uint64_t filesystem_iterate (dentry_t *dentry, dir_ctx_t *ctx)
 
static uint64_t filesystem_dir_lookup (vnode_t *dir, dentry_t *dentry)
 
static uint64_t filesystem_dir_iterate (dentry_t *dentry, dir_ctx_t *ctx)
 
void filesystem_expose (void)
 Exposes the sysfs fs directory.
 
uint64_t filesystem_register (filesystem_t *fs)
 Registers a filesystem.
 
void filesystem_unregister (filesystem_t *fs)
 Unregisters a filesystem.
 
filesystem_tfilesystem_get_by_name (const char *name)
 Gets a filesystem by name.
 
filesystem_tfilesystem_get_by_path (const char *path, process_t *process)
 Gets a filesystem by path.
 
bool options_next (const char **iter, char *buffer, size_t size, char **key, char **value)
 Helper function for iterating over options passed to a filesystem mount operation.
 

Variables

static dentry_tdir = NULL
 
static map_t fsMap = MAP_CREATE()
 
static list_t filesystems = LIST_CREATE(filesystems)
 
static rwlock_t lock = RWLOCK_CREATE()
 
static file_ops_t sbFileOps
 
static vnode_ops_t sbVnodeOps
 
static vnode_ops_t fsVnodeOps
 
static dentry_ops_t fsDentryOps
 
static vnode_ops_t dirVnodeOps
 
static dentry_ops_t dirDentryOps
 

Function Documentation

◆ filesystem_key()

static map_key_t filesystem_key ( const char *  name)
static

Definition at line 40 of file filesystem.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ superblock_read()

static size_t superblock_read ( file_t file,
void *  buffer,
size_t  count,
size_t offset 
)
static

Definition at line 45 of file filesystem.c.

Here is the call graph for this function:

◆ superblock_cleanup()

static void superblock_cleanup ( vnode_t vnode)
static

Definition at line 61 of file filesystem.c.

◆ filesystem_lookup()

static uint64_t filesystem_lookup ( vnode_t dir,
dentry_t dentry 
)
static

Definition at line 81 of file filesystem.c.

Here is the call graph for this function:

◆ filesystem_iterate()

static uint64_t filesystem_iterate ( dentry_t dentry,
dir_ctx_t ctx 
)
static

Definition at line 115 of file filesystem.c.

Here is the call graph for this function:

◆ filesystem_dir_lookup()

static uint64_t filesystem_dir_lookup ( vnode_t dir,
dentry_t dentry 
)
static

Definition at line 155 of file filesystem.c.

Here is the call graph for this function:

◆ filesystem_dir_iterate()

static uint64_t filesystem_dir_iterate ( dentry_t dentry,
dir_ctx_t ctx 
)
static

Definition at line 181 of file filesystem.c.

Here is the call graph for this function:

Variable Documentation

◆ dir

dentry_t* dir = NULL
static

Definition at line 34 of file filesystem.c.

◆ fsMap

map_t fsMap = MAP_CREATE()
static

Definition at line 36 of file filesystem.c.

◆ filesystems

list_t filesystems = LIST_CREATE(filesystems)
static

Definition at line 37 of file filesystem.c.

◆ lock

rwlock_t lock = RWLOCK_CREATE()
static

Definition at line 38 of file filesystem.c.

◆ sbFileOps

file_ops_t sbFileOps
static
Initial value:
= {
.read = superblock_read,
}
static size_t superblock_read(file_t *file, void *buffer, size_t count, size_t *offset)
Definition filesystem.c:45

Definition at line 73 of file filesystem.c.

◆ sbVnodeOps

vnode_ops_t sbVnodeOps
static
Initial value:
= {
.cleanup = superblock_cleanup,
}
static void superblock_cleanup(vnode_t *vnode)
Definition filesystem.c:61

Definition at line 77 of file filesystem.c.

◆ fsVnodeOps

vnode_ops_t fsVnodeOps
static
Initial value:
= {
.lookup = filesystem_lookup,
}
static uint64_t filesystem_lookup(vnode_t *dir, dentry_t *dentry)
Definition filesystem.c:81

Definition at line 147 of file filesystem.c.

◆ fsDentryOps

dentry_ops_t fsDentryOps
static
Initial value:
= {
.iterate = filesystem_iterate,
}
static uint64_t filesystem_iterate(dentry_t *dentry, dir_ctx_t *ctx)
Definition filesystem.c:115

Definition at line 151 of file filesystem.c.

◆ dirVnodeOps

vnode_ops_t dirVnodeOps
static
Initial value:
= {
}
static uint64_t filesystem_dir_lookup(vnode_t *dir, dentry_t *dentry)
Definition filesystem.c:155

Definition at line 207 of file filesystem.c.

◆ dirDentryOps

dentry_ops_t dirDentryOps
static
Initial value:
= {
}
static uint64_t filesystem_dir_iterate(dentry_t *dentry, dir_ctx_t *ctx)
Definition filesystem.c:181

Definition at line 211 of file filesystem.c.