comparison target-utils/libtiffs/init.c @ 61:c10a65f7563e

target-utils/libtiffs: find the root inode even if it's preceded by some blank entries
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 16:06:28 +0000
parents 87cb03b35f77
children
comparison
equal deleted inserted replaced
60:87cb03b35f77 61:c10a65f7563e
2 #include "struct.h" 2 #include "struct.h"
3 #include "globals.h" 3 #include "globals.h"
4 #include "macros.h" 4 #include "macros.h"
5 5
6 static const u8 ffs_sector_signature[6] = {'F', 'f', 's', '#', 0x10, 0x02}; 6 static const u8 ffs_sector_signature[6] = {'F', 'f', 's', '#', 0x10, 0x02};
7 static const u8 blank_flash_line[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
8 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
9 0xFF, 0xFF, 0xFF, 0xFF};
10 7
11 static 8 static
12 find_indexblk() 9 find_indexblk()
13 { 10 {
14 u32 sector_addr; 11 u32 sector_addr;
43 if (ino >= tiffs_sector_size >> 4) { 40 if (ino >= tiffs_sector_size >> 4) {
44 printf("Error: Hit end of sector, no root inode found\n"); 41 printf("Error: Hit end of sector, no root inode found\n");
45 return(-1); 42 return(-1);
46 } 43 }
47 irec = tiffs_active_index + ino; 44 irec = tiffs_active_index + ino;
48 if (!bcmp((u8 *) irec, blank_flash_line, 16)) {
49 printf("Error: Hit blank flash, no root inode found\n");
50 return(-1);
51 }
52 if (irec->type == OBJTYPE_DIR && *inode_to_dataptr(irec) == '/') 45 if (irec->type == OBJTYPE_DIR && *inode_to_dataptr(irec) == '/')
53 break; 46 break;
54 } 47 }
55 printf("Found at inode #%x\n", ino); 48 printf("Found at inode #%x\n", ino);
56 tiffs_root_ino = ino; 49 tiffs_root_ino = ino;