diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2011-08-08 09:38:33 +0000 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-10-01 21:50:39 +0200 |
commit | ac4977719e157bcb3c45c70d9dd781164727530d (patch) | |
tree | cd0e324be681e5de909b1d8c82a5995cde6c6b26 /include | |
parent | 1e02c20ac925fbc527b8579e42f0a6bd610a0760 (diff) | |
download | u-boot-imx-ac4977719e157bcb3c45c70d9dd781164727530d.zip u-boot-imx-ac4977719e157bcb3c45c70d9dd781164727530d.tar.gz u-boot-imx-ac4977719e157bcb3c45c70d9dd781164727530d.tar.bz2 |
fat: fix crash with big sector size
Apple iPod nanos have sector sizes of 2 or 4 KiB, which crashes U-Boot when it
tries to read the boot sector into 512-byte buffer situated on stack. Make the
FAT code indifferent to the sector size.
Signed-off-by: Sergei Shtylyov <sshtylyov@mvista.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/fat.h | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/include/fat.h b/include/fat.h index afb2116..c2465d2 100644 --- a/include/fat.h +++ b/include/fat.h @@ -33,22 +33,15 @@ /* Maximum Long File Name length supported here is 128 UTF-16 code units */ #define VFAT_MAXLEN_BYTES 256 /* Maximum LFN buffer in bytes */ #define VFAT_MAXSEQ 9 /* Up to 9 of 13 2-byte UTF-16 entries */ -#define LINEAR_PREFETCH_SIZE (SECTOR_SIZE*2) /* Prefetch buffer size */ - -#define SECTOR_SIZE FS_BLOCK_SIZE - -#define FS_BLOCK_SIZE 512 - -#if FS_BLOCK_SIZE != SECTOR_SIZE -#error FS_BLOCK_SIZE != SECTOR_SIZE - This code needs to be fixed! -#endif +#define LINEAR_PREFETCH_SIZE (mydata->sect_size*2) /* Prefetch buffer size */ #define MAX_CLUSTSIZE 65536 -#define DIRENTSPERBLOCK (FS_BLOCK_SIZE/sizeof(dir_entry)) -#define DIRENTSPERCLUST ((mydata->clust_size*SECTOR_SIZE)/sizeof(dir_entry)) +#define DIRENTSPERBLOCK (mydata->sect_size / sizeof(dir_entry)) +#define DIRENTSPERCLUST ((mydata->clust_size * mydata->sect_size) / \ + sizeof(dir_entry)) #define FATBUFBLOCKS 6 -#define FATBUFSIZE (FS_BLOCK_SIZE*FATBUFBLOCKS) +#define FATBUFSIZE (mydata->sect_size * FATBUFBLOCKS) #define FAT12BUFSIZE ((FATBUFSIZE*2)/3) #define FAT16BUFSIZE (FATBUFSIZE/2) #define FAT32BUFSIZE (FATBUFSIZE/4) @@ -181,11 +174,12 @@ typedef struct dir_slot { * (see FAT32 accesses) */ typedef struct { - __u8 fatbuf[FATBUFSIZE]; /* Current FAT buffer */ + __u8 *fatbuf; /* Current FAT buffer */ int fatsize; /* Size of FAT in bits */ __u16 fatlength; /* Length of FAT in sectors */ __u16 fat_sect; /* Starting sector of the FAT */ __u16 rootdir_sect; /* Start sector of root directory */ + __u16 sect_size; /* Size of sectors in bytes */ __u16 clust_size; /* Size of clusters in sectors */ short data_begin; /* The sector of the first cluster, can be negative */ int fatbufnum; /* Used by get_fatent, init to -1 */ |