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
54 int disk_read (__u32 startblock, __u32 getsize, __u8 * bufptr)
56 startblock += part_offset;
59 if (cur_dev->block_read) {
60 return cur_dev->block_read (cur_dev->dev
61 , startblock, getsize, (unsigned long *)bufptr);
68 fat_register_device(block_dev_desc_t *dev_desc, int part_no)
70 unsigned char buffer[SECTOR_SIZE];
71 disk_partition_t info;
73 if (!dev_desc->block_read)
76 /* check if we have a MBR (on floppies we have only a PBR) */
77 if (dev_desc->block_read (dev_desc->dev, 0, 1, (ulong *) buffer) != 1) {
78 printf ("** Can't read from device %d **\n", dev_desc->dev);
81 if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
82 buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
83 /* no signature found */
86 #if (defined(CONFIG_CMD_IDE) || \
87 defined(CONFIG_CMD_SATA) || \
88 defined(CONFIG_CMD_SCSI) || \
89 defined(CONFIG_CMD_USB) || \
90 defined(CONFIG_MMC) || \
91 defined(CONFIG_SYSTEMACE) )
92 /* First we assume, there is a MBR */
93 if (!get_partition_info (dev_desc, part_no, &info)) {
94 part_offset = info.start;
96 } else if (!strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET], "FAT", 3)) {
97 /* ok, we assume we are on a PBR only */
101 printf ("** Partition %d not valid on device %d **\n",
102 part_no, dev_desc->dev);
107 if (!strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET],"FAT",3)) {
108 /* ok, we assume we are on a PBR only */
111 info.start = part_offset;
113 /* FIXME we need to determine the start block of the
114 * partition where the DOS FS resides. This can be done
115 * by using the get_partition_info routine. For this
116 * purpose the libpart must be included.
127 * Get the first occurence of a directory delimiter ('/' or '\') in a string.
128 * Return index into string if found, -1 otherwise.
135 while (*str != '\0') {
136 if (ISDIRDELIM(*str)) return str - start;
144 * Match volume_info fs_type strings.
145 * Return 0 on match, -1 otherwise.
148 compare_sign(char *str1, char *str2)
150 char *end = str1+SIGNLEN;
152 while (str1 != end) {
153 if (*str1 != *str2) {
165 * Extract zero terminated short name from a directory entry.
167 static void get_name (dir_entry *dirent, char *s_name)
171 memcpy (s_name, dirent->name, 8);
174 while (*ptr && *ptr != ' ')
176 if (dirent->ext[0] && dirent->ext[0] != ' ') {
179 memcpy (ptr, dirent->ext, 3);
181 while (*ptr && *ptr != ' ')
185 if (*s_name == DELETED_FLAG)
187 else if (*s_name == aRING)
188 *s_name = DELETED_FLAG;
193 * Get the entry at index 'entry' in a FAT (12/16/32) table.
194 * On failure 0x00 is returned.
197 get_fatent(fsdata *mydata, __u32 entry)
203 switch (mydata->fatsize) {
205 bufnum = entry / FAT32BUFSIZE;
206 offset = entry - bufnum * FAT32BUFSIZE;
209 bufnum = entry / FAT16BUFSIZE;
210 offset = entry - bufnum * FAT16BUFSIZE;
213 bufnum = entry / FAT12BUFSIZE;
214 offset = entry - bufnum * FAT12BUFSIZE;
218 /* Unsupported FAT size */
222 /* Read a new block of FAT entries into the cache. */
223 if (bufnum != mydata->fatbufnum) {
224 int getsize = FATBUFSIZE/FS_BLOCK_SIZE;
225 __u8 *bufptr = mydata->fatbuf;
226 __u32 fatlength = mydata->fatlength;
227 __u32 startblock = bufnum * FATBUFBLOCKS;
229 fatlength *= SECTOR_SIZE; /* We want it in bytes now */
230 startblock += mydata->fat_sect; /* Offset from start of disk */
232 if (getsize > fatlength) getsize = fatlength;
233 if (disk_read(startblock, getsize, bufptr) < 0) {
234 FAT_DPRINT("Error reading FAT blocks\n");
237 mydata->fatbufnum = bufnum;
240 /* Get the actual entry from the table */
241 switch (mydata->fatsize) {
243 ret = FAT2CPU32(((__u32*)mydata->fatbuf)[offset]);
246 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[offset]);
249 __u32 off16 = (offset*3)/4;
252 switch (offset & 0x3) {
254 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
258 val1 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
260 val2 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16+1]);
262 ret = (val2 << 4) | (val1 >> 12);
265 val1 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
267 val2 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16+1]);
269 ret = (val2 << 8) | (val1 >> 8);
272 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);;
273 ret = (ret & 0xfff0) >> 4;
281 FAT_DPRINT("ret: %d, offset: %d\n", ret, offset);
288 * Read at most 'size' bytes from the specified cluster into 'buffer'.
289 * Return 0 on success, -1 otherwise.
292 get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size)
298 startsect = mydata->data_begin + clustnum*mydata->clust_size;
300 startsect = mydata->rootdir_sect;
303 FAT_DPRINT("gc - clustnum: %d, startsect: %d\n", clustnum, startsect);
304 if (disk_read(startsect, size/FS_BLOCK_SIZE , buffer) < 0) {
305 FAT_DPRINT("Error reading data\n");
308 if(size % FS_BLOCK_SIZE) {
309 __u8 tmpbuf[FS_BLOCK_SIZE];
310 idx= size/FS_BLOCK_SIZE;
311 if (disk_read(startsect + idx, 1, tmpbuf) < 0) {
312 FAT_DPRINT("Error reading data\n");
315 buffer += idx*FS_BLOCK_SIZE;
317 memcpy(buffer, tmpbuf, size % FS_BLOCK_SIZE);
326 * Read at most 'maxsize' bytes from the file associated with 'dentptr'
328 * Return the number of bytes read or -1 on fatal errors.
331 get_contents(fsdata *mydata, dir_entry *dentptr, __u8 *buffer,
332 unsigned long maxsize)
334 unsigned long filesize = FAT2CPU32(dentptr->size), gotsize = 0;
335 unsigned int bytesperclust = mydata->clust_size * SECTOR_SIZE;
336 __u32 curclust = START(dentptr);
337 __u32 endclust, newclust;
338 unsigned long actsize;
340 FAT_DPRINT("Filesize: %ld bytes\n", filesize);
342 if (maxsize > 0 && filesize > maxsize) filesize = maxsize;
344 FAT_DPRINT("Reading: %ld bytes\n", filesize);
346 actsize=bytesperclust;
349 /* search for consecutive clusters */
350 while(actsize < filesize) {
351 newclust = get_fatent(mydata, endclust);
352 if((newclust -1)!=endclust)
354 if (CHECK_CLUST(newclust, mydata->fatsize)) {
355 FAT_DPRINT("curclust: 0x%x\n", newclust);
356 FAT_DPRINT("Invalid FAT entry\n");
360 actsize+= bytesperclust;
362 /* actsize >= file size */
363 actsize -= bytesperclust;
364 /* get remaining clusters */
365 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
366 FAT_ERROR("Error reading cluster\n");
369 /* get remaining bytes */
370 gotsize += (int)actsize;
374 if (get_cluster(mydata, endclust, buffer, (int)actsize) != 0) {
375 FAT_ERROR("Error reading cluster\n");
381 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
382 FAT_ERROR("Error reading cluster\n");
385 gotsize += (int)actsize;
388 curclust = get_fatent(mydata, endclust);
389 if (CHECK_CLUST(curclust, mydata->fatsize)) {
390 FAT_DPRINT("curclust: 0x%x\n", curclust);
391 FAT_ERROR("Invalid FAT entry\n");
394 actsize=bytesperclust;
400 #ifdef CONFIG_SUPPORT_VFAT
402 * Extract the file name information from 'slotptr' into 'l_name',
403 * starting at l_name[*idx].
404 * Return 1 if terminator (zero byte) is found, 0 otherwise.
407 slot2str(dir_slot *slotptr, char *l_name, int *idx)
411 for (j = 0; j <= 8; j += 2) {
412 l_name[*idx] = slotptr->name0_4[j];
413 if (l_name[*idx] == 0x00) return 1;
416 for (j = 0; j <= 10; j += 2) {
417 l_name[*idx] = slotptr->name5_10[j];
418 if (l_name[*idx] == 0x00) return 1;
421 for (j = 0; j <= 2; j += 2) {
422 l_name[*idx] = slotptr->name11_12[j];
423 if (l_name[*idx] == 0x00) return 1;
432 * Extract the full long filename starting at 'retdent' (which is really
433 * a slot) into 'l_name'. If successful also copy the real directory entry
435 * Return 0 on success, -1 otherwise.
437 __u8 get_vfatname_block[MAX_CLUSTSIZE];
439 get_vfatname(fsdata *mydata, int curclust, __u8 *cluster,
440 dir_entry *retdent, char *l_name)
443 dir_slot *slotptr = (dir_slot*) retdent;
444 __u8 *nextclust = cluster + mydata->clust_size * SECTOR_SIZE;
445 __u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff;
448 while ((__u8*)slotptr < nextclust) {
449 if (counter == 0) break;
450 if (((slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff) != counter)
456 if ((__u8*)slotptr >= nextclust) {
460 curclust = get_fatent(mydata, curclust);
461 if (CHECK_CLUST(curclust, mydata->fatsize)) {
462 FAT_DPRINT("curclust: 0x%x\n", curclust);
463 FAT_ERROR("Invalid FAT entry\n");
466 if (get_cluster(mydata, curclust, get_vfatname_block,
467 mydata->clust_size * SECTOR_SIZE) != 0) {
468 FAT_DPRINT("Error: reading directory block\n");
471 slotptr2 = (dir_slot*) get_vfatname_block;
472 while (slotptr2->id > 0x01) {
475 /* Save the real directory entry */
476 realdent = (dir_entry*)slotptr2 + 1;
477 while ((__u8*)slotptr2 >= get_vfatname_block) {
478 slot2str(slotptr2, l_name, &idx);
482 /* Save the real directory entry */
483 realdent = (dir_entry*)slotptr;
488 if (slot2str(slotptr, l_name, &idx)) break;
489 } while (!(slotptr->id & LAST_LONG_ENTRY_MASK));
492 if (*l_name == DELETED_FLAG) *l_name = '\0';
493 else if (*l_name == aRING) *l_name = DELETED_FLAG;
496 /* Return the real directory entry */
497 memcpy(retdent, realdent, sizeof(dir_entry));
503 /* Calculate short name checksum */
505 mkcksum(const char *str)
510 for (i = 0; i < 11; i++) {
511 ret = (((ret&1)<<7)|((ret&0xfe)>>1)) + str[i];
520 * Get the directory entry associated with 'filename' from the directory
521 * starting at 'startsect'
523 __u8 get_dentfromdir_block[MAX_CLUSTSIZE];
524 static dir_entry *get_dentfromdir (fsdata * mydata, int startsect,
525 char *filename, dir_entry * retdent,
528 __u16 prevcksum = 0xffff;
529 __u32 curclust = START (retdent);
530 int files = 0, dirs = 0;
532 FAT_DPRINT ("get_dentfromdir: %s\n", filename);
537 if (get_cluster (mydata, curclust, get_dentfromdir_block,
538 mydata->clust_size * SECTOR_SIZE) != 0) {
539 FAT_DPRINT ("Error: reading directory block\n");
542 dentptr = (dir_entry *) get_dentfromdir_block;
543 for (i = 0; i < DIRENTSPERCLUST; i++) {
544 char s_name[14], l_name[256];
547 if (dentptr->name[0] == DELETED_FLAG) {
551 if ((dentptr->attr & ATTR_VOLUME)) {
552 #ifdef CONFIG_SUPPORT_VFAT
553 if ((dentptr->attr & ATTR_VFAT) &&
554 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
555 prevcksum = ((dir_slot *) dentptr)
557 get_vfatname (mydata, curclust, get_dentfromdir_block,
560 int isdir = (dentptr->attr & ATTR_DIR);
570 if (l_name[0] != 0) {
577 printf (" %8ld %s%c\n",
578 (long) FAT2CPU32 (dentptr->size),
581 printf (" %s%c\n", l_name, dirc);
587 FAT_DPRINT ("vfatname: |%s|\n", l_name);
591 /* Volume label or VFAT entry */
596 if (dentptr->name[0] == 0) {
598 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
600 FAT_DPRINT ("Dentname == NULL - %d\n", i);
603 #ifdef CONFIG_SUPPORT_VFAT
604 if (dols && mkcksum (dentptr->name) == prevcksum) {
609 get_name (dentptr, s_name);
611 int isdir = (dentptr->attr & ATTR_DIR);
621 if (s_name[0] != 0) {
628 printf (" %8ld %s%c\n",
629 (long) FAT2CPU32 (dentptr->size), s_name,
632 printf (" %s%c\n", s_name, dirc);
638 if (strcmp (filename, s_name) && strcmp (filename, l_name)) {
639 FAT_DPRINT ("Mismatch: |%s|%s|\n", s_name, l_name);
643 memcpy (retdent, dentptr, sizeof (dir_entry));
645 FAT_DPRINT ("DentName: %s", s_name);
646 FAT_DPRINT (", start: 0x%x", START (dentptr));
647 FAT_DPRINT (", size: 0x%x %s\n",
648 FAT2CPU32 (dentptr->size),
649 (dentptr->attr & ATTR_DIR) ? "(DIR)" : "");
653 curclust = get_fatent (mydata, curclust);
654 if (CHECK_CLUST(curclust, mydata->fatsize)) {
655 FAT_DPRINT ("curclust: 0x%x\n", curclust);
656 FAT_ERROR ("Invalid FAT entry\n");
666 * Read boot sector and volume info from a FAT filesystem
669 read_bootsectandvi(boot_sector *bs, volume_info *volinfo, int *fatsize)
671 __u8 block[FS_BLOCK_SIZE];
672 volume_info *vistart;
674 if (disk_read(0, 1, block) < 0) {
675 FAT_DPRINT("Error: reading block\n");
679 memcpy(bs, block, sizeof(boot_sector));
680 bs->reserved = FAT2CPU16(bs->reserved);
681 bs->fat_length = FAT2CPU16(bs->fat_length);
682 bs->secs_track = FAT2CPU16(bs->secs_track);
683 bs->heads = FAT2CPU16(bs->heads);
685 bs->hidden = FAT2CPU32(bs->hidden);
687 bs->total_sect = FAT2CPU32(bs->total_sect);
690 if (bs->fat_length == 0) {
692 bs->fat32_length = FAT2CPU32(bs->fat32_length);
693 bs->flags = FAT2CPU16(bs->flags);
694 bs->root_cluster = FAT2CPU32(bs->root_cluster);
695 bs->info_sector = FAT2CPU16(bs->info_sector);
696 bs->backup_boot = FAT2CPU16(bs->backup_boot);
697 vistart = (volume_info*) (block + sizeof(boot_sector));
700 vistart = (volume_info*) &(bs->fat32_length);
703 memcpy(volinfo, vistart, sizeof(volume_info));
705 /* Terminate fs_type string. Writing past the end of vistart
706 is ok - it's just the buffer. */
707 vistart->fs_type[8] = '\0';
709 if (*fatsize == 32) {
710 if (compare_sign(FAT32_SIGN, vistart->fs_type) == 0) {
714 if (compare_sign(FAT12_SIGN, vistart->fs_type) == 0) {
718 if (compare_sign(FAT16_SIGN, vistart->fs_type) == 0) {
724 FAT_DPRINT("Error: broken fs_type sign\n");
729 __u8 do_fat_read_block[MAX_CLUSTSIZE]; /* Block buffer */
731 do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
734 #if CONFIG_NIOS /* NIOS CPU cannot access big automatic arrays */
737 char fnamecopy[2048];
741 fsdata *mydata = &datablock;
743 __u16 prevcksum = 0xffff;
745 int rootdir_size, cursect;
747 int files = 0, dirs = 0;
751 if (read_bootsectandvi (&bs, &volinfo, &mydata->fatsize)) {
752 FAT_DPRINT ("Error: reading boot sector\n");
755 if (mydata->fatsize == 32) {
756 mydata->fatlength = bs.fat32_length;
758 mydata->fatlength = bs.fat_length;
760 mydata->fat_sect = bs.reserved;
761 cursect = mydata->rootdir_sect
762 = mydata->fat_sect + mydata->fatlength * bs.fats;
763 mydata->clust_size = bs.cluster_size;
764 if (mydata->fatsize == 32) {
765 rootdir_size = mydata->clust_size;
766 mydata->data_begin = mydata->rootdir_sect /* + rootdir_size */
767 - (mydata->clust_size * 2);
769 rootdir_size = ((bs.dir_entries[1] * (int) 256 + bs.dir_entries[0])
770 * sizeof (dir_entry)) / SECTOR_SIZE;
771 mydata->data_begin = mydata->rootdir_sect + rootdir_size
772 - (mydata->clust_size * 2);
774 mydata->fatbufnum = -1;
776 FAT_DPRINT ("FAT%d, fatlength: %d\n", mydata->fatsize,
778 FAT_DPRINT ("Rootdir begins at sector: %d, offset: %x, size: %d\n"
779 "Data begins at: %d\n",
780 mydata->rootdir_sect, mydata->rootdir_sect * SECTOR_SIZE,
781 rootdir_size, mydata->data_begin);
782 FAT_DPRINT ("Cluster size: %d\n", mydata->clust_size);
784 /* "cwd" is always the root... */
785 while (ISDIRDELIM (*filename))
787 /* Make a copy of the filename and convert it to lowercase */
788 strcpy (fnamecopy, filename);
789 downcase (fnamecopy);
790 if (*fnamecopy == '\0') {
794 } else if ((idx = dirdelim (fnamecopy)) >= 0) {
796 fnamecopy[idx] = '\0';
797 subname = fnamecopy + idx + 1;
798 /* Handle multiple delimiters */
799 while (ISDIRDELIM (*subname))
808 if (disk_read (cursect, mydata->clust_size, do_fat_read_block) < 0) {
809 FAT_DPRINT ("Error: reading rootdir block\n");
812 dentptr = (dir_entry *) do_fat_read_block;
813 for (i = 0; i < DIRENTSPERBLOCK; i++) {
814 char s_name[14], l_name[256];
817 if ((dentptr->attr & ATTR_VOLUME)) {
818 #ifdef CONFIG_SUPPORT_VFAT
819 if ((dentptr->attr & ATTR_VFAT) &&
820 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
821 prevcksum = ((dir_slot *) dentptr)->alias_checksum;
822 get_vfatname (mydata, 0, do_fat_read_block, dentptr, l_name);
823 if (dols == LS_ROOT) {
824 int isdir = (dentptr->attr & ATTR_DIR);
834 if (l_name[0] != 0) {
841 printf (" %8ld %s%c\n",
842 (long) FAT2CPU32 (dentptr->size),
845 printf (" %s%c\n", l_name, dirc);
851 FAT_DPRINT ("Rootvfatname: |%s|\n", l_name);
855 /* Volume label or VFAT entry */
859 } else if (dentptr->name[0] == 0) {
860 FAT_DPRINT ("RootDentname == NULL - %d\n", i);
861 if (dols == LS_ROOT) {
862 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
867 #ifdef CONFIG_SUPPORT_VFAT
868 else if (dols == LS_ROOT
869 && mkcksum (dentptr->name) == prevcksum) {
874 get_name (dentptr, s_name);
875 if (dols == LS_ROOT) {
876 int isdir = (dentptr->attr & ATTR_DIR);
882 if (s_name[0] != 0) {
888 if (s_name[0] != 0) {
895 printf (" %8ld %s%c\n",
896 (long) FAT2CPU32 (dentptr->size), s_name,
899 printf (" %s%c\n", s_name, dirc);
905 if (strcmp (fnamecopy, s_name) && strcmp (fnamecopy, l_name)) {
906 FAT_DPRINT ("RootMismatch: |%s|%s|\n", s_name, l_name);
910 if (isdir && !(dentptr->attr & ATTR_DIR))
913 FAT_DPRINT ("RootName: %s", s_name);
914 FAT_DPRINT (", start: 0x%x", START (dentptr));
915 FAT_DPRINT (", size: 0x%x %s\n",
916 FAT2CPU32 (dentptr->size), isdir ? "(DIR)" : "");
918 goto rootdir_done; /* We got a match */
926 int startsect = mydata->data_begin
927 + START (dentptr) * mydata->clust_size;
929 char *nextname = NULL;
934 idx = dirdelim (subname);
937 nextname = subname + idx + 1;
938 /* Handle multiple delimiters */
939 while (ISDIRDELIM (*nextname))
941 if (dols && *nextname == '\0')
944 if (dols && firsttime) {
951 if (get_dentfromdir (mydata, startsect, subname, dentptr,
952 isdir ? 0 : dols) == NULL) {
959 if (!(dentptr->attr & ATTR_DIR))
964 ret = get_contents (mydata, dentptr, buffer, maxsize);
965 FAT_DPRINT ("Size: %d, got: %ld\n", FAT2CPU32 (dentptr->size), ret);
972 file_fat_detectfs(void)
980 printf("No current device\n");
983 #if defined(CONFIG_CMD_IDE) || \
984 defined(CONFIG_CMD_SATA) || \
985 defined(CONFIG_CMD_SCSI) || \
986 defined(CONFIG_CMD_USB) || \
988 printf("Interface: ");
989 switch(cur_dev->if_type) {
990 case IF_TYPE_IDE : printf("IDE"); break;
991 case IF_TYPE_SATA : printf("SATA"); break;
992 case IF_TYPE_SCSI : printf("SCSI"); break;
993 case IF_TYPE_ATAPI : printf("ATAPI"); break;
994 case IF_TYPE_USB : printf("USB"); break;
995 case IF_TYPE_DOC : printf("DOC"); break;
996 case IF_TYPE_MMC : printf("MMC"); break;
997 default : printf("Unknown");
999 printf("\n Device %d: ",cur_dev->dev);
1002 if(read_bootsectandvi(&bs, &volinfo, &fatsize)) {
1003 printf("\nNo valid FAT fs found\n");
1006 memcpy (vol_label, volinfo.volume_label, 11);
1007 vol_label[11] = '\0';
1008 volinfo.fs_type[5]='\0';
1009 printf("Partition %d: Filesystem: %s \"%s\"\n"
1010 ,cur_part,volinfo.fs_type,vol_label);
1016 file_fat_ls(const char *dir)
1018 return do_fat_read(dir, NULL, 0, LS_YES);
1023 file_fat_read(const char *filename, void *buffer, unsigned long maxsize)
1025 printf("reading %s\n",filename);
1026 return do_fat_read(filename, buffer, maxsize, LS_NO);