diff options
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r-- | firmware/drivers/fat.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 936299e122..35e79789b0 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -113,7 +113,6 @@ struct fsinfo { | |||
113 | #define FSINFO_NEXTFREE 492 | 113 | #define FSINFO_NEXTFREE 492 |
114 | 114 | ||
115 | static int first_sector_of_cluster(struct bpb *bpb, unsigned int cluster); | 115 | static int first_sector_of_cluster(struct bpb *bpb, unsigned int cluster); |
116 | static int get_bpb(struct bpb *bpb); | ||
117 | static int bpb_is_sane(struct bpb *bpb); | 116 | static int bpb_is_sane(struct bpb *bpb); |
118 | static void *cache_fat_sector(struct bpb *bpb, int secnum); | 117 | static void *cache_fat_sector(struct bpb *bpb, int secnum); |
119 | #ifdef DISK_WRITE | 118 | #ifdef DISK_WRITE |
@@ -125,7 +124,9 @@ static int create_dos_name(unsigned char *name, unsigned char *newname); | |||
125 | 124 | ||
126 | /* fat cache */ | 125 | /* fat cache */ |
127 | static unsigned char *fat_cache[256]; | 126 | static unsigned char *fat_cache[256]; |
127 | #ifdef DISK_WRITE | ||
128 | static int fat_cache_dirty[256]; | 128 | static int fat_cache_dirty[256]; |
129 | #endif | ||
129 | 130 | ||
130 | /* sectors cache for longname use */ | 131 | /* sectors cache for longname use */ |
131 | static unsigned char lastsector[SECTOR_SIZE]; | 132 | static unsigned char lastsector[SECTOR_SIZE]; |
@@ -149,7 +150,7 @@ int main(int argc, char *argv[]) | |||
149 | if(ata_init()) | 150 | if(ata_init()) |
150 | DEBUG("*** Warning! The disk is uninitialized\n"); | 151 | DEBUG("*** Warning! The disk is uninitialized\n"); |
151 | else | 152 | else |
152 | get_bpb(&bpb); | 153 | fat_mount(&bpb); |
153 | 154 | ||
154 | dbg_console(&bpb); | 155 | dbg_console(&bpb); |
155 | return 0; | 156 | return 0; |
@@ -192,7 +193,7 @@ static int first_sector_of_cluster(struct bpb *bpb, unsigned int cluster) | |||
192 | return (cluster - 2) * bpb->bpb_secperclus + bpb->firstdatasector; | 193 | return (cluster - 2) * bpb->bpb_secperclus + bpb->firstdatasector; |
193 | } | 194 | } |
194 | 195 | ||
195 | static int get_bpb(struct bpb *bpb) | 196 | int fat_mount(struct bpb *bpb) |
196 | { | 197 | { |
197 | unsigned char buf[SECTOR_SIZE]; | 198 | unsigned char buf[SECTOR_SIZE]; |
198 | int err; | 199 | int err; |
@@ -203,7 +204,7 @@ static int get_bpb(struct bpb *bpb) | |||
203 | err = ata_read_sectors(0,1,buf); | 204 | err = ata_read_sectors(0,1,buf); |
204 | if(err) | 205 | if(err) |
205 | { | 206 | { |
206 | DEBUG1( "get_bpb() - Couldn't read BPB (error code %i)\n", | 207 | DEBUG1( "fat_mount() - Couldn't read BPB (error code %i)\n", |
207 | err); | 208 | err); |
208 | return -1; | 209 | return -1; |
209 | } | 210 | } |
@@ -276,7 +277,7 @@ static int get_bpb(struct bpb *bpb) | |||
276 | 277 | ||
277 | if (bpb_is_sane(bpb) < 0) | 278 | if (bpb_is_sane(bpb) < 0) |
278 | { | 279 | { |
279 | DEBUG( "get_bpb() - BPB is not sane\n"); | 280 | DEBUG( "fat_mount() - BPB is not sane\n"); |
280 | return -1; | 281 | return -1; |
281 | } | 282 | } |
282 | 283 | ||
@@ -863,7 +864,7 @@ int fat_seek(struct bpb *bpb, | |||
863 | int seeksector ) | 864 | int seeksector ) |
864 | { | 865 | { |
865 | int cluster = ent->firstcluster; | 866 | int cluster = ent->firstcluster; |
866 | int sector; | 867 | int sector = seeksector; |
867 | int numsec = 0; | 868 | int numsec = 0; |
868 | int i; | 869 | int i; |
869 | 870 | ||
@@ -880,6 +881,8 @@ int fat_seek(struct bpb *bpb, | |||
880 | return -2; | 881 | return -2; |
881 | numsec=0; | 882 | numsec=0; |
882 | } | 883 | } |
884 | else | ||
885 | sector++; | ||
883 | } | 886 | } |
884 | ent->nextcluster = cluster; | 887 | ent->nextcluster = cluster; |
885 | ent->nextsector = sector; | 888 | ent->nextsector = sector; |
@@ -980,7 +983,10 @@ int fat_getnext(struct bpb *bpb, | |||
980 | index &= SECTOR_SIZE-1; | 983 | index &= SECTOR_SIZE-1; |
981 | } | 984 | } |
982 | 985 | ||
983 | /* piece together the name subcomponents */ | 986 | /* piece together the name subcomponents. |
987 | names are stored in unicode, but we | ||
988 | only grab the low byte (iso8859-1). | ||
989 | */ | ||
984 | for (k=0; k<5; k++) | 990 | for (k=0; k<5; k++) |
985 | entry->name[l++] = ptr[index + k*2 + 1]; | 991 | entry->name[l++] = ptr[index + k*2 + 1]; |
986 | for (k=0; k<6; k++) | 992 | for (k=0; k<6; k++) |