X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=fs%2Ffat%2Ffat.c;h=7f991b25de8d54266e59717ce7ba384c53728065;hb=20cc00ddac48da45d6b4d6eb3c292867b618b361;hp=6a6c5be0168ed4043fbe7f78404b44f2456f39b3;hpb=7205e4075d8b50e4dd89fe39ed03860b23cbb704;p=platform%2Fkernel%2Fu-boot.git diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 6a6c5be..7f991b2 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -89,7 +89,8 @@ fat_register_device(block_dev_desc_t *dev_desc, int part_no) part_offset=0; } else { -#if (CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI) +#if (CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI) || \ + (CONFIG_COMMANDS & CFG_CMD_USB) || defined(CONFIG_SYSTEMACE) disk_partition_t info; if(!get_partition_info(dev_desc, part_no, &info)) { part_offset = info.start; @@ -424,6 +425,7 @@ slot2str(dir_slot *slotptr, char *l_name, int *idx) * into 'retdent' * Return 0 on success, -1 otherwise. */ +__u8 get_vfatname_block[MAX_CLUSTSIZE]; static int get_vfatname(fsdata *mydata, int curclust, __u8 *cluster, dir_entry *retdent, char *l_name) @@ -431,18 +433,18 @@ get_vfatname(fsdata *mydata, int curclust, __u8 *cluster, dir_entry *realdent; dir_slot *slotptr = (dir_slot*) retdent; __u8 *nextclust = cluster + mydata->clust_size * SECTOR_SIZE; - __u8 counter = slotptr->id & 0xf; + __u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff; int idx = 0; while ((__u8*)slotptr < nextclust) { if (counter == 0) break; - if ((slotptr->id & 0x0f) != counter) return -1; + if (((slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff) != counter) + return -1; slotptr++; counter--; } if ((__u8*)slotptr >= nextclust) { - __u8 block[MAX_CLUSTSIZE]; dir_slot *slotptr2; slotptr--; @@ -452,18 +454,18 @@ get_vfatname(fsdata *mydata, int curclust, __u8 *cluster, FAT_ERROR("Invalid FAT entry\n"); return -1; } - if (get_cluster(mydata, curclust, block, + if (get_cluster(mydata, curclust, get_vfatname_block, mydata->clust_size * SECTOR_SIZE) != 0) { FAT_DPRINT("Error: reading directory block\n"); return -1; } - slotptr2 = (dir_slot*) block; + slotptr2 = (dir_slot*) get_vfatname_block; while (slotptr2->id > 0x01) { slotptr2++; } /* Save the real directory entry */ realdent = (dir_entry*)slotptr2 + 1; - while ((__u8*)slotptr2 >= block) { + while ((__u8*)slotptr2 >= get_vfatname_block) { slot2str(slotptr2, l_name, &idx); slotptr2--; } @@ -475,7 +477,7 @@ get_vfatname(fsdata *mydata, int curclust, __u8 *cluster, do { slotptr--; if (slot2str(slotptr, l_name, &idx)) break; - } while (!(slotptr->id & 0x40)); + } while (!(slotptr->id & LAST_LONG_ENTRY_MASK)); l_name[idx] = '\0'; if (*l_name == DELETED_FLAG) *l_name = '\0'; @@ -509,12 +511,12 @@ mkcksum(const char *str) * Get the directory entry associated with 'filename' from the directory * starting at 'startsect' */ +__u8 get_dentfromdir_block[MAX_CLUSTSIZE]; static dir_entry *get_dentfromdir (fsdata * mydata, int startsect, char *filename, dir_entry * retdent, int dols) { __u16 prevcksum = 0xffff; - __u8 block[MAX_CLUSTSIZE]; __u32 curclust = START (retdent); int files = 0, dirs = 0; @@ -523,23 +525,27 @@ static dir_entry *get_dentfromdir (fsdata * mydata, int startsect, dir_entry *dentptr; int i; - if (get_cluster (mydata, curclust, block, + if (get_cluster (mydata, curclust, get_dentfromdir_block, mydata->clust_size * SECTOR_SIZE) != 0) { FAT_DPRINT ("Error: reading directory block\n"); return NULL; } - dentptr = (dir_entry *) block; + dentptr = (dir_entry *) get_dentfromdir_block; for (i = 0; i < DIRENTSPERCLUST; i++) { char s_name[14], l_name[256]; l_name[0] = '\0'; + if (dentptr->name[0] == DELETED_FLAG) { + dentptr++; + continue; + } if ((dentptr->attr & ATTR_VOLUME)) { #ifdef CONFIG_SUPPORT_VFAT if ((dentptr->attr & ATTR_VFAT) && - (dentptr->name[0] & 0x40)) { + (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) { prevcksum = ((dir_slot *) dentptr) ->alias_checksum; - get_vfatname (mydata, curclust, block, + get_vfatname (mydata, curclust, get_dentfromdir_block, dentptr, l_name); if (dols) { int isdir = (dentptr->attr & ATTR_DIR); @@ -711,11 +717,11 @@ read_bootsectandvi(boot_sector *bs, volume_info *volinfo, int *fatsize) } -static long +__u8 do_fat_read_block[MAX_CLUSTSIZE]; /* Block buffer */ +long do_fat_read (const char *filename, void *buffer, unsigned long maxsize, int dols) { - __u8 block[MAX_CLUSTSIZE]; /* Block buffer */ char fnamecopy[2048]; boot_sector bs; volume_info volinfo; @@ -787,11 +793,11 @@ do_fat_read (const char *filename, void *buffer, unsigned long maxsize, while (1) { int i; - if (disk_read (cursect, mydata->clust_size, block) < 0) { + if (disk_read (cursect, mydata->clust_size, do_fat_read_block) < 0) { FAT_DPRINT ("Error: reading rootdir block\n"); return -1; } - dentptr = (dir_entry *) block; + dentptr = (dir_entry *) do_fat_read_block; for (i = 0; i < DIRENTSPERBLOCK; i++) { char s_name[14], l_name[256]; @@ -799,9 +805,9 @@ do_fat_read (const char *filename, void *buffer, unsigned long maxsize, if ((dentptr->attr & ATTR_VOLUME)) { #ifdef CONFIG_SUPPORT_VFAT if ((dentptr->attr & ATTR_VFAT) && - (dentptr->name[0] & 0x40)) { + (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) { prevcksum = ((dir_slot *) dentptr)->alias_checksum; - get_vfatname (mydata, 0, block, dentptr, l_name); + get_vfatname (mydata, 0, do_fat_read_block, dentptr, l_name); if (dols == LS_ROOT) { int isdir = (dentptr->attr & ATTR_DIR); char dirc; @@ -860,9 +866,11 @@ do_fat_read (const char *filename, void *buffer, unsigned long maxsize, int doit = 0; if (isdir) { - dirs++; dirc = '/'; - doit = 1; + if (s_name[0] != 0) { + dirs++; + doit = 1; + } } else { dirc = ' '; if (s_name[0] != 0) { @@ -960,7 +968,8 @@ file_fat_detectfs(void) printf("No current device\n"); return 1; } -#if (CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI) +#if (CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI) || \ + (CONFIG_COMMANDS & CFG_CMD_USB) || (CONFIG_MMC) printf("Interface: "); switch(cur_dev->if_type) { case IF_TYPE_IDE : printf("IDE"); break;