45 if (superblock ==
NULL)
90 panic(
NULL,
"Failed to create /dev filesystem");
184 parent = devMount->
root;
227 parent = devMount->
root;
#define assert(expression)
dentry_t * dentry_new(superblock_t *superblock, dentry_t *parent, const char *name)
Create a new dentry.
uint64_t dentry_make_positive(dentry_t *dentry, inode_t *inode)
Make a dentry positive by associating it with an inode.
uint64_t dentry_generic_getdents(dentry_t *dentry, dirent_t *buffer, uint64_t count, uint64_t *offset, path_flags_t flags)
Helper function for a basic getdents.
uint64_t file_generic_seek(file_t *file, int64_t offset, seek_origin_t origin)
Helper function for basic seeking.
inode_t * inode_new(superblock_t *superblock, inode_number_t number, inode_type_t type, const inode_ops_t *ops, const file_ops_t *fileOps)
Create a new inode.
mount_t * namespace_mount(namespace_t *ns, path_t *mountpoint, const char *deviceName, const char *fsName, void *private)
Mount a filesystem in a namespace.
void path_put(path_t *path)
Put a path.
#define PATH_CREATE(inMount, inDentry)
Helper to create a path.
#define PATH_DEFER(path)
Defer path put.
void path_set(path_t *path, mount_t *mount, dentry_t *dentry)
Set a path.
#define PATH_EMPTY
Helper to create an empty path.
superblock_t * superblock_new(const filesystem_t *fs, const char *deviceName, const superblock_ops_t *ops, const dentry_ops_t *dentryOps)
Create a new superblock.
uint64_t vfs_register_fs(filesystem_t *fs)
Registers a filesystem.
#define VFS_ROOT_ENTRY_NAME
The name of the root entry.
#define VFS_DEVICE_NAME_NONE
The name used to indicate no device.
dentry_t * vfs_get_or_lookup_dentry(const path_t *parent, const char *name)
Get or lookup a dentry for the given name. Will NOT traverse mountpoints.
NORETURN void panic(const interrupt_frame_t *frame, const char *format,...)
Panic the kernel, printing a message and halting.
#define LOG_INFO(format,...)
process_t * process_get_kernel(void)
Gets the kernel process.
#define DEREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define REF(ptr)
Increment reference count.
#define EINVAL
Invalid argument.
#define EXDEV
Cross-device link.
#define errno
Error number variable.
uint64_t inode_number_t
Inode number enum.
@ INODE_DIR
Is a directory.
#define NULL
Pointer error value.
#define ERR
Integer error value.
static process_t kernelProcess
static inode_ops_t inodeOps
static file_ops_t fileOps
static superblock_ops_t superblockOps
#define ATOMIC_VAR_INIT(value)
#define atomic_fetch_add(object, operand)
Dentry operations structure.
uint64_t(* getdents)(dentry_t *dentry, dirent_t *buffer, uint64_t count, uint64_t *offset, path_flags_t flags)
Used to now what is in a directory.
Directory entry structure.
superblock_t * superblock
File operations structure.
uint64_t(* seek)(file_t *file, int64_t offset, seek_origin_t origin)
Filesystem structure, represents a filesystem type, e.g. fat32, ramfs, sysfs, etc.
dentry_t * root
The root dentry of the mounted filesystem.
mount_t * rootMount
The root mount of the namespace, will be inherited from the parent namespace.
Superblock operations structure.
const superblock_ops_t * superblockOps
static dentry_ops_t dentryOps
mount_t * sysfs_mount_new(const path_t *parent, const char *name, namespace_t *ns, const superblock_ops_t *superblockOps)
Mount a new instance of SysFS.
dentry_t * sysfs_get_dev(void)
Gets the default SysFS directory.
static filesystem_t sysfs
dentry_t * sysfs_dir_new(dentry_t *parent, const char *name, const inode_ops_t *inodeOps, void *private)
Create a new directory inside a mounted SysFS instance.
dentry_t * sysfs_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 SysFS instance.
void sysfs_init(void)
Initializes the SysFS.
static dentry_t * sysfs_mount(filesystem_t *fs, const char *devName, void *private)