Closed blowfish64 closed 6 years ago
Am I correct to say that there are two main groups of changes:
But what if the first partition slot is just unused? Is such a disk really illegal?
I think I did my tests last year, with one of my thumb drives that had no partition table. But it has been so long that I forgot whether it really had no partition table. That thumb drive was erased various times after that, so I have no way to find out anymore.
The existing code just verifies whether all the 4 partition entries are valid for the disk, before deeming the disk as having a valid partition table. The criteria for a determining whether a partition is valid are as follows:
For this to not work, that means that either your 4 partition entries had 0s for partition types or non-zero start LBAs. Perhaps even a combination of both. If so, can we conclude that the errata is with not considering a partition type of 0x00 as invalid? But why should it only check the first partition?
Generally speaking, only Iomega ZIP disks have the partition records 1, 2 and 3 empty, and the actual partition resides in record 4.
To be more correct, the code should check if at least one partition is not invalid, but I have never come across a USB hard disk or thumb drive which had the first record empty (or, which is the same, a single partition in a record different than the first).
By reading the code, you can notice that the check against start LBA is only done for partition system ID different than 0x00 so the errata is indeed about not considering 0x00 partition type invalid, in this way the other function code always returns that there are 4 partitions, never executing the part of code where the partition records are missing and trying the whole disk.
I agree that checking only the first partition record is not perfectly the right thing, as maybe mispartitioned HDDs might have such a strange setup.
As for testing, I tried different USB thumb drives formatted by myself with mkdosfs both using the whole disk and by making a single partition via fdisk, in both cases I zero-filled the first sector to start anew, and the result was always the same: disks formatted using the whole disk were never mounted by either uLE and OPL, while partitioned disks always mounted at the first try.
You're right. It has to check that at least 1 partition is valid, for things to work. Please try using the latest commit (fbc39455), and let me know if it helps.
I always thought that Linux would allow you to have not all partition slots used. When we partition disks, we can see the device assignments (i.e. /dev/sda*). If you deleted a partition before, you could find something like /dev/sda1 and /dev/sda3, but not the deleted partition. But, I could be wrong because I have been going off memory. Linux isn't my main OS either.
Thanks for bringing this up BTW.
Just tried recompiling uLE and OPL with the new version of the module and the result is that they both do work as expected, mounting partitioned and unpartitioned disks flawlessly.
If you want, we can call it a day :)
Just a sidenote: actually you can even tell fdisk to create, for example, partitions in records 1 and 4, however Linux will still report them as /dev/sda1 and /dev/sda2. Logical partitions start from /dev/sda5, but that's another matter.
I see. Yes, perhaps that was what I saw (my PC was missing /dev/sda4).
If you have no further comments regarding this issue, we can close this. Personally, I think the change was acceptable and makes more sense than just leaving things be, even if it actually only happens when you use the GNU tools.
Once again, thanks.
The current version of USBHDFSD module does not mount unpartitioned disks, even if they are formatted as FAT16/FAT32 using the whole disk.
The file in question is
part_driver.c
: the fact is that the code to mount the whole disk is there, but due to howpart_getPartitionRecord
andpart_getPartitionTable
are written, it gets never executed.By making the following 3 changes to the file in question, the problem gets fixed and disks with both with and without a partition table get mounted correctly (tested by compiling uLaunchELF 4.43a)
/iop/usb/usbhdfsd/src/part_driver.c
Because of how it was written, the only way to mount the disk as a whole was to have a partition table indeed with one of the records specifying the whole disk.