|
PatchworkOS
321f6ec
A non-POSIX operating system.
|
Per-process Namespaces. More...
Per-process Namespaces.
The per-process namespace system allows each process to have its own view of the filesystem hierarchy, by having each process store its own set of mountpoints instead of having a global set of mountpoints.
When a new mount or bind is created in a namespace, it is only added to that specific namespace. However, its possible to propagate mounts to children and/or parent namespaces using mount flags (mount_flags_t), this allows those namespaces to also see the new mount or bind.
Data Structures | |
| struct | namespace_mount_t |
| struct | namespace_t |
| struct | namespace_mount |
| A mount in a namespace. More... | |
| struct | namespace_t |
| Namespace structure. More... | |
Functions | |
| void | namespace_init (namespace_t *ns) |
| Initializes a namespace. | |
| void | namespace_deinit (namespace_t *ns) |
| Clear and deinitialize a namespace. | |
| uint64_t | namespace_set_parent (namespace_t *ns, namespace_t *parent) |
| Sets the parent of a namespace and inherits all mounts from the parent. | |
| uint64_t | namespace_traverse (namespace_t *ns, path_t *path) |
| If the given path is a mountpoint in the namespace, traverse to the mounted filesystem, else no-op. | |
| mount_t * | namespace_mount (namespace_t *ns, path_t *target, const char *deviceName, const char *fsName, mount_flags_t flags, mode_t mode, void *private) |
| Mount a filesystem in a namespace. | |
| mount_t * | namespace_bind (namespace_t *ns, dentry_t *source, path_t *target, mount_flags_t flags, mode_t mode) |
| Bind a source dentry to a target path in a namespace. | |
| uint64_t | namespace_get_root_path (namespace_t *ns, path_t *out) |
| Get the root path of a namespace. | |
| void | namespace_clear (namespace_t *ns) |
| Clears all mounts from a namespace. | |
| void namespace_init | ( | namespace_t * | ns | ) |
Initializes a namespace.
| ns | The namespace to initialize. |
| parent | The parent namespace to inherit all mounts from, can be NULL to create an empty namespace. |
Definition at line 100 of file namespace.c.
| void namespace_deinit | ( | namespace_t * | ns | ) |
Clear and deinitialize a namespace.
| ns | The namespace to deinitialize. |
Definition at line 111 of file namespace.c.
| uint64_t namespace_set_parent | ( | namespace_t * | ns, |
| namespace_t * | parent | ||
| ) |
Sets the parent of a namespace and inherits all mounts from the parent.
| ns | The namespace to set the parent of. |
| parent | The new parent namespace. |
0. On failure, ERR and errno is set to:EINVAL: Invalid parameters.EBUSY: The namespace already has a parent.ENOMEM: Out of memory. Definition at line 123 of file namespace.c.
| uint64_t namespace_traverse | ( | namespace_t * | ns, |
| path_t * | path | ||
| ) |
If the given path is a mountpoint in the namespace, traverse to the mounted filesystem, else no-op.
| ns | The namespace to traverse in. |
| path | The mountpoint path to traverse, will be updated to the new path if traversed. |
0. On failure, ERR and errno is set to:EINVAL: Invalid parameters. Definition at line 163 of file namespace.c.
| mount_t * namespace_mount | ( | namespace_t * | ns, |
| path_t * | target, | ||
| const char * | deviceName, | ||
| const char * | fsName, | ||
| mount_flags_t | flags, | ||
| mode_t | mode, | ||
| void * | private | ||
| ) |
Mount a filesystem in a namespace.
| ns | The namespace to mount in. |
| deviceName | The device name, or VFS_DEVICE_NAME_NONE for no device. |
| target | The target path to mount to. |
| fsName | The filesystem name. |
| flags | Mount flags. |
| mode | The maximum allowed permissions for files/directories opened under this mount. |
| private | Private data for the filesystem's mount function. |
NULL and errno is set to:EINVAL: Invalid parameters.EXDEV: The target path is not visible in the namespace.ENODEV: The specified filesystem does not exist.EBUSY: Attempt to mount to already existing root.ENOMEM: Out of memory.ENOENT: The root does not exist or the target is negative.mount() function or mount_new(). Definition at line 191 of file namespace.c.
| mount_t * namespace_bind | ( | namespace_t * | ns, |
| dentry_t * | source, | ||
| path_t * | target, | ||
| mount_flags_t | flags, | ||
| mode_t | mode | ||
| ) |
Bind a source dentry to a target path in a namespace.
| ns | The namespace to mount in. |
| source | The source dentry to bind from, could be either a file or directory and from any filesystem. |
| target | The target path to bind to. |
| flags | Mount flags. |
| mode | The maximum allowed permissions for files/directories opened under this mount. |
NULL and errno is set to:EINVAL: Invalid parameters.ENOMEM: Out of memory.mount_new(). Definition at line 259 of file namespace.c.
| uint64_t namespace_get_root_path | ( | namespace_t * | ns, |
| path_t * | out | ||
| ) |
Get the root path of a namespace.
| ns | The namespace, can be NULL to get the kernel process's namespace root. |
| out | The output root path. |
0. On failure, ERR and errno is set to:EINVAL: Invalid parameters.ENOENT: The namespace has no root mount. Definition at line 286 of file namespace.c.
| void namespace_clear | ( | namespace_t * | ns | ) |
Clears all mounts from a namespace.
| ns | The namespace to clear. |
Definition at line 306 of file namespace.c.