MOS Source Code
Loading...
Searching...
No Matches
dentry.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
8#include <mos/mos_global.h>
9
36
37typedef enum
38{
39 // bit 0, 1: the operation only succeeds if the inode is a...
43
44 // bit 2: follow symlinks?
45 // only for the last segment, (if it is a symlink)
47
48 // bit 3, 4: the operation only succeeds if...
53
55
56
62should_inline bool path_is_absolute(const char *path)
63{
64 return path[0] == '/';
65}
66
68{
69 return tree_parent(&dentry, dentry_t);
70}
71
77void dentry_check_refstat(const dentry_t *dentry);
78typedef void(dump_refstat_receiver_t)(int depth, const dentry_t *dentry, bool mountroot, void *data);
79void dentry_dump_refstat(const dentry_t *dentry, dump_refstat_receiver_t receiver, void *data);
80
88
97
103void dentry_unref(dentry_t *dentry);
105void dentry_try_release(dentry_t *dentry);
106
113void dentry_attach(dentry_t *d, inode_t *inode);
114
120void dentry_detach(dentry_t *dentry);
121
130
141
157PtrResult<dentry_t> dentry_resolve(dentry_t *starting_dir, dentry_t *root_dir, const char *path, lastseg_resolve_flags_t flags);
158
168__nodiscard bool dentry_mount(dentry_t *mountpoint, dentry_t *root, filesystem_t *fs);
169
176
184
194ssize_t dentry_path(dentry_t *dentry, dentry_t *root, char *buf, size_t size);
195
void dentry_attach(dentry_t *d, inode_t *inode)
Attach an inode to a dentry.
Definition dentry.cpp:306
__nodiscard dentry_t * dentry_unmount(dentry_t *root)
Unmount a filesystem at the mountpoint.
Definition mount.cpp:95
dentry_t * dentry_ref_up_to(dentry_t *dentry, dentry_t *root)
Increment the reference count of a dentry up to a given dentry.
PtrResult< dentry_t > dentry_from_fd(fd_t fd)
Get the dentry from a file descriptor.
Definition dentry.cpp:331
void dentry_dump_refstat(const dentry_t *dentry, dump_refstat_receiver_t receiver, void *data)
__nodiscard bool dentry_mount(dentry_t *mountpoint, dentry_t *root, filesystem_t *fs)
Mount a filesystem at a mountpoint.
Definition mount.cpp:70
should_inline bool path_is_absolute(const char *path)
Check if a path is absolute.
Definition dentry.hpp:62
PtrResult< dentry_t > dentry_lookup_child(dentry_t *parent, const char *name)
Get a child dentry from a parent dentry.
Definition dentry.cpp:355
void dump_refstat_receiver_t(int depth, const dentry_t *dentry, bool mountroot, void *data)
Definition dentry.hpp:78
void dentry_detach(dentry_t *dentry)
Detach the inode from a dentry.
Definition dentry.cpp:319
void dentry_try_release(dentry_t *dentry)
ssize_t dentry_path(dentry_t *dentry, dentry_t *root, char *buf, size_t size)
Get the path of a dentry.
should_inline dentry_t * dentry_parent(const dentry_t &dentry)
Definition dentry.hpp:67
void vfs_populate_listdir_buf(dentry_t *dir, vfs_listdir_state_t *state)
List the contents of a directory.
Definition dentry.cpp:446
dentry_t * dentry_ref(dentry_t *dentry)
Increment the reference count of a dentry.
lastseg_resolve_flags_t
Definition dentry.hpp:38
void dentry_check_refstat(const dentry_t *dentry)
Check the reference count of a dentry.
PtrResult< dentry_t > dentry_resolve(dentry_t *starting_dir, dentry_t *root_dir, const char *path, lastseg_resolve_flags_t flags)
Lookup a path in the filesystem.
Definition dentry.cpp:398
void dentry_unref(dentry_t *dentry)
Decrement the reference count of a dentry.
__nodiscard bool dentry_unref_one_norelease(dentry_t *dentry)
Decrease the refcount of ONE SINGLE dentry, including (if it's a mountpoint) the mountpoint dentry.
@ RESOLVE_EXPECT_EXIST
Definition dentry.hpp:49
@ RESOLVE_EXPECT_ANY_EXIST
Definition dentry.hpp:51
@ RESOLVE_SYMLINK_NOFOLLOW
Definition dentry.hpp:46
@ RESOLVE_EXPECT_ANY_TYPE
Definition dentry.hpp:42
@ RESOLVE_EXPECT_DIR
Definition dentry.hpp:41
@ RESOLVE_EXPECT_NONEXIST
Definition dentry.hpp:50
@ RESOLVE_EXPECT_FILE
Definition dentry.hpp:40
MOSAPI void(1, 2) fatal_abort(const char *fmt
#define __nodiscard
Definition mos_global.h:35
#define should_inline
Definition mos_global.h:37
size_t size
Definition slab.cpp:34
const char * name
Definition slab.cpp:35
#define tree_parent(node, type)
Definition tree.hpp:30
s32 fd_t
Definition types.h:77
signed long ssize_t
Definition types.h:79
#define MOS_ENUM_OPERATORS(_enum)
Definition types.hpp:113