Skip to contentSkip to conversation

FAT on non standard sector size devices

PATCH New Igor Luri 2 participants 2 messages Nov 12, 2008

lore
Share & tools
lore

Igor Luri

author
#0 lore raw

PATCH 1/1 FAT on non standard sector size devices

Hi all!

There are USB devices with sector size different than 512 bytes. In fact, I have one with 2048 bytes per sector:

scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: ChipsBnk Model: Flash Disk Rev: 4.00
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0 SCSI device sda: 129124 2048-byte hdwr sectors (264 MB)
sda: Write Protect is off
Partition check:
sda: sda1 sda2 sda3 sda4

U-boot FAT filesystem code supposes that sector size is always 512 bytes, consecuently fatload and fatls commands ends up with a segmentation fault.

Attached patches adds FAT support on devices with sector size up to 8192 bytes.

I have only tested on our custom board with u-boot 1.1.6 version. I would aprpeciate if someone could test this patch on latest version.

Thanks.

Signature · 23 lines
Igor Luri
R&D Software Department
Fagor Aotek S. Coop.
P. O. Box 144
E-20500 Mondrag?n-Arrasate
Tel.    ++34 943 71 92 00 
        ++34 943 71 92 01 (Ext. 44268)
Fax.    ++34 943 79 92 03
www.aotek.es
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-support-for-non-standard-sector-size-devices.patch
Type: application/mbox
Size: 6252 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20081112/a684ed52/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-support-for-non-standard-sector-size-devices.patch
Type: application/mbox
Size: 2053 bytes
Desc: not available
Url : http://lists.denx.de/pipermail/u-boot/attachments/20081112/a684ed52/attachment-0003.bin 
#1 lore raw

PATCH 1/1 FAT on non standard sector size devices

Hello Igor,

2008/11/12 Igor Luri <[email protected]>:

Quoted 14 lines

Hi all!

There are USB devices with sector size different than 512 bytes. In fact, I have one with 2048 bytes per sector:

scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: ChipsBnk Model: Flash Disk Rev: 4.00
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0 SCSI device sda: 129124 2048-byte hdwr sectors (264 MB)
sda: Write Protect is off
Partition check:
sda: sda1 sda2 sda3 sda4

Quoted 6 lines

U-boot FAT filesystem code supposes that sector size is always 512 bytes, consecuently fatload and fatls commands ends up with a segmentation fault.

Attached patches adds FAT support on devices with sector size up to 8192 bytes.

Please only sent patches inline, see http://lwn.net/Articles/139918/
for more info

Quoted 2 lines

I have only tested on our custom board with u-boot 1.1.6 version. I would aprpeciate if someone could test this patch on latest version.

I just looked at it (not tested it yet), and I have some comments:

Review

Quoted 3 lines
(quoted diff) +1 -1
-	unsigned char buffer[SECTOR_SIZE];
+	unsigned char buffer[8192];
 	disk_partition_t info;

Why hardcode this size to 8192, cant it be malloced somehow? Is there a check that detects if the size is getting bigger than 8192 to prevent segfaults?

Review static void get_name (dir_entry *dirent, char *s_name) · line 188

Quoted 7 lines

if (!dev_desc->block_read)

(quoted diff) +1 -1
@@ -184,7 +185,7 @@ static void get_name (dir_entry *dirent, char *s_name)
 	if (*s_name == DELETED_FLAG)
 		*s_name = '\0';
 	else if (*s_name == aRING)
-		*s_name = '?';
+		*s_name = '???';

Some weird characters here... Is this change what you want?

Kind Regards,

Remy