summaryrefslogtreecommitdiff
path: root/kernel/fs/mount.c
blob: 401d2e8e0ed9bef1be323ec7f940ef48ab0f816f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <kernel/con.h>
#include <kernel/fs.h>
#include <string.h>

/* super blocks table */
struct super_block sblocks[NRSUPER];

void mount_root(void) {
  int ret;
  struct buffer *b;
  struct super_block *s;

  b = buffer_get_block(1, 1);
  if(!b) {
    printk("[fs] Failed to read super block\n");
    return;
  }

  s = b->b_data;

  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, s, ((unsigned) &s->s_imap - (unsigned) s));
}