Nucleus
Barry Simple tmpfs file system driver 8250907 (3 years, 3 months ago)
diff --git a/vfs/tmpfs/super.c b/vfs/tmpfs/super.c
index 989d2c0..4746588 100644
--- a/vfs/tmpfs/super.c
+++ b/vfs/tmpfs/super.c
@@ -1,11 +1,39 @@
+#include <sys/stat.h>
#include <nucleus/vfs.h>
+extern InodeOps tmpfsInodeOps;
+extern FileOps tmpfsFileOps;
+
+Inode *tmpfs_alloc_inode(SuperBlock *sb);
+
+SuperOps tmpfsSuperOps = {
+ .alloc_inode = tmpfs_alloc_inode,
+};
+
/* Mount a tmpfs instance */
Inode *
tmpfs_mount(FSType *type, int flags, const char *dev, void *data)
{
-// SuperBlock *super = new(&superBlockType);
+ SuperBlock *super = new(&superBlockType);
+
+ super->type = get(type);
+ super->ops = &tmpfsSuperOps;
+
+ Inode *inode = super_alloc_inode(super);
+ inode->mode = S_IFDIR | 0755;
+ super->root = inode;
-// super->type =
- return NULL;
+ return inode;
+}
+
+/* Allocate an inode */
+Inode *
+tmpfs_alloc_inode(SuperBlock *sb)
+{
+ Inode *inode = new(&inodeType);
+ inode->ops = &tmpfsInodeOps;
+ inode->fileOps = &tmpfsFileOps;
+ inode->super = get(sb);
+ inode->nlink = 1;
+ return inode;
}