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 __attribute__ ((__aligned__(__alignof__(dir_entry))))
438 __u8 get_vfatname_block[MAX_CLUSTSIZE];
440 get_vfatname(fsdata *mydata, int curclust, __u8 *cluster,
441 dir_entry *retdent, char *l_name)
444 dir_slot *slotptr = (dir_slot*) retdent;
445 __u8 *nextclust = cluster + mydata->clust_size * SECTOR_SIZE;
446 __u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff;
449 while ((__u8*)slotptr < nextclust) {
450 if (counter == 0) break;
451 if (((slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff) != counter)
457 if ((__u8*)slotptr >= nextclust) {
461 curclust = get_fatent(mydata, curclust);
462 if (CHECK_CLUST(curclust, mydata->fatsize)) {
463 FAT_DPRINT("curclust: 0x%x\n", curclust);
464 FAT_ERROR("Invalid FAT entry\n");
467 if (get_cluster(mydata, curclust, get_vfatname_block,
468 mydata->clust_size * SECTOR_SIZE) != 0) {
469 FAT_DPRINT("Error: reading directory block\n");
472 slotptr2 = (dir_slot*) get_vfatname_block;
473 while (slotptr2->id > 0x01) {
476 /* Save the real directory entry */
477 realdent = (dir_entry*)slotptr2 + 1;
478 while ((__u8*)slotptr2 >= get_vfatname_block) {
479 slot2str(slotptr2, l_name, &idx);
483 /* Save the real directory entry */
484 realdent = (dir_entry*)slotptr;
489 if (slot2str(slotptr, l_name, &idx)) break;
490 } while (!(slotptr->id & LAST_LONG_ENTRY_MASK));
493 if (*l_name == DELETED_FLAG) *l_name = '\0';
494 else if (*l_name == aRING) *l_name = DELETED_FLAG;
497 /* Return the real directory entry */
498 memcpy(retdent, realdent, sizeof(dir_entry));
504 /* Calculate short name checksum */
506 mkcksum(const char *str)
511 for (i = 0; i < 11; i++) {
512 ret = (((ret&1)<<7)|((ret&0xfe)>>1)) + str[i];
521 * Get the directory entry associated with 'filename' from the directory
522 * starting at 'startsect'
524 __attribute__ ((__aligned__(__alignof__(dir_entry))))
525 __u8 get_dentfromdir_block[MAX_CLUSTSIZE];
526 static dir_entry *get_dentfromdir (fsdata * mydata, int startsect,
527 char *filename, dir_entry * retdent,
530 __u16 prevcksum = 0xffff;
531 __u32 curclust = START (retdent);
532 int files = 0, dirs = 0;
534 FAT_DPRINT ("get_dentfromdir: %s\n", filename);
539 if (get_cluster (mydata, curclust, get_dentfromdir_block,
540 mydata->clust_size * SECTOR_SIZE) != 0) {
541 FAT_DPRINT ("Error: reading directory block\n");
544 dentptr = (dir_entry *) get_dentfromdir_block;
545 for (i = 0; i < DIRENTSPERCLUST; i++) {
546 char s_name[14], l_name[256];
549 if (dentptr->name[0] == DELETED_FLAG) {
553 if ((dentptr->attr & ATTR_VOLUME)) {
554 #ifdef CONFIG_SUPPORT_VFAT
555 if ((dentptr->attr & ATTR_VFAT) &&
556 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
557 prevcksum = ((dir_slot *) dentptr)
559 get_vfatname (mydata, curclust, get_dentfromdir_block,
562 int isdir = (dentptr->attr & ATTR_DIR);
572 if (l_name[0] != 0) {
579 printf (" %8ld %s%c\n",
580 (long) FAT2CPU32 (dentptr->size),
583 printf (" %s%c\n", l_name, dirc);
589 FAT_DPRINT ("vfatname: |%s|\n", l_name);
593 /* Volume label or VFAT entry */
598 if (dentptr->name[0] == 0) {
600 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
602 FAT_DPRINT ("Dentname == NULL - %d\n", i);
605 #ifdef CONFIG_SUPPORT_VFAT
606 if (dols && mkcksum (dentptr->name) == prevcksum) {
611 get_name (dentptr, s_name);
613 int isdir = (dentptr->attr & ATTR_DIR);
623 if (s_name[0] != 0) {
630 printf (" %8ld %s%c\n",
631 (long) FAT2CPU32 (dentptr->size), s_name,
634 printf (" %s%c\n", s_name, dirc);
640 if (strcmp (filename, s_name) && strcmp (filename, l_name)) {
641 FAT_DPRINT ("Mismatch: |%s|%s|\n", s_name, l_name);
645 memcpy (retdent, dentptr, sizeof (dir_entry));
647 FAT_DPRINT ("DentName: %s", s_name);
648 FAT_DPRINT (", start: 0x%x", START (dentptr));
649 FAT_DPRINT (", size: 0x%x %s\n",
650 FAT2CPU32 (dentptr->size),
651 (dentptr->attr & ATTR_DIR) ? "(DIR)" : "");
655 curclust = get_fatent (mydata, curclust);
656 if (CHECK_CLUST(curclust, mydata->fatsize)) {
657 FAT_DPRINT ("curclust: 0x%x\n", curclust);
658 FAT_ERROR ("Invalid FAT entry\n");
668 * Read boot sector and volume info from a FAT filesystem
671 read_bootsectandvi(boot_sector *bs, volume_info *volinfo, int *fatsize)
673 __u8 block[FS_BLOCK_SIZE];
674 volume_info *vistart;
676 if (disk_read(0, 1, block) < 0) {
677 FAT_DPRINT("Error: reading block\n");
681 memcpy(bs, block, sizeof(boot_sector));
682 bs->reserved = FAT2CPU16(bs->reserved);
683 bs->fat_length = FAT2CPU16(bs->fat_length);
684 bs->secs_track = FAT2CPU16(bs->secs_track);
685 bs->heads = FAT2CPU16(bs->heads);
687 bs->hidden = FAT2CPU32(bs->hidden);
689 bs->total_sect = FAT2CPU32(bs->total_sect);
692 if (bs->fat_length == 0) {
694 bs->fat32_length = FAT2CPU32(bs->fat32_length);
695 bs->flags = FAT2CPU16(bs->flags);
696 bs->root_cluster = FAT2CPU32(bs->root_cluster);
697 bs->info_sector = FAT2CPU16(bs->info_sector);
698 bs->backup_boot = FAT2CPU16(bs->backup_boot);
699 vistart = (volume_info*) (block + sizeof(boot_sector));
702 vistart = (volume_info*) &(bs->fat32_length);
705 memcpy(volinfo, vistart, sizeof(volume_info));
707 /* Terminate fs_type string. Writing past the end of vistart
708 is ok - it's just the buffer. */
709 vistart->fs_type[8] = '\0';
711 if (*fatsize == 32) {
712 if (compare_sign(FAT32_SIGN, vistart->fs_type) == 0) {
716 if (compare_sign(FAT12_SIGN, vistart->fs_type) == 0) {
720 if (compare_sign(FAT16_SIGN, vistart->fs_type) == 0) {
726 FAT_DPRINT("Error: broken fs_type sign\n");
730 __attribute__ ((__aligned__(__alignof__(dir_entry))))
731 __u8 do_fat_read_block[MAX_CLUSTSIZE];
733 do_fat_read (const char *filename, void *buffer, unsigned long maxsize,
736 #if CONFIG_NIOS /* NIOS CPU cannot access big automatic arrays */
739 char fnamecopy[2048];
743 fsdata *mydata = &datablock;
745 __u16 prevcksum = 0xffff;
747 int rootdir_size, cursect;
749 int files = 0, dirs = 0;
753 if (read_bootsectandvi (&bs, &volinfo, &mydata->fatsize)) {
754 FAT_DPRINT ("Error: reading boot sector\n");
757 if (mydata->fatsize == 32) {
758 mydata->fatlength = bs.fat32_length;
760 mydata->fatlength = bs.fat_length;
762 mydata->fat_sect = bs.reserved;
763 cursect = mydata->rootdir_sect
764 = mydata->fat_sect + mydata->fatlength * bs.fats;
765 mydata->clust_size = bs.cluster_size;
766 if (mydata->fatsize == 32) {
767 rootdir_size = mydata->clust_size;
768 mydata->data_begin = mydata->rootdir_sect /* + rootdir_size */
769 - (mydata->clust_size * 2);
771 rootdir_size = ((bs.dir_entries[1] * (int) 256 + bs.dir_entries[0])
772 * sizeof (dir_entry)) / SECTOR_SIZE;
773 mydata->data_begin = mydata->rootdir_sect + rootdir_size
774 - (mydata->clust_size * 2);
776 mydata->fatbufnum = -1;
778 FAT_DPRINT ("FAT%d, fatlength: %d\n", mydata->fatsize,
780 FAT_DPRINT ("Rootdir begins at sector: %d, offset: %x, size: %d\n"
781 "Data begins at: %d\n",
782 mydata->rootdir_sect, mydata->rootdir_sect * SECTOR_SIZE,
783 rootdir_size, mydata->data_begin);
784 FAT_DPRINT ("Cluster size: %d\n", mydata->clust_size);
786 /* "cwd" is always the root... */
787 while (ISDIRDELIM (*filename))
789 /* Make a copy of the filename and convert it to lowercase */
790 strcpy (fnamecopy, filename);
791 downcase (fnamecopy);
792 if (*fnamecopy == '\0') {
796 } else if ((idx = dirdelim (fnamecopy)) >= 0) {
798 fnamecopy[idx] = '\0';
799 subname = fnamecopy + idx + 1;
800 /* Handle multiple delimiters */
801 while (ISDIRDELIM (*subname))
810 if (disk_read (cursect, mydata->clust_size, do_fat_read_block) < 0) {
811 FAT_DPRINT ("Error: reading rootdir block\n");
814 dentptr = (dir_entry *) do_fat_read_block;
815 for (i = 0; i < DIRENTSPERBLOCK; i++) {
816 char s_name[14], l_name[256];
819 if ((dentptr->attr & ATTR_VOLUME)) {
820 #ifdef CONFIG_SUPPORT_VFAT
821 if ((dentptr->attr & ATTR_VFAT) &&
822 (dentptr->name[0] & LAST_LONG_ENTRY_MASK)) {
823 prevcksum = ((dir_slot *) dentptr)->alias_checksum;
824 get_vfatname (mydata, 0, do_fat_read_block, dentptr, l_name);
825 if (dols == LS_ROOT) {
826 int isdir = (dentptr->attr & ATTR_DIR);
836 if (l_name[0] != 0) {
843 printf (" %8ld %s%c\n",
844 (long) FAT2CPU32 (dentptr->size),
847 printf (" %s%c\n", l_name, dirc);
853 FAT_DPRINT ("Rootvfatname: |%s|\n", l_name);
857 /* Volume label or VFAT entry */
861 } else if (dentptr->name[0] == 0) {
862 FAT_DPRINT ("RootDentname == NULL - %d\n", i);
863 if (dols == LS_ROOT) {
864 printf ("\n%d file(s), %d dir(s)\n\n", files, dirs);
869 #ifdef CONFIG_SUPPORT_VFAT
870 else if (dols == LS_ROOT
871 && mkcksum (dentptr->name) == prevcksum) {
876 get_name (dentptr, s_name);
877 if (dols == LS_ROOT) {
878 int isdir = (dentptr->attr & ATTR_DIR);
884 if (s_name[0] != 0) {
890 if (s_name[0] != 0) {
897 printf (" %8ld %s%c\n",
898 (long) FAT2CPU32 (dentptr->size), s_name,
901 printf (" %s%c\n", s_name, dirc);
907 if (strcmp (fnamecopy, s_name) && strcmp (fnamecopy, l_name)) {
908 FAT_DPRINT ("RootMismatch: |%s|%s|\n", s_name, l_name);
912 if (isdir && !(dentptr->attr & ATTR_DIR))
915 FAT_DPRINT ("RootName: %s", s_name);
916 FAT_DPRINT (", start: 0x%x", START (dentptr));
917 FAT_DPRINT (", size: 0x%x %s\n",
918 FAT2CPU32 (dentptr->size), isdir ? "(DIR)" : "");
920 goto rootdir_done; /* We got a match */
928 int startsect = mydata->data_begin
929 + START (dentptr) * mydata->clust_size;
931 char *nextname = NULL;
936 idx = dirdelim (subname);
939 nextname = subname + idx + 1;
940 /* Handle multiple delimiters */
941 while (ISDIRDELIM (*nextname))
943 if (dols && *nextname == '\0')
946 if (dols && firsttime) {
953 if (get_dentfromdir (mydata, startsect, subname, dentptr,
954 isdir ? 0 : dols) == NULL) {
961 if (!(dentptr->attr & ATTR_DIR))
966 ret = get_contents (mydata, dentptr, buffer, maxsize);
967 FAT_DPRINT ("Size: %d, got: %ld\n", FAT2CPU32 (dentptr->size), ret);
974 file_fat_detectfs(void)
982 printf("No current device\n");
985 #if defined(CONFIG_CMD_IDE) || \
986 defined(CONFIG_CMD_SATA) || \
987 defined(CONFIG_CMD_SCSI) || \
988 defined(CONFIG_CMD_USB) || \
990 printf("Interface: ");
991 switch(cur_dev->if_type) {
992 case IF_TYPE_IDE : printf("IDE"); break;
993 case IF_TYPE_SATA : printf("SATA"); break;
994 case IF_TYPE_SCSI : printf("SCSI"); break;
995 case IF_TYPE_ATAPI : printf("ATAPI"); break;
996 case IF_TYPE_USB : printf("USB"); break;
997 case IF_TYPE_DOC : printf("DOC"); break;
998 case IF_TYPE_MMC : printf("MMC"); break;
999 default : printf("Unknown");
1001 printf("\n Device %d: ",cur_dev->dev);
1004 if(read_bootsectandvi(&bs, &volinfo, &fatsize)) {
1005 printf("\nNo valid FAT fs found\n");
1008 memcpy (vol_label, volinfo.volume_label, 11);
1009 vol_label[11] = '\0';
1010 volinfo.fs_type[5]='\0';
1011 printf("Partition %d: Filesystem: %s \"%s\"\n"
1012 ,cur_part,volinfo.fs_type,vol_label);
1018 file_fat_ls(const char *dir)
1020 return do_fat_read(dir, NULL, 0, LS_YES);
1025 file_fat_read(const char *filename, void *buffer, unsigned long maxsize)
1027 printf("reading %s\n",filename);
1028 return do_fat_read(filename, buffer, maxsize, LS_NO);