58 if (superblock ==
NULL)
60 panic(
NULL,
"Failed to create devfs superblock");
67 panic(
NULL,
"Failed to create devfs root vnode");
74 panic(
NULL,
"Failed to create devfs root dentry");
78 superblock->
root = dentry;
static dentry_ops_t dentryOps
static dentry_t * devfs_mount(filesystem_t *fs, const char *options, void *data)
static filesystem_t devfs
dentry_t * dentry_new(superblock_t *superblock, dentry_t *parent, const char *name)
Create a new dentry.
uint64_t dentry_generic_iterate(dentry_t *dentry, dir_ctx_t *ctx)
Helper function for a basic iterate.
void dentry_make_positive(dentry_t *dentry, vnode_t *vnode)
Make a dentry positive by associating it with an vnode.
uint64_t devfs_files_new(list_t *out, dentry_t *parent, const devfs_file_desc_t *descs)
Create multiple files in a devfs directory.
void devfs_init(void)
Initializes the devfs.
void devfs_files_free(list_t *files)
Free all files in a list created by devfs_files_new().
dentry_t * devfs_file_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, const file_ops_t *fileOps, void *data)
Create a new file inside a mounted devfs instance.
#define DEVFS_NAME
The name of the device filesystem.
dentry_t * devfs_dir_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, void *data)
Create a new directory inside a mounted devfs instance.
dentry_t * devfs_symlink_new(dentry_t *parent, const char *name, const vnode_ops_t *vnodeOps, void *data)
Create a new symbolic link inside a mounted devfs instance.
uint64_t filesystem_register(filesystem_t *fs)
Registers a filesystem.
superblock_t * superblock_new(filesystem_t *fs, const superblock_ops_t *ops, const dentry_ops_t *dentryOps)
Create a new superblock.
vnode_t * vnode_new(superblock_t *superblock, vtype_t type, const vnode_ops_t *ops, const file_ops_t *fileOps)
Create a new vnode.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define UNREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define UNREF(ptr)
Decrement reference count.
#define EINVAL
Invalid argument.
#define EXDEV
Cross-device link.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
@ VSYMLINK
Is a symbolic link.
static void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
#define LIST_CREATE(name)
Creates a list initializer.
static bool list_is_empty(list_t *list)
Checks if a list is empty.
static list_entry_t * list_pop_back(list_t *list)
Pops the last entry from the list.
static list_entry_t * list_pop_front(list_t *list)
Pops the first entry from the list.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF_SAFE(ptr, type, member)
Safe container of macro.
Dentry operations structure.
uint64_t(* iterate)(dentry_t *dentry, dir_ctx_t *ctx)
Iterate over the entries in a directory dentry.
Directory entry structure.
char name[MAX_NAME]
The name of the dentry, immutable after creation.
list_entry_t otherEntry
Made available for use by any other subsystems for convenience.
superblock_t * superblock
Descriptor for batch file creation.
const char * name
Name of the file, NULL marks end of array.
File operations structure.
Filesystem structure, represents a filesystem type, e.g. fat32, tmpfs, devfs, etc.
dentry_t * root
Root dentry of the filesystem, should not take a reference.
vnode operations structure.
void * data
Filesystem defined data.
static vnode_ops_t vnodeOps
static file_ops_t fileOps