Index: firmware/usbstack/usb_storage.c =================================================================== --- firmware/usbstack/usb_storage.c (revision 20080) +++ firmware/usbstack/usb_storage.c (working copy) @@ -283,6 +283,26 @@ 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 validate_mbr(unsigned char* mbr) +{ + int i; + unsigned char* p; + + for (i = 0; i < 4 ; i++) + { + p = mbr + 0x1be + i*0x10; + if ((*p != 0) && (*p != 0x80)) + *p = 0; + } +} +#endif + static bool check_disk_present(IF_MV_NONVOID(int volume)) { #ifdef USB_USE_RAMDISK @@ -985,7 +1005,13 @@ MIN(BUFFER_SIZE/SECTOR_SIZE, cur_cmd.count), cur_cmd.data[cur_cmd.data_select]); + +#ifdef TOSHIBA_GIGABEAT_S + if (cur_cmd.sector == 0) { + validate_mbr(cur_cmd.data[cur_cmd.data_select]); + } #endif +#endif send_and_read_next(); } break;