Skip to content

Detect GPT disk images also by magic

Currently, the default xdg shared mime info data detects GPT disk images by the very generic suffix "*.img" only (which the IANA registration suggests, actually, so isn't wrong).

In the wild there are various others suffixes in use however. For example in systemd context we typically use "*.raw". Hence it makes sense to tweak the detection and look for a magic header. This adds that.

The GPT partition table header is located at offset 1 (i.e. not 0) of the disk. And where that is as a byte offset depends on the sector sizes. The sector sizes used in the wild are 512 and 4096 for HDDs and 2048 for CDROMs. For good measure I also added a check for sector size 1024, to cover evreything from 2^9 to 2^12.

Merge request reports