64 const char* version =
"9P2000";
70 if (
strcmp(key,
"in") == 0)
74 else if (
strcmp(key,
"out") == 0)
78 else if (
strcmp(key,
"version") == 0)
89 if (in ==
ERR || out ==
ERR)
95 if (
strcmp(version,
"9P2000") != 0)
102 if (superblock ==
NULL)
148 superblock->
root = dentry;
149 return superblock->
root;
178MODULE_INFO(
"9P Filesystem",
"Kai Norberg",
"A implementation of the 9P filesystem", OS_VERSION,
"MIT",
"BOOT_ALWAYS");
uint64_t _module_procedure(const module_event_t *event)
#define assert(expression)
static void ninep_super_cleanup(superblock_t *sb)
static dentry_t * ninep_mount(filesystem_t *fs, const char *options, void *data)
static superblock_ops_t superOps
static filesystem_t ninep
dentry_t * dentry_new(superblock_t *superblock, dentry_t *parent, const char *name)
Create a new dentry.
void dentry_make_positive(dentry_t *dentry, vnode_t *vnode)
Make a dentry positive by associating it with an vnode.
file_t * file_table_get(file_table_t *table, fd_t fd)
Get a file from its file descriptor.
uint64_t filesystem_register(filesystem_t *fs)
Registers a filesystem.
#define OPTIONS_FOR_EACH(options, key, value)
Helper macro for iterating over options passed to a filesystem mount operation.
void filesystem_unregister(filesystem_t *fs)
Unregisters 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.
#define MODULE_INFO(_name, _author, _description, _version, _licence, _deviceTypes)
Macro to define module information.
static process_t * process_current(void)
Retrieves the process of the currently running thread.
#define UNREF_DEFER(ptr)
RAII-style cleanup for scoped references.
#define UNREF(ptr)
Decrement reference count.
#define EINVAL
Invalid argument.
#define ENOSYS
Function not implemented.
#define ENOMEM
Out of memory.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ fd_t
File descriptor type.
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
_PUBLIC int strcmp(const char *s1, const char *s2)
Directory entry structure.
Filesystem structure, represents a filesystem type, e.g. fat32, tmpfs, devfs, etc.
Superblock operations structure.
void(* cleanup)(superblock_t *superblock)
dentry_t * root
Root dentry of the filesystem, should not take a reference.