PatchworkOS
c9fea19
A non-POSIX operating system.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
mount.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <
kernel/fs/path.h
>
4
#include <
kernel/utils/map.h
>
5
#include <
kernel/utils/ref.h
>
6
#include <
sys/list.h
>
7
8
#include <
stdatomic.h
>
9
#include <
stdint.h
>
10
11
typedef
struct
mount
mount_t
;
12
typedef
struct
superblock
superblock_t
;
13
typedef
struct
dentry
dentry_t
;
14
typedef
struct
path
path_t
;
15
16
/**
17
* @brief Mount point.
18
* @defgroup kernel_fs_mount Mount
19
* @ingroup kernel_fs
20
*
21
* A mount represents a location that a superblock is mounted to. It links a superblock (the mounted filesystem) to a
22
* mountpoint (a dentry in another filesystem).
23
*
24
* @{
25
*/
26
27
/**
28
* @brief Mount ID type.
29
*/
30
typedef
uint64_t
mount_id_t
;
31
32
/**
33
* @brief Macro to check if a mount is the root filesystem.
34
*/
35
#define MOUNT_IS_ROOT(mount) ((mount)->parent == (mount))
36
37
/**
38
* @brief Mount structure.
39
* @struct mount_t
40
*
41
* Mounts are owned by the VFS, not the filesystem.
42
*/
43
typedef
struct
mount
44
{
45
ref_t
ref
;
46
mount_id_t
id
;
47
dentry_t
*
48
source
;
///< The dentry to appear at target once mounted, usually the root dentry of the mounted filesystem.
49
dentry_t
*
target
;
///< The dentry which the source is mounted to, can be `NULL` for the root filesystem.
50
superblock_t
*
superblock
;
///< The superblock of the mounted filesystem.
51
mount_t
*
parent
;
///< The parent mount, can be `NULL` for the root filesystem.
52
mode_t
mode
;
///< Specifies the maximum permissions for this mount and if it is a directory or a file.
53
}
mount_t
;
54
55
/**
56
* @brief Create a new mount.
57
*
58
* This does not add the mount to the mount cache, that must be done separately with `vfs_add_mount()`.
59
*
60
* There is no `mount_free()` instead use `UNREF()`.
61
*
62
* @param superblock The superblock of the mounted filesystem.
63
* @param source The dentry to appear at target once mounted, usually the root dentry of the mounted filesystem.
64
* @param target The dentry which the source is mounted to, can be `NULL` for the root filesystem.
65
* @param parent The parent mount, can be `NULL` for the root filesystem.
66
* @param mode Specifies the maximum permissions for this mount and if it is a directory or a file.
67
* @return On success, the new mount. On failure, returns `NULL` and `errno` is set to:
68
* - `EINVAL`: Invalid parameters.
69
* - `ENOENT`: Source or target dentry is negative.
70
* - `ENOTDIR`: Source is a file but mode specifies a directory.
71
* - `EISDIR`: Source is a directory but mode specifies a file.
72
* - `ENOMEM`: Out of memory.
73
*/
74
mount_t
*
mount_new
(
superblock_t
* superblock,
dentry_t
*
source
,
dentry_t
* target,
mount_t
* parent,
mode_t
mode);
75
76
/** @} */
mount_new
mount_t * mount_new(superblock_t *superblock, dentry_t *source, dentry_t *target, mount_t *parent, mode_t mode)
Create a new mount.
Definition
mount.c:39
mount_id_t
uint64_t mount_id_t
Mount ID type.
Definition
mount.h:30
mode_t
mode_t
Path flags and permissions.
Definition
path.h:74
source
static clock_source_t source
Structure to describe the HPET to the sys time subsystem.
Definition
hpet.c:192
list.h
map.h
path.h
mount
static mount_t * mount
Definition
ramfs.c:28
ref.h
stdatomic.h
stdint.h
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
dentry_t
Directory entry structure.
Definition
dentry.h:84
mount_t
Mount structure.
Definition
mount.h:44
mount_t::superblock
superblock_t * superblock
The superblock of the mounted filesystem.
Definition
mount.h:50
mount_t::target
dentry_t * target
The dentry which the source is mounted to, can be NULL for the root filesystem.
Definition
mount.h:49
mount_t::mode
mode_t mode
Specifies the maximum permissions for this mount and if it is a directory or a file.
Definition
mount.h:52
mount_t::parent
mount_t * parent
The parent mount, can be NULL for the root filesystem.
Definition
mount.h:51
mount_t::source
dentry_t * source
The dentry to appear at target once mounted, usually the root dentry of the mounted filesystem.
Definition
mount.h:48
mount_t::ref
ref_t ref
Definition
mount.h:45
mount_t::id
mount_id_t id
Definition
mount.h:46
path_t
Path structure.
Definition
path.h:125
ref_t
Reference counting structure.
Definition
ref.h:30
superblock_t
Superblock structure.
Definition
superblock.h:44
include
kernel
fs
mount.h
Generated on Mon Dec 15 2025 05:10:34 for PatchworkOS by
1.9.8