FreeCalypso > hg > freecalypso-tools
comparison target-utils/libtiffs/init.c @ 60:87cb03b35f77
target-utils: long-overdue s/mpffs/tiffs/ and s/MPFFS/TIFFS/ rename
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 26 Oct 2016 15:52:14 +0000 |
parents | e7502631a0f9 |
children | c10a65f7563e |
comparison
equal
deleted
inserted
replaced
59:819335e06fd1 | 60:87cb03b35f77 |
---|---|
13 { | 13 { |
14 u32 sector_addr; | 14 u32 sector_addr; |
15 u8 *sector_ptr; | 15 u8 *sector_ptr; |
16 int i; | 16 int i; |
17 | 17 |
18 printf("Looking for MPFFS active index block\n"); | 18 printf("Looking for TIFFS active index block\n"); |
19 sector_addr = mpffs_base_addr; | 19 sector_addr = tiffs_base_addr; |
20 for (i = 0; i < mpffs_nsectors; i++) { | 20 for (i = 0; i < tiffs_nsectors; i++) { |
21 sector_ptr = (u8 *) sector_addr; | 21 sector_ptr = (u8 *) sector_addr; |
22 if (!bcmp(sector_ptr, ffs_sector_signature, 6) && | 22 if (!bcmp(sector_ptr, ffs_sector_signature, 6) && |
23 sector_ptr[8] == 0xAB) { | 23 sector_ptr[8] == 0xAB) { |
24 printf("Found at %08X\n", sector_addr); | 24 printf("Found at %08X\n", sector_addr); |
25 mpffs_active_index = (struct inode *) sector_ptr; | 25 tiffs_active_index = (struct inode *) sector_ptr; |
26 return(0); | 26 return(0); |
27 } | 27 } |
28 sector_addr += mpffs_sector_size; | 28 sector_addr += tiffs_sector_size; |
29 } | 29 } |
30 printf("Error: Not found in any of the %d candidate sectors\n", | 30 printf("Error: Not found in any of the %d candidate sectors\n", |
31 mpffs_nsectors); | 31 tiffs_nsectors); |
32 return(-1); | 32 return(-1); |
33 } | 33 } |
34 | 34 |
35 static | 35 static |
36 find_rootino() | 36 find_rootino() |
38 int ino; | 38 int ino; |
39 struct inode *irec; | 39 struct inode *irec; |
40 | 40 |
41 printf("Looking for the root inode\n"); | 41 printf("Looking for the root inode\n"); |
42 for (ino = 1; ; ino++) { | 42 for (ino = 1; ; ino++) { |
43 if (ino >= mpffs_sector_size >> 4) { | 43 if (ino >= tiffs_sector_size >> 4) { |
44 printf("Error: Hit end of sector, no root inode found\n"); | 44 printf("Error: Hit end of sector, no root inode found\n"); |
45 return(-1); | 45 return(-1); |
46 } | 46 } |
47 irec = mpffs_active_index + ino; | 47 irec = tiffs_active_index + ino; |
48 if (!bcmp((u8 *) irec, blank_flash_line, 16)) { | 48 if (!bcmp((u8 *) irec, blank_flash_line, 16)) { |
49 printf("Error: Hit blank flash, no root inode found\n"); | 49 printf("Error: Hit blank flash, no root inode found\n"); |
50 return(-1); | 50 return(-1); |
51 } | 51 } |
52 if (irec->type == OBJTYPE_DIR && *inode_to_dataptr(irec) == '/') | 52 if (irec->type == OBJTYPE_DIR && *inode_to_dataptr(irec) == '/') |
53 break; | 53 break; |
54 } | 54 } |
55 printf("Found at inode #%x\n", ino); | 55 printf("Found at inode #%x\n", ino); |
56 mpffs_root_ino = ino; | 56 tiffs_root_ino = ino; |
57 return(0); | 57 return(0); |
58 } | 58 } |
59 | 59 |
60 mpffs_init() | 60 tiffs_init() |
61 { | 61 { |
62 int stat; | 62 int stat; |
63 | 63 |
64 if (mpffs_init_done) | 64 if (tiffs_init_done) |
65 return(0); | 65 return(0); |
66 stat = find_indexblk(); | 66 stat = find_indexblk(); |
67 if (stat < 0) | 67 if (stat < 0) |
68 return(stat); | 68 return(stat); |
69 stat = find_rootino(); | 69 stat = find_rootino(); |
70 if (stat < 0) | 70 if (stat < 0) |
71 return(stat); | 71 return(stat); |
72 mpffs_init_done = 1; | 72 tiffs_init_done = 1; |
73 return(0); | 73 return(0); |
74 } | 74 } |