blob: 47911fbb53cc2c411fee52b9964211d32df30611 (
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
|
#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));
}
|