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,
31 #include <asm/byteorder.h>
35 * Convert a string to lowercase.
40 while (*str != '\0') {
46 static block_dev_desc_t *cur_dev = NULL;
47 static unsigned long part_offset = 0;
48 static int cur_part = 1;
50 #define DOS_PART_TBL_OFFSET 0x1be
51 #define DOS_PART_MAGIC_OFFSET 0x1fe
52 #define DOS_FS_TYPE_OFFSET 0x36
53 #define DOS_FS32_TYPE_OFFSET 0x52
55 int disk_read (__u32 startblock, __u32 getsize, __u8 * bufptr)
57 startblock += part_offset;
60 if (cur_dev->block_read) {
61 return cur_dev->block_read (cur_dev->dev
62 , startblock, getsize, (unsigned long *)bufptr);
69 fat_register_device(block_dev_desc_t *dev_desc, int part_no)
71 unsigned char buffer[SECTOR_SIZE];
72 disk_partition_t info;
74 if (!dev_desc->block_read)
77 /* check if we have a MBR (on floppies we have only a PBR) */
78 if (dev_desc->block_read (dev_desc->dev, 0, 1, (ulong *) buffer) != 1) {
79 printf ("** Can't read from device %d **\n", dev_desc->dev);
82 if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
83 buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
84 /* no signature found */
87 #if (defined(CONFIG_CMD_IDE) || \
88 defined(CONFIG_CMD_MG_DISK) || \
89 defined(CONFIG_CMD_SATA) || \
90 defined(CONFIG_CMD_SCSI) || \
91 defined(CONFIG_CMD_USB) || \
92 defined(CONFIG_MMC) || \
93 defined(CONFIG_SYSTEMACE) )
94 /* First we assume, there is a MBR */
95 if (!get_partition_info (dev_desc, part_no, &info)) {
96 part_offset = info.start;
98 } else if (strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET], "FAT", 3)==0 ||
99 strncmp((char *)&buffer[DOS_FS32_TYPE_OFFSET],"FAT32",5)==0) {
100 /* ok, we assume we are on a PBR only */
104 printf ("** Partition %d not valid on device %d **\n",
105 part_no, dev_desc->dev);
110 if ((strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET], "FAT", 3) == 0) ||
111 (strncmp((char *)&buffer[DOS_FS32_TYPE_OFFSET], "FAT32", 5) == 0)) {
112 /* ok, we assume we are on a PBR only */
115 info.start = part_offset;
117 /* FIXME we need to determine the start block of the
118 * partition where the DOS FS resides. This can be done
119 * by using the get_partition_info routine. For this
120 * purpose the libpart must be included.
131 * Get the first occurence of a directory delimiter ('/' or '\') in a string.
132 * Return index into string if found, -1 otherwise.
139 while (*str != '\0') {
140 if (ISDIRDELIM(*str)) return str - start;
147 * Extract zero terminated short name from a directory entry.
149 static void get_name (dir_entry *dirent, char *s_name)
153 memcpy (s_name, dirent->name, 8);
156 while (*ptr && *ptr != ' ')
158 if (dirent->ext[0] && dirent->ext[0] != ' ') {
161 memcpy (ptr, dirent->ext, 3);
163 while (*ptr && *ptr != ' ')
167 if (*s_name == DELETED_FLAG)
169 else if (*s_name == aRING)
170 *s_name = DELETED_FLAG;
175 * Get the entry at index 'entry' in a FAT (12/16/32) table.
176 * On failure 0x00 is returned.
179 get_fatent(fsdata *mydata, __u32 entry)
185 switch (mydata->fatsize) {
187 bufnum = entry / FAT32BUFSIZE;
188 offset = entry - bufnum * FAT32BUFSIZE;
191 bufnum = entry / FAT16BUFSIZE;
192 offset = entry - bufnum * FAT16BUFSIZE;
195 bufnum = entry / FAT12BUFSIZE;
196 offset = entry - bufnum * FAT12BUFSIZE;
200 /* Unsupported FAT size */
204 /* Read a new block of FAT entries into the cache. */
205 if (bufnum != mydata->fatbufnum) {
206 int getsize = FATBUFSIZE/FS_BLOCK_SIZE;
207 __u8 *bufptr = mydata->fatbuf;
208 __u32 fatlength = mydata->fatlength;
209 __u32 startblock = bufnum * FATBUFBLOCKS;
211 fatlength *= SECTOR_SIZE; /* We want it in bytes now */
212 startblock += mydata->fat_sect; /* Offset from start of disk */
214 if (getsize > fatlength) getsize = fatlength;
215 if (disk_read(startblock, getsize, bufptr) < 0) {
216 FAT_DPRINT("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 __u32 off16 = (offset*3)/4;
234 switch (offset & 0x3) {
236 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
240 val1 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
242 val2 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16+1]);
244 ret = (val2 << 4) | (val1 >> 12);
247 val1 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
249 val2 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16+1]);
251 ret = (val2 << 8) | (val1 >> 8);
254 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);;
255 ret = (ret & 0xfff0) >> 4;
263 FAT_DPRINT("ret: %d, offset: %d\n", ret, offset);
270 * Read at most 'size' bytes from the specified cluster into 'buffer'.
271 * Return 0 on success, -1 otherwise.
274 get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size)
280 startsect = mydata->data_begin + clustnum*mydata->clust_size;
282 startsect = mydata->rootdir_sect;
285 FAT_DPRINT("gc - clustnum: %d, startsect: %d\n", clustnum, startsect);
286 if (disk_read(startsect, size/FS_BLOCK_SIZE , buffer) < 0) {
287 FAT_DPRINT("Error reading data\n");
290 if(size % FS_BLOCK_SIZE) {
291 __u8 tmpbuf[FS_BLOCK_SIZE];
292 idx= size/FS_BLOCK_SIZE;
293 if (disk_read(startsect + idx, 1, tmpbuf) < 0) {
294 FAT_DPRINT("Error reading data\n");
297 buffer += idx*FS_BLOCK_SIZE;
299 memcpy(buffer, tmpbuf, size % FS_BLOCK_SIZE);
308 * Read at most 'maxsize' bytes from the file associated with 'dentptr'
310 * Return the number of bytes read or -1 on fatal errors.
313 get_contents(fsdata *mydata, dir_entry *dentptr, __u8 *buffer,
314 unsigned long maxsize)
316 unsigned long filesize = FAT2CPU32(dentptr->size), gotsize = 0;
317 unsigned int bytesperclust = mydata->clust_size * SECTOR_SIZE;
318 __u32 curclust = START(dentptr);
319 __u32 endclust, newclust;
320 unsigned long actsize;
322 FAT_DPRINT("Filesize: %ld bytes\n", filesize);
324 if (maxsize > 0 && filesize > maxsize) filesize = maxsize;
326 FAT_DPRINT("Reading: %ld bytes\n", filesize);
328 actsize=bytesperclust;
331 /* search for consecutive clusters */
332 while(actsize < filesize) {
333 newclust = get_fatent(mydata, endclust);
334 if((newclust -1)!=endclust)
336 if (CHECK_CLUST(newclust, mydata->fatsize)) {
337 FAT_DPRINT("curclust: 0x%x\n", newclust);
338 FAT_DPRINT("Invalid FAT entry\n");
342 actsize+= bytesperclust;
344 /* actsize >= file size */
345 actsize -= bytesperclust;
346 /* get remaining clusters */
347 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
348 FAT_ERROR("Error reading cluster\n");
351 /* get remaining bytes */
352 gotsize += (int)actsize;
356 if (get_cluster(mydata, endclust, buffer, (int)actsize) != 0) {
357 FAT_ERROR("Error reading cluster\n");
363 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
364 FAT_ERROR("Error reading cluster\n");
367 gotsize += (int)actsize;
370 curclust = get_fatent(mydata, endclust);
371 if (CHECK_CLUST(curclust, mydata->fatsize)) {
372 FAT_DPRINT("curclust: 0x%x\n", curclust);
373 FAT_ERROR("Invalid FAT entry\n");
376 actsize=bytesperclust;
382 #ifdef CONFIG_SUPPORT_VFAT
384 * Extract the file name information from 'slotptr' into 'l_name',
385 * starting at l_name[*idx].
386 * Return 1 if terminator (zero byte) is found, 0 otherwise.
389 slot2str(dir_slot *slotptr, char *l_name, int *idx)
393 for (j = 0; j <= 8; j += 2) {
394 l_name[*idx] = slotptr->name0_4[j];
395 if (l_name[*idx] == 0x00) return 1;
398 for (j = 0; j <= 10; j += 2) {
399 l_name[*idx] = slotptr->name5_10[j];
400 if (l_name[*idx] == 0x00) return 1;
403 for (j = 0; j <= 2; j += 2) {
404 l_name[*idx] = slotptr->name11_12[j];
405 if (l_name[*idx] == 0x00) return 1;
414 * Extract the full long filename starting at 'retdent' (which is really
415 * a slot) into 'l_name'. If successful also copy the real directory entry
417 * Return 0 on success, -1 otherwise.
419 __attribute__ ((__aligned__(__alignof__(dir_entry))))
420 __u8 get_vfatname_block[MAX_CLUSTSIZE];
422 get_vfatname(fsdata *mydata, int curclust, __u8 *cluster,
423 dir_entry *retdent, char *l_name)
426 dir_slot *slotptr = (dir_slot*) retdent;
427 __u8 *nextclust = cluster + mydata->clust_size * SECTOR_SIZE;
428 __u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff;
431 while ((__u8*)slotptr < nextclust) {
432 if (counter == 0) break;
433 if (((slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff) != counter)
439 if ((__u8*)slotptr >= nextclust) {
443 curclust = get_fatent(mydata, curclust);
444 if (CHECK_CLUST(curclust, mydata->fatsize)) {
445 FAT_DPRINT("curclust: 0x%x\n", curclust);
446 FAT_ERROR("Invalid FAT entry\n");
449 if (get_cluster(mydata, curclust, get_vfatname_block,
450 mydata->clust_size * SECTOR_SIZE) != 0) {
451 FAT_DPRINT("Error: reading directory block\n");
454 slotptr2 = (dir_slot*) get_vfatname_block;
455 while (slotptr2->id > 0x01) {
458 /* Save the real directory entry */
459 realdent = (dir_entry*)slotptr2 + 1;
460 while ((__u8*)slotptr2 >= get_vfatname_block) {
461 slot2str(slotptr2, l_name, &idx);
465 /* Save the real directory entry */
466 realdent = (dir_entry*)slotptr;
471 if (slot2str(slotptr, l_name, &idx)) break;
472 } while (!(slotptr->id & LAST_LONG_ENTRY_MASK));
475 if (*l_name == DELETED_FLAG) *l_name = '\0';
476 else if (*l_name == aRING) *l_name = DELETED_FLAG;
479 /* Return the real directory entry */
480 memcpy(retdent, realdent, sizeof(dir_entry));
486 /* Calculate short name checksum */
488 mkcksum(const char *str)
493 for (i = 0; i < 11; i++) {
494 ret = (((ret&1)<<7)|((ret&0xfe)>>1)) + str[i];
503 * Get the directory entry associated with 'filename' from the directory
504 * starting at 'startsect'
506 __attribute__ ((__aligned__(__alignof__(dir_entry))))
507 __u8 get_dentfromdir_block[MAX_CLUSTSIZE];
508 static dir_entry *get_dentfromdir (fsdata * mydata, int startsect,
509 char *filename, dir_entry * retdent,
512 __u16 prevcksum = 0xffff;
513 __u32 curclust = START (retdent);
514 int files = 0, dirs = 0;
516 FAT_DPRINT ("get_dentfromdir: %s\n", filename);
521 if (get_cluster (mydata, curclust, get_dentfromdir_block,
522 mydata->clust_size * SECTOR_SIZE) != 0) {
523 FAT_DPRINT ("Error: reading directory block\n");
526 dentptr = (dir_entry *) get_dentfromdir_block;
527 for (i = 0; i < DIRENTSPERCLUST; i++) {
528 char s_name[14], l_name[256];
531 if (dentptr->name[0] == DELETED_FLAG) {
535 if ((dentptr->attr & ATTR_VOLUME)) {
536 #ifdef CONFIG_SUPPORT_VFAT
537 if ((dentptr->attr & ATTR_VFAT) &&
538 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
539 prevcksum = ((dir_slot *) dentptr)
541 get_vfatname (mydata, curclust, get_dentfromdir_block,
544 int isdir = (dentptr->attr & ATTR_DIR);
554 if (l_name[0] != 0) {
561 printf (" %8ld %s%c\n",
562 (long) FAT2CPU32 (dentptr->size),
565 printf (" %s%c\n", l_name, dirc);
571 FAT_DPRINT ("vfatname: |%s|\n", l_name);
575 /* Volume label or VFAT entry */
580 if (dentptr->name[0] == 0) {
582 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
584 FAT_DPRINT ("Dentname == NULL - %d\n", i);
587 #ifdef CONFIG_SUPPORT_VFAT
588 if (dols && mkcksum (dentptr->name) == prevcksum) {
593 get_name (dentptr, s_name);
595 int isdir = (dentptr->attr & ATTR_DIR);
605 if (s_name[0] != 0) {
612 printf (" %8ld %s%c\n",
613 (long) FAT2CPU32 (dentptr->size), s_name,
616 printf (" %s%c\n", s_name, dirc);
622 if (strcmp (filename, s_name) && strcmp (filename, l_name)) {
623 FAT_DPRINT ("Mismatch: |%s|%s|\n", s_name, l_name);
627 memcpy (retdent, dentptr, sizeof (dir_entry));
629 FAT_DPRINT ("DentName: %s", s_name);
630 FAT_DPRINT (", start: 0x%x", START (dentptr));
631 FAT_DPRINT (", size: 0x%x %s\n",
632 FAT2CPU32 (dentptr->size),
633 (dentptr->attr & ATTR_DIR) ? "(DIR)" : "");
637 curclust = get_fatent (mydata, curclust);
638 if (CHECK_CLUST(curclust, mydata->fatsize)) {
639 FAT_DPRINT ("curclust: 0x%x\n", curclust);
640 FAT_ERROR ("Invalid FAT entry\n");
650 * Read boot sector and volume info from a FAT filesystem
653 read_bootsectandvi(boot_sector *bs, volume_info *volinfo, int *fatsize)
655 __u8 block[FS_BLOCK_SIZE];
656 volume_info *vistart;
658 if (disk_read(0, 1, block) < 0) {
659 FAT_DPRINT("Error: reading block\n");
663 memcpy(bs, block, sizeof(boot_sector));
664 bs->reserved = FAT2CPU16(bs->reserved);
665 bs->fat_length = FAT2CPU16(bs->fat_length);
666 bs->secs_track = FAT2CPU16(bs->secs_track);
667 bs->heads = FAT2CPU16(bs->heads);
669 bs->hidden = FAT2CPU32(bs->hidden);
671 bs->total_sect = FAT2CPU32(bs->total_sect);
674 if (bs->fat_length == 0) {
676 bs->fat32_length = FAT2CPU32(bs->fat32_length);
677 bs->flags = FAT2CPU16(bs->flags);
678 bs->root_cluster = FAT2CPU32(bs->root_cluster);
679 bs->info_sector = FAT2CPU16(bs->info_sector);
680 bs->backup_boot = FAT2CPU16(bs->backup_boot);
681 vistart = (volume_info*) (block + sizeof(boot_sector));
684 vistart = (volume_info*) &(bs->fat32_length);
687 memcpy(volinfo, vistart, sizeof(volume_info));
689 if (*fatsize == 32) {
690 if (strncmp(FAT32_SIGN, vistart->fs_type, SIGNLEN) == 0) {
694 if (strncmp(FAT12_SIGN, vistart->fs_type, SIGNLEN) == 0) {
698 if (strncmp(FAT16_SIGN, vistart->fs_type, SIGNLEN) == 0) {
704 FAT_DPRINT("Error: broken fs_type sign\n");
708 __attribute__ ((__aligned__(__alignof__(dir_entry))))
709 __u8 do_fat_read_block[MAX_CLUSTSIZE];
711 do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
714 char fnamecopy[2048];
718 fsdata *mydata = &datablock;
720 __u16 prevcksum = 0xffff;
722 int rootdir_size, cursect;
724 int files = 0, dirs = 0;
728 if (read_bootsectandvi (&bs, &volinfo, &mydata->fatsize)) {
729 FAT_DPRINT ("Error: reading boot sector\n");
732 if (mydata->fatsize == 32) {
733 mydata->fatlength = bs.fat32_length;
735 mydata->fatlength = bs.fat_length;
737 mydata->fat_sect = bs.reserved;
738 cursect = mydata->rootdir_sect
739 = mydata->fat_sect + mydata->fatlength * bs.fats;
740 mydata->clust_size = bs.cluster_size;
741 if (mydata->fatsize == 32) {
742 rootdir_size = mydata->clust_size;
743 mydata->data_begin = mydata->rootdir_sect /* + rootdir_size */
744 - (mydata->clust_size * 2);
746 rootdir_size = ((bs.dir_entries[1] * (int) 256 + bs.dir_entries[0])
747 * sizeof (dir_entry)) / SECTOR_SIZE;
748 mydata->data_begin = mydata->rootdir_sect + rootdir_size
749 - (mydata->clust_size * 2);
751 mydata->fatbufnum = -1;
753 FAT_DPRINT ("FAT%d, fatlength: %d\n", mydata->fatsize,
755 FAT_DPRINT ("Rootdir begins at sector: %d, offset: %x, size: %d\n"
756 "Data begins at: %d\n",
757 mydata->rootdir_sect, mydata->rootdir_sect * SECTOR_SIZE,
758 rootdir_size, mydata->data_begin);
759 FAT_DPRINT ("Cluster size: %d\n", mydata->clust_size);
761 /* "cwd" is always the root... */
762 while (ISDIRDELIM (*filename))
764 /* Make a copy of the filename and convert it to lowercase */
765 strcpy (fnamecopy, filename);
766 downcase (fnamecopy);
767 if (*fnamecopy == '\0') {
771 } else if ((idx = dirdelim (fnamecopy)) >= 0) {
773 fnamecopy[idx] = '\0';
774 subname = fnamecopy + idx + 1;
775 /* Handle multiple delimiters */
776 while (ISDIRDELIM (*subname))
785 if (disk_read (cursect, mydata->clust_size, do_fat_read_block) < 0) {
786 FAT_DPRINT ("Error: reading rootdir block\n");
789 dentptr = (dir_entry *) do_fat_read_block;
790 for (i = 0; i < DIRENTSPERBLOCK; i++) {
791 char s_name[14], l_name[256];
794 if ((dentptr->attr & ATTR_VOLUME)) {
795 #ifdef CONFIG_SUPPORT_VFAT
796 if ((dentptr->attr & ATTR_VFAT) &&
797 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
798 prevcksum = ((dir_slot *) dentptr)->alias_checksum;
799 get_vfatname (mydata, 0, do_fat_read_block, dentptr, l_name);
800 if (dols == LS_ROOT) {
801 int isdir = (dentptr->attr & ATTR_DIR);
811 if (l_name[0] != 0) {
818 printf (" %8ld %s%c\n",
819 (long) FAT2CPU32 (dentptr->size),
822 printf (" %s%c\n", l_name, dirc);
828 FAT_DPRINT ("Rootvfatname: |%s|\n", l_name);
832 /* Volume label or VFAT entry */
836 } else if (dentptr->name[0] == 0) {
837 FAT_DPRINT ("RootDentname == NULL - %d\n", i);
838 if (dols == LS_ROOT) {
839 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
844 #ifdef CONFIG_SUPPORT_VFAT
845 else if (dols == LS_ROOT
846 && mkcksum (dentptr->name) == prevcksum) {
851 get_name (dentptr, s_name);
852 if (dols == LS_ROOT) {
853 int isdir = (dentptr->attr & ATTR_DIR);
859 if (s_name[0] != 0) {
865 if (s_name[0] != 0) {
872 printf (" %8ld %s%c\n",
873 (long) FAT2CPU32 (dentptr->size), s_name,
876 printf (" %s%c\n", s_name, dirc);
882 if (strcmp (fnamecopy, s_name) && strcmp (fnamecopy, l_name)) {
883 FAT_DPRINT ("RootMismatch: |%s|%s|\n", s_name, l_name);
887 if (isdir && !(dentptr->attr & ATTR_DIR))
890 FAT_DPRINT ("RootName: %s", s_name);
891 FAT_DPRINT (", start: 0x%x", START (dentptr));
892 FAT_DPRINT (", size: 0x%x %s\n",
893 FAT2CPU32 (dentptr->size), isdir ? "(DIR)" : "");
895 goto rootdir_done; /* We got a match */
903 int startsect = mydata->data_begin
904 + START (dentptr) * mydata->clust_size;
906 char *nextname = NULL;
911 idx = dirdelim (subname);
914 nextname = subname + idx + 1;
915 /* Handle multiple delimiters */
916 while (ISDIRDELIM (*nextname))
918 if (dols && *nextname == '\0')
921 if (dols && firsttime) {
928 if (get_dentfromdir (mydata, startsect, subname, dentptr,
929 isdir ? 0 : dols) == NULL) {
936 if (!(dentptr->attr & ATTR_DIR))
941 ret = get_contents (mydata, dentptr, buffer, maxsize);
942 FAT_DPRINT ("Size: %d, got: %ld\n", FAT2CPU32 (dentptr->size), ret);
949 file_fat_detectfs(void)
957 printf("No current device\n");
960 #if defined(CONFIG_CMD_IDE) || \
961 defined(CONFIG_CMD_MG_DISK) || \
962 defined(CONFIG_CMD_SATA) || \
963 defined(CONFIG_CMD_SCSI) || \
964 defined(CONFIG_CMD_USB) || \
966 printf("Interface: ");
967 switch(cur_dev->if_type) {
968 case IF_TYPE_IDE : printf("IDE"); break;
969 case IF_TYPE_SATA : printf("SATA"); break;
970 case IF_TYPE_SCSI : printf("SCSI"); break;
971 case IF_TYPE_ATAPI : printf("ATAPI"); break;
972 case IF_TYPE_USB : printf("USB"); break;
973 case IF_TYPE_DOC : printf("DOC"); break;
974 case IF_TYPE_MMC : printf("MMC"); break;
975 default : printf("Unknown");
977 printf("\n Device %d: ",cur_dev->dev);
980 if(read_bootsectandvi(&bs, &volinfo, &fatsize)) {
981 printf("\nNo valid FAT fs found\n");
984 memcpy (vol_label, volinfo.volume_label, 11);
985 vol_label[11] = '\0';
986 volinfo.fs_type[5]='\0';
987 printf("Partition %d: Filesystem: %s \"%s\"\n"
988 ,cur_part,volinfo.fs_type,vol_label);
994 file_fat_ls(const char *dir)
996 return do_fat_read(dir, NULL, 0, LS_YES);
1001 file_fat_read(const char *filename, void *buffer, unsigned long maxsize)
1003 printf("reading %s\n",filename);
1004 return do_fat_read(filename, buffer, maxsize, LS_NO);