[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Info-mtools] Incorrect assignment of partition type in mformat/mpar
Re: [Info-mtools] Incorrect assignment of partition type in mformat/mpartition
Fri, 17 Aug 2018 00:21:08 +0200
On Saturday 11 August 2018 17:48:03 Pali Rohár wrote:
> I found out that mformat and mpartition incorrectly assigns MBR
> partition type. This is because of following problems:
> 1) Begin and end location of partition in function setBeginEnd() is of
> type "signed" integer which start overflowing when hitting 1TB partition
> size. It should be "unsigned" type, it does not make sense to have
> negative value. Result is that 1TB partitions are marked as FAT12
> because "end-begin < 4096" is truth (end is negative number).
> 2) There is missing partition type for FAT32 (MBR ID 0x0C).
> 3) Detection expects that sector size is 512 bytes, which is not truth
> for new Native 4K disks with sector size of 4096 bytes.
> In attachment I'm sending a patch which fixes all these 3 problems.
> I created FAT32 image with mformat -F and then via fdisk verified that
> partition type is 0x0C.
I did here one mistake. Partition types 0x01, 0x04 and 0x06 depend on
number of sectors, and not on number of (mega)bytes -- as was written in
original comments. 0x04 is used for original FAT16 and 0x06 for BIGDOS
FAT16 (or big FAT12). So 0x04 is only for partitions which has less then
2^16 sectors (which is 32MB when disk sector size is 512b; this is where
original comment "<32M" comes from). Therefore sector size is not needed
in this function at all.
In attachment I'm sending fixed version of my previous patch
Description: Text Data
Description: PGP signature