PatchworkOS  10941b4
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/inode.h>
#include <kernel/fs/mount.h>
#include <kernel/fs/namespace.h>
#include <kernel/fs/path.h>
#include <kernel/fs/vfs.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/io.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 inode_ttmpfs_inode_new (superblock_t *superblock, itype_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 (inode_t *dir, dentry_t *target, mode_t mode)
 
static void tmpfs_truncate (inode_t *inode)
 
static uint64_t tmpfs_link (inode_t *dir, dentry_t *old, dentry_t *target)
 
static uint64_t tmpfs_readlink (inode_t *inode, char *buffer, uint64_t count)
 
static uint64_t tmpfs_symlink (inode_t *dir, dentry_t *target, const char *dest)
 
static uint64_t tmpfs_remove (inode_t *dir, dentry_t *target)
 
static void tmpfs_inode_cleanup (inode_t *inode)
 
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, block_device_t *device, void *private)
 
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 inode_ops_t inodeOps
 
static dentry_ops_t dentryOps
 
static superblock_ops_t superOps
 
static filesystem_t tmpfs
 

Function Documentation

◆ tmpfs_inode_new()

static inode_t * tmpfs_inode_new ( superblock_t superblock,
itype_t  type,
void buffer,
uint64_t  size 
)
static

Definition at line 338 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 ( inode_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 ( inode_t inode)
static

Definition at line 109 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_link()

static uint64_t tmpfs_link ( inode_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 ( inode_t inode,
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 ( inode_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 ( inode_t dir,
dentry_t target 
)
static

Definition at line 163 of file tmpfs.c.

Here is the call graph for this function:

◆ tmpfs_inode_cleanup()

static void tmpfs_inode_cleanup ( inode_t inode)
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,
block_device_t device,
void private 
)
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:69
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.

◆ inodeOps

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

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:313

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, block_device_t *device, void *private)
Definition tmpfs.c:279

Definition at line 368 of file tmpfs.c.