MOS Source Code
Loading...
Searching...
No Matches
dentry.h
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
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
60should_inline bool path_is_absolute(const char *path)
61{
62 return path[0] == '/';
63}
64
66{
67 return tree_parent(dentry, dentry_t);
68}
69
75void dentry_check_refstat(const dentry_t *dentry);
76typedef void(dump_refstat_receiver_t)(int depth, const dentry_t *dentry, bool mountroot, void *data);
77void dentry_dump_refstat(const dentry_t *dentry, dump_refstat_receiver_t receiver, void *data);
78
86
95
101void dentry_unref(dentry_t *dentry);
103void dentry_try_release(dentry_t *dentry);
104
111void dentry_attach(dentry_t *d, inode_t *inode);
112
118void dentry_detach(dentry_t *dentry);
119
128
138dentry_t *dentry_lookup_child(dentry_t *parent, const char *name);
139
155dentry_t *dentry_resolve(dentry_t *starting_dir, dentry_t *root_dir, const char *path, lastseg_resolve_flags_t flags);
156
166__nodiscard bool dentry_mount(dentry_t *mountpoint, dentry_t *root, filesystem_t *fs);
167
174
182
192ssize_t dentry_path(dentry_t *dentry, dentry_t *root, char *buf, size_t size);
193
void dentry_attach(dentry_t *d, inode_t *inode)
Attach an inode to a dentry.
Definition dentry.c:305
__nodiscard dentry_t * dentry_unmount(dentry_t *root)
Unmount a filesystem at the mountpoint.
Definition mount.c:107
dentry_t * dentry_from_fd(fd_t fd)
Get the dentry from a file descriptor.
Definition dentry.c:330
dentry_t * dentry_ref_up_to(dentry_t *dentry, dentry_t *root)
Increment the reference count of a dentry up to a given dentry.
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.c:76
should_inline bool path_is_absolute(const char *path)
Check if a path is absolute.
Definition dentry.h:60
void dump_refstat_receiver_t(int depth, const dentry_t *dentry, bool mountroot, void *data)
Definition dentry.h:76
void dentry_detach(dentry_t *dentry)
Detach the inode from a dentry.
Definition dentry.c:318
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.
void vfs_populate_listdir_buf(dentry_t *dir, vfs_listdir_state_t *state)
List the contents of a directory.
Definition dentry.c:446
dentry_t * dentry_ref(dentry_t *dentry)
Increment the reference count of a dentry.
should_inline dentry_t * dentry_parent(const dentry_t *dentry)
Definition dentry.h:65
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.c:397
lastseg_resolve_flags_t
Definition dentry.h:38
void dentry_check_refstat(const dentry_t *dentry)
Check the reference count of a dentry.
dentry_t * dentry_lookup_child(dentry_t *parent, const char *name)
Get a child dentry from a parent dentry.
Definition dentry.c:354
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.h:49
@ RESOLVE_EXPECT_ANY_EXIST
Definition dentry.h:51
@ RESOLVE_SYMLINK_NOFOLLOW
Definition dentry.h:46
@ RESOLVE_EXPECT_ANY_TYPE
Definition dentry.h:42
@ RESOLVE_EXPECT_DIR
Definition dentry.h:41
@ RESOLVE_EXPECT_NONEXIST
Definition dentry.h:50
@ RESOLVE_EXPECT_FILE
Definition dentry.h: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.c:30
const char * name
Definition slab.c:31
#define tree_parent(node, type)
Definition tree.h:30
s32 fd_t
Definition types.h:81
signed long ssize_t
Definition types.h:83