PatchworkOS  dbbdc99
A non-POSIX operating system.
Loading...
Searching...
No Matches
namespace.c File Reference
#include <kernel/fs/namespace.h>
#include <kernel/cpu/syscall.h>
#include <kernel/fs/dentry.h>
#include <kernel/fs/filesystem.h>
#include <kernel/fs/mount.h>
#include <kernel/fs/path.h>
#include <kernel/fs/superblock.h>
#include <kernel/fs/vfs.h>
#include <kernel/log/log.h>
#include <kernel/proc/process.h>
#include <kernel/sched/thread.h>
#include <kernel/sync/lock.h>
#include <kernel/sync/rwlock.h>
#include <kernel/utils/map.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/fs.h>
#include <sys/list.h>
Include dependency graph for namespace.c:

Go to the source code of this file.

Functions

static map_key_t mount_key (mount_id_t parentId, dentry_id_t mountpointId)
 
static map_key_t root_key (void)
 
static map_key_t mount_key_from_mount (mount_t *mount)
 
static uint64_t mount_stack_push (mount_stack_t *stack, mount_t *mount)
 
static void mount_stack_remove (mount_stack_t *stack, mount_t *mount)
 
static uint64_t mount_stack_init (namespace_t *ns, mount_stack_t *stack, map_key_t *key)
 
static void mount_stack_free (namespace_t *ns, mount_stack_t *stack)
 
static mount_stack_tnamespace_get_stack (namespace_t *ns, const map_key_t *key)
 
static uint64_t namespace_add (namespace_t *ns, mount_t *mount)
 
static void namespace_remove (namespace_t *ns, mount_t *mount, mode_t mode)
 
static void namespace_free (namespace_t *ns)
 
namespace_tnamespace_new (namespace_t *parent)
 Create a new namespace.
 
uint64_t namespace_copy (namespace_t *dest, namespace_t *src)
 Copy mounts from one namespace to another.
 
static bool namespace_is_descendant (namespace_t *ancestor, namespace_t *descendant)
 
bool namespace_accessible (namespace_t *ns, namespace_t *other)
 Check if mounts in a namespace can be propagated to another namespace.
 
bool namespace_rcu_traverse (namespace_t *ns, mount_t **mount, dentry_t **dentry)
 If the given path is a mountpoint in the namespace, traverse to the mounted filesystem in an RCU read critical section, else no-op.
 
mount_tnamespace_mount (namespace_t *ns, path_t *target, filesystem_t *fs, const char *options, mode_t mode, void *data)
 Mount a filesystem in a namespace.
 
mount_tnamespace_bind (namespace_t *ns, path_t *target, path_t *source, mode_t mode)
 Bind a source path to a target path in a namespace.
 
void namespace_unmount (namespace_t *ns, mount_t *mount, mode_t mode)
 Remove a mount in a namespace.
 
void namespace_get_root (namespace_t *ns, path_t *out)
 Get the root path of a namespace.
 
void namespace_rcu_get_root (namespace_t *ns, mount_t **mount, dentry_t **dentry)
 Get the root mount of a namespace in an RCU read critical section.
 
 SYSCALL_DEFINE (SYS_MOUNT, uint64_t, const char *mountpoint, const char *fs, const char *options)
 
 SYSCALL_DEFINE (SYS_UNMOUNT, uint64_t, const char *mountpoint)
 
 SYSCALL_DEFINE (SYS_BIND, uint64_t, const char *mountpoint, fd_t source)
 

Function Documentation

◆ mount_key()

static map_key_t mount_key ( mount_id_t  parentId,
dentry_id_t  mountpointId 
)
static

Definition at line 22 of file namespace.c.

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

◆ root_key()

static map_key_t root_key ( void  )
static

Definition at line 35 of file namespace.c.

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

◆ mount_key_from_mount()

static map_key_t mount_key_from_mount ( mount_t mount)
static

Definition at line 46 of file namespace.c.

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

◆ mount_stack_push()

static uint64_t mount_stack_push ( mount_stack_t stack,
mount_t mount 
)
static

Definition at line 56 of file namespace.c.

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

◆ mount_stack_remove()

static void mount_stack_remove ( mount_stack_t stack,
mount_t mount 
)
static

Definition at line 70 of file namespace.c.

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

◆ mount_stack_init()

static uint64_t mount_stack_init ( namespace_t ns,
mount_stack_t stack,
map_key_t key 
)
static

Definition at line 88 of file namespace.c.

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

◆ mount_stack_free()

static void mount_stack_free ( namespace_t ns,
mount_stack_t stack 
)
static

Definition at line 102 of file namespace.c.

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

◆ namespace_get_stack()

static mount_stack_t * namespace_get_stack ( namespace_t ns,
const map_key_t key 
)
static

Definition at line 127 of file namespace.c.

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

◆ namespace_add()

static uint64_t namespace_add ( namespace_t ns,
mount_t mount 
)
static

Definition at line 132 of file namespace.c.

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

◆ namespace_remove()

static void namespace_remove ( namespace_t ns,
mount_t mount,
mode_t  mode 
)
static

Definition at line 184 of file namespace.c.

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

◆ namespace_free()

static void namespace_free ( namespace_t ns)
static

Definition at line 222 of file namespace.c.

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

◆ namespace_is_descendant()

static bool namespace_is_descendant ( namespace_t ancestor,
namespace_t descendant 
)
static

Definition at line 318 of file namespace.c.

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

◆ SYSCALL_DEFINE() [1/3]

SYSCALL_DEFINE ( SYS_MOUNT  ,
uint64_t  ,
const char *  mountpoint,
const char *  fs,
const char *  options 
)

Definition at line 519 of file namespace.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [2/3]

SYSCALL_DEFINE ( SYS_UNMOUNT  ,
uint64_t  ,
const char *  mountpoint 
)

Definition at line 573 of file namespace.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [3/3]

SYSCALL_DEFINE ( SYS_BIND  ,
uint64_t  ,
const char *  mountpoint,
fd_t  source 
)

Definition at line 603 of file namespace.c.

Here is the call graph for this function: