PatchworkOS  dbbdc99
A non-POSIX operating system.
Loading...
Searching...
No Matches
tmpfs.c File Reference
#include <kernel/fs/tmpfs.h>
#include <kernel/fs/dentry.h>
#include <kernel/fs/devfs.h>
#include <kernel/fs/file.h>
#include <kernel/fs/filesystem.h>
#include <kernel/fs/mount.h>
#include <kernel/fs/namespace.h>
#include <kernel/fs/path.h>
#include <kernel/fs/vfs.h>
#include <kernel/fs/vnode.h>
#include <kernel/init/boot_info.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/sched/sched.h>
#include <kernel/sync/lock.h>
#include <kernel/sync/mutex.h>
#include <kernel/utils/ref.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/fs.h>
#include <sys/list.h>
#include <sys/math.h>
Include dependency graph for tmpfs.c:

Go to the source code of this file.

Functions

static vnode_ttmpfs_vnode_new (superblock_t *superblock, vtype_t type, void *buffer, uint64_t size)
 
static void tmpfs_dentry_add (dentry_t *dentry)
 
static void tmpfs_dentry_remove (dentry_t *dentry)
 
static size_t tmpfs_read (file_t *file, void *buffer, size_t count, size_t *offset)
 
static size_t tmpfs_write (file_t *file, const void *buffer, size_t count, size_t *offset)
 
static uint64_t tmpfs_create (vnode_t *dir, dentry_t *target, mode_t mode)
 
static void tmpfs_truncate (vnode_t *vnode)
 
static uint64_t tmpfs_link (vnode_t *dir, dentry_t *old, dentry_t *target)
 
static uint64_t tmpfs_readlink (vnode_t *vnode, char *buffer, uint64_t count)
 
static uint64_t tmpfs_symlink (vnode_t *dir, dentry_t *target, const char *dest)
 
static uint64_t tmpfs_remove (vnode_t *dir, dentry_t *target)
 
static void tmpfs_vnode_cleanup (vnode_t *vnode)
 
static void tmpfs_superblock_cleanup (superblock_t *superblock)
 
static dentry_ttmpfs_load_file (superblock_t *superblock, dentry_t *parent, const char *name, const boot_file_t *in)
 
static dentry_ttmpfs_load_dir (superblock_t *superblock, dentry_t *parent, const char *name, const boot_dir_t *in)
 
static dentry_ttmpfs_mount (filesystem_t *fs, const char *options, void *data)
 
void tmpfs_init (void)
 Registers the tmpfs filesystem and mounts an instance of it containing the boot ram disk as root.
 

Variables

static bool initialized = false
 
static file_ops_t fileOps
 
static vnode_ops_t vnodeOps
 
static dentry_ops_t dentryOps
 
static superblock_ops_t superOps
 
static filesystem_t tmpfs
 

Function Documentation

◆ tmpfs_vnode_new()

static vnode_t * tmpfs_vnode_new ( superblock_t superblock,
vtype_t  type,
void *  buffer,
uint64_t  size 
)
static

Definition at line 344 of file tmpfs.c.

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

◆ tmpfs_dentry_add()

static void tmpfs_dentry_add ( dentry_t dentry)
static

Definition at line 32 of file tmpfs.c.

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

◆ tmpfs_dentry_remove()

static void tmpfs_dentry_remove ( dentry_t dentry)
static

Definition at line 42 of file tmpfs.c.

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

◆ tmpfs_read()

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

Definition at line 54 of file tmpfs.c.

◆ tmpfs_write()

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

Definition at line 66 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_create()

static uint64_t tmpfs_create ( vnode_t dir,
dentry_t target,
mode_t  mode 
)
static

Definition at line 92 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_truncate()

static void tmpfs_truncate ( vnode_t vnode)
static

Definition at line 109 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_link()

static uint64_t tmpfs_link ( vnode_t dir,
dentry_t old,
dentry_t target 
)
static

Definition at line 121 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_readlink()

static uint64_t tmpfs_readlink ( vnode_t vnode,
char *  buffer,
uint64_t  count 
)
static

Definition at line 131 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_symlink()

static uint64_t tmpfs_symlink ( vnode_t dir,
dentry_t target,
const char *  dest 
)
static

Definition at line 146 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_remove()

static uint64_t tmpfs_remove ( vnode_t dir,
dentry_t target 
)
static

Definition at line 163 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_vnode_cleanup()

static void tmpfs_vnode_cleanup ( vnode_t vnode)
static

Definition at line 185 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_superblock_cleanup()

static void tmpfs_superblock_cleanup ( superblock_t superblock)
static

Definition at line 209 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_load_file()

static dentry_t * tmpfs_load_file ( superblock_t superblock,
dentry_t parent,
const char *  name,
const boot_file_t in 
)
static

Definition at line 220 of file tmpfs.c.

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

◆ tmpfs_load_dir()

static dentry_t * tmpfs_load_dir ( superblock_t superblock,
dentry_t parent,
const char *  name,
const boot_dir_t in 
)
static

Definition at line 243 of file tmpfs.c.

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

◆ tmpfs_mount()

static dentry_t * tmpfs_mount ( filesystem_t fs,
const char *  options,
void *  data 
)
static

Definition at line 279 of file tmpfs.c.

Here is the call graph for this function:

Variable Documentation

◆ initialized

bool initialized = false
static

Definition at line 28 of file tmpfs.c.

◆ fileOps

file_ops_t fileOps
static
Initial value:
= {
.read = tmpfs_read,
.write = tmpfs_write,
}
size_t file_generic_seek(file_t *file, ssize_t offset, seek_origin_t origin)
Helper function for basic seeking.
Definition file.c:76
static size_t tmpfs_read(file_t *file, void *buffer, size_t count, size_t *offset)
Definition tmpfs.c:54
static size_t tmpfs_write(file_t *file, const void *buffer, size_t count, size_t *offset)
Definition tmpfs.c:66

Definition at line 86 of file tmpfs.c.

◆ vnodeOps

vnode_ops_t vnodeOps
static
Initial value:
= {
.create = tmpfs_create,
.truncate = tmpfs_truncate,
.link = tmpfs_link,
.readlink = tmpfs_readlink,
.symlink = tmpfs_symlink,
.remove = tmpfs_remove,
.cleanup = tmpfs_vnode_cleanup,
}
static uint64_t tmpfs_symlink(vnode_t *dir, dentry_t *target, const char *dest)
Definition tmpfs.c:146
static uint64_t tmpfs_link(vnode_t *dir, dentry_t *old, dentry_t *target)
Definition tmpfs.c:121
static void tmpfs_vnode_cleanup(vnode_t *vnode)
Definition tmpfs.c:185
static uint64_t tmpfs_remove(vnode_t *dir, dentry_t *target)
Definition tmpfs.c:163
static uint64_t tmpfs_create(vnode_t *dir, dentry_t *target, mode_t mode)
Definition tmpfs.c:92
static uint64_t tmpfs_readlink(vnode_t *vnode, char *buffer, uint64_t count)
Definition tmpfs.c:131
static void tmpfs_truncate(vnode_t *vnode)
Definition tmpfs.c:109

Definition at line 195 of file tmpfs.c.

◆ dentryOps

dentry_ops_t dentryOps
static
Initial value:
= {
}
uint64_t dentry_generic_iterate(dentry_t *dentry, dir_ctx_t *ctx)
Helper function for a basic iterate.
Definition dentry.c:325

Definition at line 205 of file tmpfs.c.

◆ superOps

superblock_ops_t superOps
static
Initial value:
= {
}
static void tmpfs_superblock_cleanup(superblock_t *superblock)
Definition tmpfs.c:209

Definition at line 216 of file tmpfs.c.

◆ tmpfs

filesystem_t tmpfs
static
Initial value:
= {
.name = TMPFS_NAME,
.mount = tmpfs_mount,
}
#define TMPFS_NAME
The name of the tmpfs filesystem.
Definition tmpfs.h:25
static dentry_t * tmpfs_mount(filesystem_t *fs, const char *options, void *data)
Definition tmpfs.c:279

Definition at line 372 of file tmpfs.c.