diff options
| author | Dave Chapman <dave@dchapman.com> | 2009-02-22 18:25:16 +0000 |
|---|---|---|
| committer | Dave Chapman <dave@dchapman.com> | 2009-02-22 18:25:16 +0000 |
| commit | dff46d20e6c495a345d4756f72ee65bf971c2726 (patch) | |
| tree | f340cff309828214175f8b46d4a49a7cdf397a8a /firmware/usbstack/usb_storage.c | |
| parent | 8dc70840d362ae0d3a2fe3086df60d6726896e47 (diff) | |
| download | rockbox-dff46d20e6c495a345d4756f72ee65bf971c2726.zip rockbox-dff46d20e6c495a345d4756f72ee65bf971c2726.tar.gz rockbox-dff46d20e6c495a345d4756f72ee65bf971c2726.tar.bz2 rockbox-dff46d20e6c495a345d4756f72ee65bf971c2726.tar.xz | |
Commit my patch from FS#9940 - fix the invalid active flags in the Gigabeat S MBR on the fly in the UMS driver. It is hypothosized that actually changing these on the disk will make the OF more likely to reformat the data partition during recovery - but that is not confirmed. So we play it safe.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20085 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack/usb_storage.c')
| -rw-r--r-- | firmware/usbstack/usb_storage.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index 86b47cf..9be2d5d 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -283,6 +283,23 @@ static enum { SENDING_CSW } state = WAITING_FOR_COMMAND; +#ifdef TOSHIBA_GIGABEAT_S + +/* The Gigabeat S factory partition table contains invalid values for the + "active" flag in the MBR. This prevents at least the Linux kernel from + accepting the partition table, so we fix it on-the-fly. */ + +static void fix_mbr(unsigned char* mbr) +{ + unsigned char* p = mbr + 0x1be; + + p[0x00] &= 0x80; + p[0x10] &= 0x80; + p[0x20] &= 0x80; + p[0x30] &= 0x80; +} +#endif + static bool check_disk_present(IF_MV_NONVOID(int volume)) { #ifdef USB_USE_RAMDISK @@ -985,6 +1002,12 @@ static void handle_scsi(struct command_block_wrapper* cbw) MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), cur_cmd.data[cur_cmd.data_select]); + +#ifdef TOSHIBA_GIGABEAT_S + if (cur_cmd.sector == 0) { + fix_mbr(cur_cmd.data[cur_cmd.data_select]); + } +#endif #endif send_and_read_next(); } |