mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
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>
This commit is contained in:

committed by
Wolfgang Denk

parent
1e02c20ac9
commit
ac4977719e
@ -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 */
|
||||
|
Reference in New Issue
Block a user