summaryrefslogtreecommitdiff
path: root/kernel/fs/mount.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/fs/mount.c')
-rw-r--r--kernel/fs/mount.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/kernel/fs/mount.c b/kernel/fs/mount.c
new file mode 100644
index 0000000..47911fb
--- /dev/null
+++ b/kernel/fs/mount.c
@@ -0,0 +1,35 @@
+#include <kernel/con.h>
+#include <kernel/fs.h>
+#include <string.h>
+
+/* super blocks table */
+struct super_block sblocks[NRSUPER];
+
+void mount_root(void) {
+ size_t ret;
+ char buf[BLOCK_SIZE];
+ struct super_block *s = (void*) buf;
+
+ ret = block_read(buf, 1, 1);
+ if(ret < 1) {
+ printk("[fs] Failed to read super block\n");
+ return;
+ }
+
+ if(s->s_magic != SUPER_MAGIC) {
+ printk("[fs] Invalid magic number in super block!\n");
+ return;
+ }
+
+ printk("[fs] Found valid super-block for /\n");
+ printk(" 0x%01x inodes\n", s->s_ninodes);
+ printk(" 0x%01x zones\n", s->s_nzones);
+ printk(" 0x%01x inode block bitmaps\n", s->s_imap_blocks);
+ printk(" 0x%01x zone block bitmaps\n", s->s_zmap_blocks);
+ printk(" First data zone: 0x%01x\n", s->s_firstdatazone);
+ printk(" Log zone size: 0x%01x\n", s->s_log_zone_size);
+ printk(" Max file size: 0x%01x\n", s->s_max_size);
+
+ /* copy the super block into the table */
+ memcpy(sblocks, buf, ((unsigned) &s->s_imap - (unsigned) s));
+}