kern
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/fs.c Thu Dec 08 13:34:47 2011 +0200 1.3 @@ -0,0 +1,46 @@ 1.4 +#include <stdio.h> 1.5 +#include "fs.h" 1.6 +#include "ata.h" 1.7 +#include "part.h" 1.8 +#include "panic.h" 1.9 + 1.10 +#define PART_TYPE 0xcc 1.11 + 1.12 +static int find_rootfs(int *dev, struct partition *part); 1.13 + 1.14 +/* root device & partition */ 1.15 +static int rdev; 1.16 +static struct partition rpart; 1.17 + 1.18 +void init_fs(void) 1.19 +{ 1.20 + if(find_rootfs(&rdev, &rpart) == -1) { 1.21 + panic("can't find root filesystem\n"); 1.22 + } 1.23 +} 1.24 + 1.25 +static int find_rootfs(int *dev, struct partition *part) 1.26 +{ 1.27 + int i, num_dev, partid; 1.28 + struct partition *plist, *p; 1.29 + 1.30 + num_dev = ata_num_devices(); 1.31 + for(i=0; i<num_dev; i++) { 1.32 + plist = p = get_part_list(i); 1.33 + 1.34 + partid = 0; 1.35 + while(p) { 1.36 + if(get_part_type(p) == PART_TYPE) { 1.37 + /* found it! */ 1.38 + printf("using ata%dp%d\n", i, partid); 1.39 + *dev = i; 1.40 + *part = *p; 1.41 + return 0; 1.42 + } 1.43 + p = p->next; 1.44 + partid++; 1.45 + } 1.46 + free_part_list(plist); 1.47 + } 1.48 + return -1; 1.49 +}