forked from wesedens/fs-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initfs.c
51 lines (38 loc) · 1.21 KB
/
initfs.c
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
This file contains some glue code that initializes the block cache,
the vnode layer, mounts the root file system (a simple container)
and then mounts our file system at the mount point /myfs. You could
modify this to mount other file systems or even multiple file systems
if you wanted.
THIS CODE COPYRIGHT DOMINIC GIAMPAOLO. NO WARRANTY IS EXPRESSED
OR IMPLIED. YOU MAY USE THIS CODE AND FREELY DISTRIBUTE IT FOR
NON-COMMERCIAL USE AS LONG AS THIS NOTICE REMAINS ATTACHED.
FOR COMMERCIAL USE, CONTACT DOMINIC GIAMPAOLO (dbg@be.com).
Dominic Giampaolo
dbg@be.com
*/
#include <stdio.h>
#include <stdlib.h>
#include "compat.h"
#include "fsproto.h"
#include "myfs_vnops.h"
#include "kprotos.h"
void *
init_fs(char *disk_name)
{
int err;
void *data = NULL;
init_block_cache(1024, 0);
init_vnode_layer();
err = sys_mkdir(1, -1, "/myfs", 0);
if (install_file_system(&myfs_ops, "myfs", 1, -1) == NULL) {
printf("can't install my file system\n");
exit(0);
}
data = sys_mount(1, "myfs", -1, "/myfs", disk_name, 0, NULL, 0);
if (data == NULL) {
printf("could not mount %s on /myfs\n", disk_name);
exit(0);
}
return data;
}