4 * R/O (V)FAT 12/16/32 filesystem implementation by Marcus Sundberg
6 * 2002-07-28 - rjones@nexus-tech.net - ported to ppcboot v1.1.6
7 * 2003-03-10 - kharris@nexus-tech.net - ported to uboot
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #include <asm/byteorder.h>
36 * Convert a string to lowercase.
38 static void downcase (char *str)
40 while (*str != '\0') {
46 static block_dev_desc_t *cur_dev;
47 static unsigned int cur_part_nr;
48 static disk_partition_t cur_part_info;
50 #define DOS_BOOT_MAGIC_OFFSET 0x1fe
51 #define DOS_FS_TYPE_OFFSET 0x36
52 #define DOS_FS32_TYPE_OFFSET 0x52
54 static int disk_read(__u32 block, __u32 nr_blocks, void *buf)
56 if (!cur_dev || !cur_dev->block_read)
59 return cur_dev->block_read(cur_dev->dev,
60 cur_part_info.start + block, nr_blocks, buf);
63 int fat_register_device (block_dev_desc_t * dev_desc, int part_no)
65 unsigned char buffer[dev_desc->blksz];
67 /* First close any currently found FAT filesystem */
70 #if (defined(CONFIG_CMD_IDE) || \
71 defined(CONFIG_CMD_MG_DISK) || \
72 defined(CONFIG_CMD_SATA) || \
73 defined(CONFIG_CMD_SCSI) || \
74 defined(CONFIG_CMD_USB) || \
75 defined(CONFIG_MMC) || \
76 defined(CONFIG_SYSTEMACE) )
78 /* Read the partition table, if present */
79 if (!get_partition_info(dev_desc, part_no, &cur_part_info)) {
81 cur_part_nr = part_no;
85 /* Otherwise it might be a superfloppy (whole-disk FAT filesystem) */
88 printf("** Partition %d not valid on device %d **\n",
89 part_no, dev_desc->dev);
95 cur_part_info.start = 0;
96 cur_part_info.size = dev_desc->lba;
97 cur_part_info.blksz = dev_desc->blksz;
98 memset(cur_part_info.name, 0, sizeof(cur_part_info.name));
99 memset(cur_part_info.type, 0, sizeof(cur_part_info.type));
102 /* Make sure it has a valid FAT header */
103 if (disk_read(0, 1, buffer) != 1) {
108 /* Check if it's actually a DOS volume */
109 if (memcmp(buffer + DOS_BOOT_MAGIC_OFFSET, "\x55\xAA", 2)) {
114 /* Check for FAT12/FAT16/FAT32 filesystem */
115 if (!memcmp(buffer + DOS_FS_TYPE_OFFSET, "FAT", 3))
117 if (!memcmp(buffer + DOS_FS32_TYPE_OFFSET, "FAT32", 5))
126 * Get the first occurence of a directory delimiter ('/' or '\') in a string.
127 * Return index into string if found, -1 otherwise.
129 static int dirdelim (char *str)
133 while (*str != '\0') {
134 if (ISDIRDELIM(*str))
142 * Extract zero terminated short name from a directory entry.
144 static void get_name (dir_entry *dirent, char *s_name)
148 memcpy(s_name, dirent->name, 8);
151 while (*ptr && *ptr != ' ')
153 if (dirent->ext[0] && dirent->ext[0] != ' ') {
156 memcpy(ptr, dirent->ext, 3);
158 while (*ptr && *ptr != ' ')
162 if (*s_name == DELETED_FLAG)
164 else if (*s_name == aRING)
165 *s_name = DELETED_FLAG;
170 * Get the entry at index 'entry' in a FAT (12/16/32) table.
171 * On failure 0x00 is returned.
173 static __u32 get_fatent (fsdata *mydata, __u32 entry)
180 switch (mydata->fatsize) {
182 bufnum = entry / FAT32BUFSIZE;
183 offset = entry - bufnum * FAT32BUFSIZE;
186 bufnum = entry / FAT16BUFSIZE;
187 offset = entry - bufnum * FAT16BUFSIZE;
190 bufnum = entry / FAT12BUFSIZE;
191 offset = entry - bufnum * FAT12BUFSIZE;
195 /* Unsupported FAT size */
199 debug("FAT%d: entry: 0x%04x = %d, offset: 0x%04x = %d\n",
200 mydata->fatsize, entry, entry, offset, offset);
202 /* Read a new block of FAT entries into the cache. */
203 if (bufnum != mydata->fatbufnum) {
204 __u32 getsize = FATBUFBLOCKS;
205 __u8 *bufptr = mydata->fatbuf;
206 __u32 fatlength = mydata->fatlength;
207 __u32 startblock = bufnum * FATBUFBLOCKS;
209 if (getsize > fatlength)
212 fatlength *= mydata->sect_size; /* We want it in bytes now */
213 startblock += mydata->fat_sect; /* Offset from start of disk */
215 if (disk_read(startblock, getsize, bufptr) < 0) {
216 debug("Error reading FAT blocks\n");
219 mydata->fatbufnum = bufnum;
222 /* Get the actual entry from the table */
223 switch (mydata->fatsize) {
225 ret = FAT2CPU32(((__u32 *) mydata->fatbuf)[offset]);
228 ret = FAT2CPU16(((__u16 *) mydata->fatbuf)[offset]);
231 off16 = (offset * 3) / 4;
233 switch (offset & 0x3) {
235 ret = FAT2CPU16(((__u16 *) mydata->fatbuf)[off16]);
239 val1 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16]);
241 val2 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16 + 1]);
243 ret = (val2 << 4) | (val1 >> 12);
246 val1 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16]);
248 val2 = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16 + 1]);
250 ret = (val2 << 8) | (val1 >> 8);
253 ret = FAT2CPU16(((__u16 *)mydata->fatbuf)[off16]);
254 ret = (ret & 0xfff0) >> 4;
261 debug("FAT%d: ret: %08x, offset: %04x\n",
262 mydata->fatsize, ret, offset);
268 * Read at most 'size' bytes from the specified cluster into 'buffer'.
269 * Return 0 on success, -1 otherwise.
272 get_cluster (fsdata *mydata, __u32 clustnum, __u8 *buffer,
279 startsect = mydata->data_begin +
280 clustnum * mydata->clust_size;
282 startsect = mydata->rootdir_sect;
285 debug("gc - clustnum: %d, startsect: %d\n", clustnum, startsect);
287 if (disk_read(startsect, size / mydata->sect_size, buffer) < 0) {
288 debug("Error reading data\n");
291 if (size % mydata->sect_size) {
292 __u8 tmpbuf[mydata->sect_size];
294 idx = size / mydata->sect_size;
295 if (disk_read(startsect + idx, 1, tmpbuf) < 0) {
296 debug("Error reading data\n");
299 buffer += idx * mydata->sect_size;
301 memcpy(buffer, tmpbuf, size % mydata->sect_size);
309 * Read at most 'maxsize' bytes from the file associated with 'dentptr'
311 * Return the number of bytes read or -1 on fatal errors.
314 get_contents (fsdata *mydata, dir_entry *dentptr, __u8 *buffer,
315 unsigned long maxsize)
317 unsigned long filesize = FAT2CPU32(dentptr->size), gotsize = 0;
318 unsigned int bytesperclust = mydata->clust_size * mydata->sect_size;
319 __u32 curclust = START(dentptr);
320 __u32 endclust, newclust;
321 unsigned long actsize;
323 debug("Filesize: %ld bytes\n", filesize);
325 if (maxsize > 0 && filesize > maxsize)
328 debug("%ld bytes\n", filesize);
330 actsize = bytesperclust;
334 /* search for consecutive clusters */
335 while (actsize < filesize) {
336 newclust = get_fatent(mydata, endclust);
337 if ((newclust - 1) != endclust)
339 if (CHECK_CLUST(newclust, mydata->fatsize)) {
340 debug("curclust: 0x%x\n", newclust);
341 debug("Invalid FAT entry\n");
345 actsize += bytesperclust;
348 /* actsize >= file size */
349 actsize -= bytesperclust;
351 /* get remaining clusters */
352 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
353 printf("Error reading cluster\n");
357 /* get remaining bytes */
358 gotsize += (int)actsize;
362 if (get_cluster(mydata, endclust, buffer, (int)actsize) != 0) {
363 printf("Error reading cluster\n");
369 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
370 printf("Error reading cluster\n");
373 gotsize += (int)actsize;
377 curclust = get_fatent(mydata, endclust);
378 if (CHECK_CLUST(curclust, mydata->fatsize)) {
379 debug("curclust: 0x%x\n", curclust);
380 printf("Invalid FAT entry\n");
383 actsize = bytesperclust;
388 #ifdef CONFIG_SUPPORT_VFAT
390 * Extract the file name information from 'slotptr' into 'l_name',
391 * starting at l_name[*idx].
392 * Return 1 if terminator (zero byte) is found, 0 otherwise.
394 static int slot2str (dir_slot *slotptr, char *l_name, int *idx)
398 for (j = 0; j <= 8; j += 2) {
399 l_name[*idx] = slotptr->name0_4[j];
400 if (l_name[*idx] == 0x00)
404 for (j = 0; j <= 10; j += 2) {
405 l_name[*idx] = slotptr->name5_10[j];
406 if (l_name[*idx] == 0x00)
410 for (j = 0; j <= 2; j += 2) {
411 l_name[*idx] = slotptr->name11_12[j];
412 if (l_name[*idx] == 0x00)
421 * Extract the full long filename starting at 'retdent' (which is really
422 * a slot) into 'l_name'. If successful also copy the real directory entry
424 * Return 0 on success, -1 otherwise.
426 __attribute__ ((__aligned__ (__alignof__ (dir_entry))))
427 __u8 get_vfatname_block[MAX_CLUSTSIZE];
430 get_vfatname (fsdata *mydata, int curclust, __u8 *cluster,
431 dir_entry *retdent, char *l_name)
434 dir_slot *slotptr = (dir_slot *)retdent;
435 __u8 *buflimit = cluster + mydata->sect_size * ((curclust == 0) ?
438 __u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff;
441 if (counter > VFAT_MAXSEQ) {
442 debug("Error: VFAT name is too long\n");
446 while ((__u8 *)slotptr < buflimit) {
449 if (((slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff) != counter)
455 if ((__u8 *)slotptr >= buflimit) {
460 curclust = get_fatent(mydata, curclust);
461 if (CHECK_CLUST(curclust, mydata->fatsize)) {
462 debug("curclust: 0x%x\n", curclust);
463 printf("Invalid FAT entry\n");
467 if (get_cluster(mydata, curclust, get_vfatname_block,
468 mydata->clust_size * mydata->sect_size) != 0) {
469 debug("Error: reading directory block\n");
473 slotptr2 = (dir_slot *)get_vfatname_block;
474 while (counter > 0) {
475 if (((slotptr2->id & ~LAST_LONG_ENTRY_MASK)
482 /* Save the real directory entry */
483 realdent = (dir_entry *)slotptr2;
484 while ((__u8 *)slotptr2 > get_vfatname_block) {
486 slot2str(slotptr2, l_name, &idx);
489 /* Save the real directory entry */
490 realdent = (dir_entry *)slotptr;
495 if (slot2str(slotptr, l_name, &idx))
497 } while (!(slotptr->id & LAST_LONG_ENTRY_MASK));
500 if (*l_name == DELETED_FLAG)
502 else if (*l_name == aRING)
503 *l_name = DELETED_FLAG;
506 /* Return the real directory entry */
507 memcpy(retdent, realdent, sizeof(dir_entry));
512 /* Calculate short name checksum */
513 static __u8 mkcksum (const char *str)
519 for (i = 0; i < 11; i++) {
520 ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + str[i];
525 #endif /* CONFIG_SUPPORT_VFAT */
528 * Get the directory entry associated with 'filename' from the directory
529 * starting at 'startsect'
531 __attribute__ ((__aligned__ (__alignof__ (dir_entry))))
532 __u8 get_dentfromdir_block[MAX_CLUSTSIZE];
534 static dir_entry *get_dentfromdir (fsdata *mydata, int startsect,
535 char *filename, dir_entry *retdent,
538 __u16 prevcksum = 0xffff;
539 __u32 curclust = START(retdent);
540 int files = 0, dirs = 0;
542 debug("get_dentfromdir: %s\n", filename);
549 if (get_cluster(mydata, curclust, get_dentfromdir_block,
550 mydata->clust_size * mydata->sect_size) != 0) {
551 debug("Error: reading directory block\n");
555 dentptr = (dir_entry *)get_dentfromdir_block;
557 for (i = 0; i < DIRENTSPERCLUST; i++) {
558 char s_name[14], l_name[VFAT_MAXLEN_BYTES];
561 if (dentptr->name[0] == DELETED_FLAG) {
565 if ((dentptr->attr & ATTR_VOLUME)) {
566 #ifdef CONFIG_SUPPORT_VFAT
567 if ((dentptr->attr & ATTR_VFAT) == ATTR_VFAT &&
568 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
569 prevcksum = ((dir_slot *)dentptr)->alias_checksum;
570 get_vfatname(mydata, curclust,
571 get_dentfromdir_block,
578 isdir = (dentptr->attr & ATTR_DIR);
586 if (l_name[0] != 0) {
593 printf(" %8ld %s%c\n",
594 (long)FAT2CPU32(dentptr->size),
606 debug("vfatname: |%s|\n", l_name);
610 /* Volume label or VFAT entry */
615 if (dentptr->name[0] == 0) {
617 printf("\n%d file(s), %d dir(s)\n\n",
620 debug("Dentname == NULL - %d\n", i);
623 #ifdef CONFIG_SUPPORT_VFAT
624 if (dols && mkcksum(dentptr->name) == prevcksum) {
630 get_name(dentptr, s_name);
632 int isdir = (dentptr->attr & ATTR_DIR);
642 if (s_name[0] != 0) {
650 printf(" %8ld %s%c\n",
651 (long)FAT2CPU32(dentptr->size),
663 if (strcmp(filename, s_name)
664 && strcmp(filename, l_name)) {
665 debug("Mismatch: |%s|%s|\n", s_name, l_name);
670 memcpy(retdent, dentptr, sizeof(dir_entry));
672 debug("DentName: %s", s_name);
673 debug(", start: 0x%x", START(dentptr));
674 debug(", size: 0x%x %s\n",
675 FAT2CPU32(dentptr->size),
676 (dentptr->attr & ATTR_DIR) ? "(DIR)" : "");
681 curclust = get_fatent(mydata, curclust);
682 if (CHECK_CLUST(curclust, mydata->fatsize)) {
683 debug("curclust: 0x%x\n", curclust);
684 printf("Invalid FAT entry\n");
693 * Read boot sector and volume info from a FAT filesystem
696 read_bootsectandvi (boot_sector *bs, volume_info *volinfo, int *fatsize)
699 volume_info *vistart;
702 if (cur_dev == NULL) {
703 debug("Error: no device selected\n");
707 block = malloc(cur_dev->blksz);
709 debug("Error: allocating block\n");
713 if (disk_read (0, 1, block) < 0) {
714 debug("Error: reading block\n");
718 memcpy(bs, block, sizeof(boot_sector));
719 bs->reserved = FAT2CPU16(bs->reserved);
720 bs->fat_length = FAT2CPU16(bs->fat_length);
721 bs->secs_track = FAT2CPU16(bs->secs_track);
722 bs->heads = FAT2CPU16(bs->heads);
723 bs->total_sect = FAT2CPU32(bs->total_sect);
726 if (bs->fat_length == 0) {
728 bs->fat32_length = FAT2CPU32(bs->fat32_length);
729 bs->flags = FAT2CPU16(bs->flags);
730 bs->root_cluster = FAT2CPU32(bs->root_cluster);
731 bs->info_sector = FAT2CPU16(bs->info_sector);
732 bs->backup_boot = FAT2CPU16(bs->backup_boot);
733 vistart = (volume_info *)(block + sizeof(boot_sector));
736 vistart = (volume_info *)&(bs->fat32_length);
739 memcpy(volinfo, vistart, sizeof(volume_info));
741 if (*fatsize == 32) {
742 if (strncmp(FAT32_SIGN, vistart->fs_type, SIGNLEN) == 0)
745 if (strncmp(FAT12_SIGN, vistart->fs_type, SIGNLEN) == 0) {
749 if (strncmp(FAT16_SIGN, vistart->fs_type, SIGNLEN) == 0) {
755 debug("Error: broken fs_type sign\n");
763 __attribute__ ((__aligned__ (__alignof__ (dir_entry))))
764 __u8 do_fat_read_block[MAX_CLUSTSIZE];
767 do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
770 char fnamecopy[2048];
774 fsdata *mydata = &datablock;
776 __u16 prevcksum = 0xffff;
780 int files = 0, dirs = 0;
783 __u32 root_cluster = 0;
784 int rootdir_size = 0;
787 if (read_bootsectandvi(&bs, &volinfo, &mydata->fatsize)) {
788 debug("Error: reading boot sector\n");
792 if (mydata->fatsize == 32) {
793 root_cluster = bs.root_cluster;
794 mydata->fatlength = bs.fat32_length;
796 mydata->fatlength = bs.fat_length;
799 mydata->fat_sect = bs.reserved;
801 cursect = mydata->rootdir_sect
802 = mydata->fat_sect + mydata->fatlength * bs.fats;
804 mydata->sect_size = (bs.sector_size[1] << 8) + bs.sector_size[0];
805 mydata->clust_size = bs.cluster_size;
807 if (mydata->fatsize == 32) {
808 mydata->data_begin = mydata->rootdir_sect -
809 (mydata->clust_size * 2);
811 rootdir_size = ((bs.dir_entries[1] * (int)256 +
815 mydata->data_begin = mydata->rootdir_sect +
817 (mydata->clust_size * 2);
820 mydata->fatbufnum = -1;
821 mydata->fatbuf = malloc(FATBUFSIZE);
822 if (mydata->fatbuf == NULL) {
823 debug("Error: allocating memory\n");
827 #ifdef CONFIG_SUPPORT_VFAT
828 debug("VFAT Support enabled\n");
830 debug("FAT%d, fat_sect: %d, fatlength: %d\n",
831 mydata->fatsize, mydata->fat_sect, mydata->fatlength);
832 debug("Rootdir begins at cluster: %d, sector: %d, offset: %x\n"
833 "Data begins at: %d\n",
835 mydata->rootdir_sect,
836 mydata->rootdir_sect * mydata->sect_size, mydata->data_begin);
837 debug("Sector size: %d, cluster size: %d\n", mydata->sect_size,
840 /* "cwd" is always the root... */
841 while (ISDIRDELIM(*filename))
844 /* Make a copy of the filename and convert it to lowercase */
845 strcpy(fnamecopy, filename);
848 if (*fnamecopy == '\0') {
853 } else if ((idx = dirdelim(fnamecopy)) >= 0) {
855 fnamecopy[idx] = '\0';
856 subname = fnamecopy + idx + 1;
858 /* Handle multiple delimiters */
859 while (ISDIRDELIM(*subname))
869 debug("FAT read sect=%d, clust_size=%d, DIRENTSPERBLOCK=%zd\n",
870 cursect, mydata->clust_size, DIRENTSPERBLOCK);
872 if (disk_read(cursect,
873 (mydata->fatsize == 32) ?
874 (mydata->clust_size) :
876 do_fat_read_block) < 0) {
877 debug("Error: reading rootdir block\n");
881 dentptr = (dir_entry *) do_fat_read_block;
883 for (i = 0; i < DIRENTSPERBLOCK; i++) {
884 char s_name[14], l_name[VFAT_MAXLEN_BYTES];
887 if (dentptr->name[0] == DELETED_FLAG) {
891 if ((dentptr->attr & ATTR_VOLUME)) {
892 #ifdef CONFIG_SUPPORT_VFAT
893 if ((dentptr->attr & ATTR_VFAT) == ATTR_VFAT &&
894 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
896 ((dir_slot *)dentptr)->alias_checksum;
903 if (dols == LS_ROOT) {
907 (dentptr->attr & ATTR_DIR);
915 if (l_name[0] != 0) {
922 printf(" %8ld %s%c\n",
923 (long)FAT2CPU32(dentptr->size),
935 debug("Rootvfatname: |%s|\n",
940 /* Volume label or VFAT entry */
944 } else if (dentptr->name[0] == 0) {
945 debug("RootDentname == NULL - %d\n", i);
946 if (dols == LS_ROOT) {
947 printf("\n%d file(s), %d dir(s)\n\n",
953 #ifdef CONFIG_SUPPORT_VFAT
954 else if (dols == LS_ROOT &&
955 mkcksum(dentptr->name) == prevcksum) {
961 get_name(dentptr, s_name);
963 if (dols == LS_ROOT) {
964 int isdir = (dentptr->attr & ATTR_DIR);
970 if (s_name[0] != 0) {
976 if (s_name[0] != 0) {
983 printf(" %8ld %s%c\n",
984 (long)FAT2CPU32(dentptr->size),
995 if (strcmp(fnamecopy, s_name)
996 && strcmp(fnamecopy, l_name)) {
997 debug("RootMismatch: |%s|%s|\n", s_name,
1003 if (isdir && !(dentptr->attr & ATTR_DIR))
1006 debug("RootName: %s", s_name);
1007 debug(", start: 0x%x", START(dentptr));
1008 debug(", size: 0x%x %s\n",
1009 FAT2CPU32(dentptr->size),
1010 isdir ? "(DIR)" : "");
1012 goto rootdir_done; /* We got a match */
1014 debug("END LOOP: j=%d clust_size=%d\n", j,
1015 mydata->clust_size);
1018 * On FAT32 we must fetch the FAT entries for the next
1019 * root directory clusters when a cluster has been
1020 * completely processed.
1024 if ((mydata->fatsize == 32) && (j == mydata->clust_size)) {
1028 nxt_clust = get_fatent(mydata, root_cluster);
1029 fat32_end = CHECK_CLUST(nxt_clust, 32);
1031 nxtsect = mydata->data_begin +
1032 (nxt_clust * mydata->clust_size);
1034 root_cluster = nxt_clust;
1042 /* If end of rootdir reached */
1043 if ((mydata->fatsize == 32 && fat32_end) ||
1044 (mydata->fatsize != 32 && j == rootdir_size)) {
1045 if (dols == LS_ROOT) {
1046 printf("\n%d file(s), %d dir(s)\n\n",
1058 int startsect = mydata->data_begin
1059 + START(dentptr) * mydata->clust_size;
1061 char *nextname = NULL;
1066 idx = dirdelim(subname);
1069 subname[idx] = '\0';
1070 nextname = subname + idx + 1;
1071 /* Handle multiple delimiters */
1072 while (ISDIRDELIM(*nextname))
1074 if (dols && *nextname == '\0')
1077 if (dols && firsttime) {
1084 if (get_dentfromdir(mydata, startsect, subname, dentptr,
1085 isdir ? 0 : dols) == NULL) {
1092 if (!(dentptr->attr & ATTR_DIR))
1098 ret = get_contents(mydata, dentptr, buffer, maxsize);
1099 debug("Size: %d, got: %ld\n", FAT2CPU32(dentptr->size), ret);
1102 free(mydata->fatbuf);
1106 int file_fat_detectfs (void)
1109 volume_info volinfo;
1113 if (cur_dev == NULL) {
1114 printf("No current device\n");
1118 #if defined(CONFIG_CMD_IDE) || \
1119 defined(CONFIG_CMD_MG_DISK) || \
1120 defined(CONFIG_CMD_SATA) || \
1121 defined(CONFIG_CMD_SCSI) || \
1122 defined(CONFIG_CMD_USB) || \
1124 printf("Interface: ");
1125 switch (cur_dev->if_type) {
1151 printf("\n Device %d: ", cur_dev->dev);
1155 if (read_bootsectandvi(&bs, &volinfo, &fatsize)) {
1156 printf("\nNo valid FAT fs found\n");
1160 memcpy(vol_label, volinfo.volume_label, 11);
1161 vol_label[11] = '\0';
1162 volinfo.fs_type[5] = '\0';
1164 printf("Partition %d: Filesystem: %s \"%s\"\n", cur_part_nr,
1165 volinfo.fs_type, vol_label);
1170 int file_fat_ls (const char *dir)
1172 return do_fat_read(dir, NULL, 0, LS_YES);
1175 long file_fat_read (const char *filename, void *buffer, unsigned long maxsize)
1177 printf("reading %s\n", filename);
1178 return do_fat_read(filename, buffer, maxsize, LS_NO);