kern

view src/fs.c @ 88:a398bf73fe93

- added the partition table parsing code - starting with the filesystem
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 Dec 2011 13:34:47 +0200
parents
children 2f555c81ae67
line source
1 #include <stdio.h>
2 #include "fs.h"
3 #include "ata.h"
4 #include "part.h"
5 #include "panic.h"
7 #define PART_TYPE 0xcc
9 static int find_rootfs(int *dev, struct partition *part);
11 /* root device & partition */
12 static int rdev;
13 static struct partition rpart;
15 void init_fs(void)
16 {
17 if(find_rootfs(&rdev, &rpart) == -1) {
18 panic("can't find root filesystem\n");
19 }
20 }
22 static int find_rootfs(int *dev, struct partition *part)
23 {
24 int i, num_dev, partid;
25 struct partition *plist, *p;
27 num_dev = ata_num_devices();
28 for(i=0; i<num_dev; i++) {
29 plist = p = get_part_list(i);
31 partid = 0;
32 while(p) {
33 if(get_part_type(p) == PART_TYPE) {
34 /* found it! */
35 printf("using ata%dp%d\n", i, partid);
36 *dev = i;
37 *part = *p;
38 return 0;
39 }
40 p = p->next;
41 partid++;
42 }
43 free_part_list(plist);
44 }
45 return -1;
46 }