57 if (superblock ==
NULL)
59 panic(
NULL,
"Failed to create devfs superblock");
66 panic(
NULL,
"Failed to create devfs root inode");
73 panic(
NULL,
"Failed to create devfs root dentry");
77 superblock->
root = dentry;
dentry_t * devfs_dir_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
Create a new directory inside a mounted devfs instance.
static dentry_ops_t dentryOps
uint64_t devfs_files_new(list_t *out, dentry_t *parent, const devfs_file_desc_t *descs)
Create multiple files in a devfs directory.
static filesystem_t devfs
dentry_t * devfs_symlink_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
Create a new symbolic link inside a mounted devfs instance.
static dentry_t * devfs_mount(filesystem_t *fs, block_device_t *device, void *private)
dentry_t * devfs_file_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, const file_ops_t *fileOps, void *private)
Create a new file inside a mounted devfs instance.
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().
#define DEVFS_NAME
The name of the device filesystem.
void dentry_make_positive(dentry_t *dentry, inode_t *inode)
Make a dentry positive by associating it with an inode.
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.
size_t file_generic_seek(file_t *file, ssize_t offset, seek_origin_t origin)
Helper function for basic seeking.
uint64_t filesystem_register(filesystem_t *fs)
Registers a filesystem.
inode_t * inode_new(superblock_t *superblock, ino_t number, itype_t type, const inode_ops_t *ops, const file_ops_t *fileOps)
Create a new inode.
superblock_t * superblock_new(filesystem_t *fs, block_device_t *device, const superblock_ops_t *ops, const dentry_ops_t *dentryOps)
Create a new superblock.
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.
uint64_t vfs_id_get(void)
Generates a new unique ID, to be used for any VFS object.
#define EINVAL
Invalid argument.
#define EXDEV
Cross-device link.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
@ INODE_DIR
Is a directory.
@ INODE_SYMLINK
Is a symbolic link.
static uint64_t list_length(list_t *list)
Gets the length of the list.
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]
Constant 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.
size_t(* seek)(file_t *file, ssize_t offset, seek_origin_t origin)
Filesystem structure, represents a filesystem type, e.g. fat32, tmpfs, devfs, etc.
Inode operations structure.
dentry_t * root
Root dentry of the filesystem, should not take a reference.
static inode_ops_t inodeOps
static file_ops_t fileOps