miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
tmpfs.h File Reference
#include <miniOS/fs/vfs.h>
Include dependency graph for tmpfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void tmpfs_init (void)
vfs_ops_ttmpfs_get_ops (void)
uint32_t tmpfs_alloc_root (void)
: Filename (not full path; no '/' allowed).

tmpfs_create() - Create a new regular file in a tmpfs directory. @parent_ino: Inode number of the parent directory (must be a directory).

@new_ino_out: Set to the new inode number on success.

Allocates a new inode with EXT2_S_IFREG | (mode & 0777); 0 mode defaults to 0644. Appends an ext2_dirent_t entry to the parent directory's data block.

Returns
: 0 on success, -1 if parent not found, not a directory, name too long, or inode table full.
int tmpfs_create (uint32_t parent_ino, const char *name, uint16_t mode, uint32_t *new_ino_out)
int tmpfs_create_device (uint32_t parent_ino, const char *name, uint8_t device_type, uint32_t *new_ino_out)
: Filename (no '/' allowed).

tmpfs_mknod() - Create a device special file (char or block device node). @parent_ino: Inode number of the parent directory.

@mode: EXT2_S_IFCHR|perms or EXT2_S_IFBLK|perms. @dev: Device number (major<<8)|minor; stored in i_rdev. @new_ino_out: Set to the new inode number on success.

Maps well-known (major,minor) pairs to VFS_DEVICE_* constants so that open/read/write dispatch works for TTY (5,0) and null (1,3) devices.

Returns
: 0 on success, -1 on error, -22 if mode type is not IFCHR/IFBLK.
int tmpfs_mknod (uint32_t parent_ino, const char *name, uint16_t mode, uint32_t dev, uint32_t *new_ino_out)
: Directory name (no '/' allowed).

tmpfs_mkdir() - Create a new directory in a tmpfs directory. @parent_ino: Inode number of the parent directory.

@new_ino_out: Set to the new inode number on success.

Allocates a new inode (EXT2_S_IFDIR | 0755), adds "." and ".." entries, links the new directory into parent.

Returns
: 0 on success, -1 on error.
int tmpfs_mkdir (uint32_t parent_ino, const char *name, uint32_t *new_ino_out)
: Name of the file to remove (regular file only).

tmpfs_unlink() - Remove a file from its parent directory and free its inode. @parent_ino: Inode number of the parent directory.

Removes the directory entry from the parent. Frees all data blocks and clears the inode slot. Immediate deletion (no open-file keep-alive).

Returns
: 0 on success, -1 if not found or is a directory.
int tmpfs_unlink (uint32_t parent_ino, const char *name)
: Name of the subdirectory to remove.

tmpfs_rmdir() - Remove an empty directory. @parent_ino: Inode number of the parent directory.

Only succeeds if the directory contains only "." and ".." entries.

Returns
: 0 on success, -1 if not found, not empty, or not a directory.
int tmpfs_rmdir (uint32_t parent_ino, const char *name)

Function Documentation

◆ tmpfs_alloc_root()

uint32_t tmpfs_alloc_root ( void )

tmpfs_alloc_root() - Allocate a fresh root directory inode for a new mount.

Each call to mount tmpfs <target> should call this to get an isolated root directory. The returned inode number is stored in vfs_mount_t.root_ino and activated via set_root() before each path lookup on that mount.

Returns
: New inode number, or 0 on failure (inode table full).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tmpfs_create()

int tmpfs_create ( uint32_t parent_ino,
const char * name,
uint16_t mode,
uint32_t * new_ino_out )
Here is the call graph for this function:

◆ tmpfs_create_device()

int tmpfs_create_device ( uint32_t parent_ino,
const char * name,
uint8_t device_type,
uint32_t * new_ino_out )
Here is the call graph for this function:

◆ tmpfs_get_ops()

vfs_ops_t * tmpfs_get_ops ( void )

tmpfs_get_ops() - Return a pointer to the static tmpfs vfs_ops_t table.

The returned pointer is valid for the lifetime of the kernel.

Returns
: Pointer to static vfs_ops_t with lookup, read, readdir, write, flush set.

◆ tmpfs_init()

void tmpfs_init ( void )

tmpfs_init() - Initialise the tmpfs inode pool and register the "tmpfs" type.

Initialises the shared inode table (inode 1 = internal sentinel root) and calls register_filesystem("tmpfs", ...) so that vfs_mount_fstype("tmpfs", ...) works. Safe to call multiple times — subsequent calls are no-ops. Must be called before any vfs_mount_fstype("tmpfs", ...) invocation.

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

◆ tmpfs_mkdir()

int tmpfs_mkdir ( uint32_t parent_ino,
const char * name,
uint32_t * new_ino_out )
Here is the call graph for this function:

◆ tmpfs_mknod()

int tmpfs_mknod ( uint32_t parent_ino,
const char * name,
uint16_t mode,
uint32_t dev,
uint32_t * new_ino_out )
Here is the call graph for this function:

◆ tmpfs_rmdir()

int tmpfs_rmdir ( uint32_t parent_ino,
const char * name )
Here is the call graph for this function:

◆ tmpfs_unlink()

int tmpfs_unlink ( uint32_t parent_ino,
const char * name )
Here is the call graph for this function: