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>
34 #if defined(CONFIG_CMD_FAT)
37 * Convert a string to lowercase.
42 while (*str != '\0') {
48 static block_dev_desc_t *cur_dev = NULL;
49 static unsigned long part_offset = 0;
50 static int cur_part = 1;
52 #define DOS_PART_TBL_OFFSET 0x1be
53 #define DOS_PART_MAGIC_OFFSET 0x1fe
54 #define DOS_FS_TYPE_OFFSET 0x36
56 int disk_read (__u32 startblock, __u32 getsize, __u8 * bufptr)
58 startblock += part_offset;
61 if (cur_dev->block_read) {
62 return cur_dev->block_read (cur_dev->dev
63 , startblock, getsize, (unsigned long *)bufptr);
70 fat_register_device(block_dev_desc_t *dev_desc, int part_no)
72 unsigned char buffer[SECTOR_SIZE];
73 disk_partition_t info;
75 if (!dev_desc->block_read)
78 /* check if we have a MBR (on floppies we have only a PBR) */
79 if (dev_desc->block_read (dev_desc->dev, 0, 1, (ulong *) buffer) != 1) {
80 printf ("** Can't read from device %d **\n", dev_desc->dev);
83 if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
84 buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
85 /* no signature found */
88 if(!strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET],"FAT",3)) {
89 /* ok, we assume we are on a PBR only */
94 #if (defined(CONFIG_CMD_IDE) || \
95 defined(CONFIG_CMD_SCSI) || \
96 defined(CONFIG_CMD_USB) || \
97 (defined(CONFIG_MMC) && defined(CONFIG_LPC2292)) || \
98 defined(CONFIG_SYSTEMACE) )
99 /* First we assume, there is a MBR */
100 if (!get_partition_info (dev_desc, part_no, &info)) {
101 part_offset = info.start;
103 } else if (!strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET], "FAT", 3)) {
104 /* ok, we assume we are on a PBR only */
108 printf ("** Partition %d not valid on device %d **\n", part_no, dev_desc->dev);
112 if(!strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET],"FAT",3)) {
113 /* ok, we assume we are on a PBR only */
116 info.start = part_offset;
118 /* FIXME we need to determine the start block of the
119 * partition where the DOS FS resides. This can be done
120 * by using the get_partition_info routine. For this
121 * purpose the libpart must be included.
132 * Get the first occurence of a directory delimiter ('/' or '\') in a string.
133 * Return index into string if found, -1 otherwise.
140 while (*str != '\0') {
141 if (ISDIRDELIM(*str)) return str - start;
149 * Match volume_info fs_type strings.
150 * Return 0 on match, -1 otherwise.
153 compare_sign(char *str1, char *str2)
155 char *end = str1+SIGNLEN;
157 while (str1 != end) {
158 if (*str1 != *str2) {
170 * Extract zero terminated short name from a directory entry.
172 static void get_name (dir_entry *dirent, char *s_name)
176 memcpy (s_name, dirent->name, 8);
179 while (*ptr && *ptr != ' ')
181 if (dirent->ext[0] && dirent->ext[0] != ' ') {
184 memcpy (ptr, dirent->ext, 3);
186 while (*ptr && *ptr != ' ')
190 if (*s_name == DELETED_FLAG)
192 else if (*s_name == aRING)
198 * Get the entry at index 'entry' in a FAT (12/16/32) table.
199 * On failure 0x00 is returned.
202 get_fatent(fsdata *mydata, __u32 entry)
208 switch (mydata->fatsize) {
210 bufnum = entry / FAT32BUFSIZE;
211 offset = entry - bufnum * FAT32BUFSIZE;
214 bufnum = entry / FAT16BUFSIZE;
215 offset = entry - bufnum * FAT16BUFSIZE;
218 bufnum = entry / FAT12BUFSIZE;
219 offset = entry - bufnum * FAT12BUFSIZE;
223 /* Unsupported FAT size */
227 /* Read a new block of FAT entries into the cache. */
228 if (bufnum != mydata->fatbufnum) {
229 int getsize = FATBUFSIZE/FS_BLOCK_SIZE;
230 __u8 *bufptr = mydata->fatbuf;
231 __u32 fatlength = mydata->fatlength;
232 __u32 startblock = bufnum * FATBUFBLOCKS;
234 fatlength *= SECTOR_SIZE; /* We want it in bytes now */
235 startblock += mydata->fat_sect; /* Offset from start of disk */
237 if (getsize > fatlength) getsize = fatlength;
238 if (disk_read(startblock, getsize, bufptr) < 0) {
239 FAT_DPRINT("Error reading FAT blocks\n");
242 mydata->fatbufnum = bufnum;
245 /* Get the actual entry from the table */
246 switch (mydata->fatsize) {
248 ret = FAT2CPU32(((__u32*)mydata->fatbuf)[offset]);
251 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[offset]);
254 __u32 off16 = (offset*3)/4;
257 switch (offset & 0x3) {
259 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
263 val1 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
265 val2 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16+1]);
267 ret = (val2 << 4) | (val1 >> 12);
270 val1 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);
272 val2 = FAT2CPU16(((__u16*)mydata->fatbuf)[off16+1]);
274 ret = (val2 << 8) | (val1 >> 8);
277 ret = FAT2CPU16(((__u16*)mydata->fatbuf)[off16]);;
278 ret = (ret & 0xfff0) >> 4;
286 FAT_DPRINT("ret: %d, offset: %d\n", ret, offset);
293 * Read at most 'size' bytes from the specified cluster into 'buffer'.
294 * Return 0 on success, -1 otherwise.
297 get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size)
303 startsect = mydata->data_begin + clustnum*mydata->clust_size;
305 startsect = mydata->rootdir_sect;
308 FAT_DPRINT("gc - clustnum: %d, startsect: %d\n", clustnum, startsect);
309 if (disk_read(startsect, size/FS_BLOCK_SIZE , buffer) < 0) {
310 FAT_DPRINT("Error reading data\n");
313 if(size % FS_BLOCK_SIZE) {
314 __u8 tmpbuf[FS_BLOCK_SIZE];
315 idx= size/FS_BLOCK_SIZE;
316 if (disk_read(startsect + idx, 1, tmpbuf) < 0) {
317 FAT_DPRINT("Error reading data\n");
320 buffer += idx*FS_BLOCK_SIZE;
322 memcpy(buffer, tmpbuf, size % FS_BLOCK_SIZE);
331 * Read at most 'maxsize' bytes from the file associated with 'dentptr'
333 * Return the number of bytes read or -1 on fatal errors.
336 get_contents(fsdata *mydata, dir_entry *dentptr, __u8 *buffer,
337 unsigned long maxsize)
339 unsigned long filesize = FAT2CPU32(dentptr->size), gotsize = 0;
340 unsigned int bytesperclust = mydata->clust_size * SECTOR_SIZE;
341 __u32 curclust = START(dentptr);
342 __u32 endclust, newclust;
343 unsigned long actsize;
345 FAT_DPRINT("Filesize: %ld bytes\n", filesize);
347 if (maxsize > 0 && filesize > maxsize) filesize = maxsize;
349 FAT_DPRINT("Reading: %ld bytes\n", filesize);
351 actsize=bytesperclust;
354 /* search for consecutive clusters */
355 while(actsize < filesize) {
356 newclust = get_fatent(mydata, endclust);
357 if((newclust -1)!=endclust)
359 if (newclust <= 0x0001 || newclust >= 0xfff0) {
360 FAT_DPRINT("curclust: 0x%x\n", newclust);
361 FAT_DPRINT("Invalid FAT entry\n");
365 actsize+= bytesperclust;
367 /* actsize >= file size */
368 actsize -= bytesperclust;
369 /* get remaining clusters */
370 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
371 FAT_ERROR("Error reading cluster\n");
374 /* get remaining bytes */
375 gotsize += (int)actsize;
379 if (get_cluster(mydata, endclust, buffer, (int)actsize) != 0) {
380 FAT_ERROR("Error reading cluster\n");
386 if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
387 FAT_ERROR("Error reading cluster\n");
390 gotsize += (int)actsize;
393 curclust = get_fatent(mydata, endclust);
394 if (curclust <= 0x0001 || curclust >= 0xfff0) {
395 FAT_DPRINT("curclust: 0x%x\n", curclust);
396 FAT_ERROR("Invalid FAT entry\n");
399 actsize=bytesperclust;
405 #ifdef CONFIG_SUPPORT_VFAT
407 * Extract the file name information from 'slotptr' into 'l_name',
408 * starting at l_name[*idx].
409 * Return 1 if terminator (zero byte) is found, 0 otherwise.
412 slot2str(dir_slot *slotptr, char *l_name, int *idx)
416 for (j = 0; j <= 8; j += 2) {
417 l_name[*idx] = slotptr->name0_4[j];
418 if (l_name[*idx] == 0x00) return 1;
421 for (j = 0; j <= 10; j += 2) {
422 l_name[*idx] = slotptr->name5_10[j];
423 if (l_name[*idx] == 0x00) return 1;
426 for (j = 0; j <= 2; j += 2) {
427 l_name[*idx] = slotptr->name11_12[j];
428 if (l_name[*idx] == 0x00) return 1;
437 * Extract the full long filename starting at 'retdent' (which is really
438 * a slot) into 'l_name'. If successful also copy the real directory entry
440 * Return 0 on success, -1 otherwise.
442 __u8 get_vfatname_block[MAX_CLUSTSIZE];
444 get_vfatname(fsdata *mydata, int curclust, __u8 *cluster,
445 dir_entry *retdent, char *l_name)
448 dir_slot *slotptr = (dir_slot*) retdent;
449 __u8 *nextclust = cluster + mydata->clust_size * SECTOR_SIZE;
450 __u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff;
453 while ((__u8*)slotptr < nextclust) {
454 if (counter == 0) break;
455 if (((slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff) != counter)
461 if ((__u8*)slotptr >= nextclust) {
465 curclust = get_fatent(mydata, curclust);
466 if (curclust <= 0x0001 || curclust >= 0xfff0) {
467 FAT_DPRINT("curclust: 0x%x\n", curclust);
468 FAT_ERROR("Invalid FAT entry\n");
471 if (get_cluster(mydata, curclust, get_vfatname_block,
472 mydata->clust_size * SECTOR_SIZE) != 0) {
473 FAT_DPRINT("Error: reading directory block\n");
476 slotptr2 = (dir_slot*) get_vfatname_block;
477 while (slotptr2->id > 0x01) {
480 /* Save the real directory entry */
481 realdent = (dir_entry*)slotptr2 + 1;
482 while ((__u8*)slotptr2 >= get_vfatname_block) {
483 slot2str(slotptr2, l_name, &idx);
487 /* Save the real directory entry */
488 realdent = (dir_entry*)slotptr;
493 if (slot2str(slotptr, l_name, &idx)) break;
494 } while (!(slotptr->id & LAST_LONG_ENTRY_MASK));
497 if (*l_name == DELETED_FLAG) *l_name = '\0';
498 else if (*l_name == aRING) *l_name = 'å';
501 /* Return the real directory entry */
502 memcpy(retdent, realdent, sizeof(dir_entry));
508 /* Calculate short name checksum */
510 mkcksum(const char *str)
515 for (i = 0; i < 11; i++) {
516 ret = (((ret&1)<<7)|((ret&0xfe)>>1)) + str[i];
525 * Get the directory entry associated with 'filename' from the directory
526 * starting at 'startsect'
528 __u8 get_dentfromdir_block[MAX_CLUSTSIZE];
529 static dir_entry *get_dentfromdir (fsdata * mydata, int startsect,
530 char *filename, dir_entry * retdent,
533 __u16 prevcksum = 0xffff;
534 __u32 curclust = START (retdent);
535 int files = 0, dirs = 0;
537 FAT_DPRINT ("get_dentfromdir: %s\n", filename);
542 if (get_cluster (mydata, curclust, get_dentfromdir_block,
543 mydata->clust_size * SECTOR_SIZE) != 0) {
544 FAT_DPRINT ("Error: reading directory block\n");
547 dentptr = (dir_entry *) get_dentfromdir_block;
548 for (i = 0; i < DIRENTSPERCLUST; i++) {
549 char s_name[14], l_name[256];
552 if (dentptr->name[0] == DELETED_FLAG) {
556 if ((dentptr->attr & ATTR_VOLUME)) {
557 #ifdef CONFIG_SUPPORT_VFAT
558 if ((dentptr->attr & ATTR_VFAT) &&
559 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
560 prevcksum = ((dir_slot *) dentptr)
562 get_vfatname (mydata, curclust, get_dentfromdir_block,
565 int isdir = (dentptr->attr & ATTR_DIR);
575 if (l_name[0] != 0) {
582 printf (" %8ld %s%c\n",
583 (long) FAT2CPU32 (dentptr->size),
586 printf (" %s%c\n", l_name, dirc);
592 FAT_DPRINT ("vfatname: |%s|\n", l_name);
596 /* Volume label or VFAT entry */
601 if (dentptr->name[0] == 0) {
603 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
605 FAT_DPRINT ("Dentname == NULL - %d\n", i);
608 #ifdef CONFIG_SUPPORT_VFAT
609 if (dols && mkcksum (dentptr->name) == prevcksum) {
614 get_name (dentptr, s_name);
616 int isdir = (dentptr->attr & ATTR_DIR);
626 if (s_name[0] != 0) {
633 printf (" %8ld %s%c\n",
634 (long) FAT2CPU32 (dentptr->size), s_name,
637 printf (" %s%c\n", s_name, dirc);
643 if (strcmp (filename, s_name) && strcmp (filename, l_name)) {
644 FAT_DPRINT ("Mismatch: |%s|%s|\n", s_name, l_name);
648 memcpy (retdent, dentptr, sizeof (dir_entry));
650 FAT_DPRINT ("DentName: %s", s_name);
651 FAT_DPRINT (", start: 0x%x", START (dentptr));
652 FAT_DPRINT (", size: 0x%x %s\n",
653 FAT2CPU32 (dentptr->size),
654 (dentptr->attr & ATTR_DIR) ? "(DIR)" : "");
658 curclust = get_fatent (mydata, curclust);
659 if (curclust <= 0x0001 || curclust >= 0xfff0) {
660 FAT_DPRINT ("curclust: 0x%x\n", curclust);
661 FAT_ERROR ("Invalid FAT entry\n");
671 * Read boot sector and volume info from a FAT filesystem
674 read_bootsectandvi(boot_sector *bs, volume_info *volinfo, int *fatsize)
676 __u8 block[FS_BLOCK_SIZE];
677 volume_info *vistart;
679 if (disk_read(0, 1, block) < 0) {
680 FAT_DPRINT("Error: reading block\n");
684 memcpy(bs, block, sizeof(boot_sector));
685 bs->reserved = FAT2CPU16(bs->reserved);
686 bs->fat_length = FAT2CPU16(bs->fat_length);
687 bs->secs_track = FAT2CPU16(bs->secs_track);
688 bs->heads = FAT2CPU16(bs->heads);
690 bs->hidden = FAT2CPU32(bs->hidden);
692 bs->total_sect = FAT2CPU32(bs->total_sect);
695 if (bs->fat_length == 0) {
697 bs->fat32_length = FAT2CPU32(bs->fat32_length);
698 bs->flags = FAT2CPU16(bs->flags);
699 bs->root_cluster = FAT2CPU32(bs->root_cluster);
700 bs->info_sector = FAT2CPU16(bs->info_sector);
701 bs->backup_boot = FAT2CPU16(bs->backup_boot);
702 vistart = (volume_info*) (block + sizeof(boot_sector));
705 vistart = (volume_info*) &(bs->fat32_length);
708 memcpy(volinfo, vistart, sizeof(volume_info));
710 /* Terminate fs_type string. Writing past the end of vistart
711 is ok - it's just the buffer. */
712 vistart->fs_type[8] = '\0';
714 if (*fatsize == 32) {
715 if (compare_sign(FAT32_SIGN, vistart->fs_type) == 0) {
719 if (compare_sign(FAT12_SIGN, vistart->fs_type) == 0) {
723 if (compare_sign(FAT16_SIGN, vistart->fs_type) == 0) {
729 FAT_DPRINT("Error: broken fs_type sign\n");
734 __u8 do_fat_read_block[MAX_CLUSTSIZE]; /* Block buffer */
736 do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
739 #if CONFIG_NIOS /* NIOS CPU cannot access big automatic arrays */
742 char fnamecopy[2048];
746 fsdata *mydata = &datablock;
748 __u16 prevcksum = 0xffff;
750 int rootdir_size, cursect;
752 int files = 0, dirs = 0;
756 if (read_bootsectandvi (&bs, &volinfo, &mydata->fatsize)) {
757 FAT_DPRINT ("Error: reading boot sector\n");
760 if (mydata->fatsize == 32) {
761 mydata->fatlength = bs.fat32_length;
763 mydata->fatlength = bs.fat_length;
765 mydata->fat_sect = bs.reserved;
766 cursect = mydata->rootdir_sect
767 = mydata->fat_sect + mydata->fatlength * bs.fats;
768 mydata->clust_size = bs.cluster_size;
769 if (mydata->fatsize == 32) {
770 rootdir_size = mydata->clust_size;
771 mydata->data_begin = mydata->rootdir_sect /* + rootdir_size */
772 - (mydata->clust_size * 2);
774 rootdir_size = ((bs.dir_entries[1] * (int) 256 + bs.dir_entries[0])
775 * sizeof (dir_entry)) / SECTOR_SIZE;
776 mydata->data_begin = mydata->rootdir_sect + rootdir_size
777 - (mydata->clust_size * 2);
779 mydata->fatbufnum = -1;
781 FAT_DPRINT ("FAT%d, fatlength: %d\n", mydata->fatsize,
783 FAT_DPRINT ("Rootdir begins at sector: %d, offset: %x, size: %d\n"
784 "Data begins at: %d\n",
785 mydata->rootdir_sect, mydata->rootdir_sect * SECTOR_SIZE,
786 rootdir_size, mydata->data_begin);
787 FAT_DPRINT ("Cluster size: %d\n", mydata->clust_size);
789 /* "cwd" is always the root... */
790 while (ISDIRDELIM (*filename))
792 /* Make a copy of the filename and convert it to lowercase */
793 strcpy (fnamecopy, filename);
794 downcase (fnamecopy);
795 if (*fnamecopy == '\0') {
799 } else if ((idx = dirdelim (fnamecopy)) >= 0) {
801 fnamecopy[idx] = '\0';
802 subname = fnamecopy + idx + 1;
803 /* Handle multiple delimiters */
804 while (ISDIRDELIM (*subname))
813 if (disk_read (cursect, mydata->clust_size, do_fat_read_block) < 0) {
814 FAT_DPRINT ("Error: reading rootdir block\n");
817 dentptr = (dir_entry *) do_fat_read_block;
818 for (i = 0; i < DIRENTSPERBLOCK; i++) {
819 char s_name[14], l_name[256];
822 if ((dentptr->attr & ATTR_VOLUME)) {
823 #ifdef CONFIG_SUPPORT_VFAT
824 if ((dentptr->attr & ATTR_VFAT) &&
825 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
826 prevcksum = ((dir_slot *) dentptr)->alias_checksum;
827 get_vfatname (mydata, 0, do_fat_read_block, dentptr, l_name);
828 if (dols == LS_ROOT) {
829 int isdir = (dentptr->attr & ATTR_DIR);
839 if (l_name[0] != 0) {
846 printf (" %8ld %s%c\n",
847 (long) FAT2CPU32 (dentptr->size),
850 printf (" %s%c\n", l_name, dirc);
856 FAT_DPRINT ("Rootvfatname: |%s|\n", l_name);
860 /* Volume label or VFAT entry */
864 } else if (dentptr->name[0] == 0) {
865 FAT_DPRINT ("RootDentname == NULL - %d\n", i);
866 if (dols == LS_ROOT) {
867 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
872 #ifdef CONFIG_SUPPORT_VFAT
873 else if (dols == LS_ROOT
874 && mkcksum (dentptr->name) == prevcksum) {
879 get_name (dentptr, s_name);
880 if (dols == LS_ROOT) {
881 int isdir = (dentptr->attr & ATTR_DIR);
887 if (s_name[0] != 0) {
893 if (s_name[0] != 0) {
900 printf (" %8ld %s%c\n",
901 (long) FAT2CPU32 (dentptr->size), s_name,
904 printf (" %s%c\n", s_name, dirc);
910 if (strcmp (fnamecopy, s_name) && strcmp (fnamecopy, l_name)) {
911 FAT_DPRINT ("RootMismatch: |%s|%s|\n", s_name, l_name);
915 if (isdir && !(dentptr->attr & ATTR_DIR))
918 FAT_DPRINT ("RootName: %s", s_name);
919 FAT_DPRINT (", start: 0x%x", START (dentptr));
920 FAT_DPRINT (", size: 0x%x %s\n",
921 FAT2CPU32 (dentptr->size), isdir ? "(DIR)" : "");
923 goto rootdir_done; /* We got a match */
931 int startsect = mydata->data_begin
932 + START (dentptr) * mydata->clust_size;
934 char *nextname = NULL;
939 idx = dirdelim (subname);
942 nextname = subname + idx + 1;
943 /* Handle multiple delimiters */
944 while (ISDIRDELIM (*nextname))
946 if (dols && *nextname == '\0')
949 if (dols && firsttime) {
956 if (get_dentfromdir (mydata, startsect, subname, dentptr,
957 isdir ? 0 : dols) == NULL) {
964 if (!(dentptr->attr & ATTR_DIR))
969 ret = get_contents (mydata, dentptr, buffer, maxsize);
970 FAT_DPRINT ("Size: %d, got: %ld\n", FAT2CPU32 (dentptr->size), ret);
977 file_fat_detectfs(void)
985 printf("No current device\n");
988 #if defined(CONFIG_CMD_IDE) || \
989 defined(CONFIG_CMD_SCSI) || \
990 defined(CONFIG_CMD_USB) || \
992 printf("Interface: ");
993 switch(cur_dev->if_type) {
994 case IF_TYPE_IDE : printf("IDE"); break;
995 case IF_TYPE_SCSI : printf("SCSI"); break;
996 case IF_TYPE_ATAPI : printf("ATAPI"); break;
997 case IF_TYPE_USB : printf("USB"); break;
998 case IF_TYPE_DOC : printf("DOC"); break;
999 case IF_TYPE_MMC : printf("MMC"); break;
1000 default : printf("Unknown");
1002 printf("\n Device %d: ",cur_dev->dev);
1005 if(read_bootsectandvi(&bs, &volinfo, &fatsize)) {
1006 printf("\nNo valid FAT fs found\n");
1009 memcpy (vol_label, volinfo.volume_label, 11);
1010 vol_label[11] = '\0';
1011 volinfo.fs_type[5]='\0';
1012 printf("Partition %d: Filesystem: %s \"%s\"\n"
1013 ,cur_part,volinfo.fs_type,vol_label);
1019 file_fat_ls(const char *dir)
1021 return do_fat_read(dir, NULL, 0, LS_YES);
1026 file_fat_read(const char *filename, void *buffer, unsigned long maxsize)
1028 printf("reading %s\n",filename);
1029 return do_fat_read(filename, buffer, maxsize, LS_NO);