]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libblkid: improve handling of ISO files with partition tables
authorDaniel Drake <drake@endlessm.com>
Tue, 24 Sep 2019 09:46:16 +0000 (17:46 +0800)
committerDaniel Drake <drake@endlessm.com>
Wed, 25 Sep 2019 03:41:30 +0000 (11:41 +0800)
commit7ef86a08914427d6486734614d7d3bbed1f108fe
tree866a6dfbf511b117326b94167144f46ea1764bb7
parent775022bdd7b2bd91eb4833c8f72c5c79ee80fd61
libblkid: improve handling of ISO files with partition tables

The ISO format specifically leaves the first 32kb blank so that it
can be used for other purposes, such as adding a partition table.
This is commonly used (e.g. by Endless and Fedora installation media) to
have partition 0 starting at sector 0 as a mountable iso9660 filesystem,
followed by more partitions (e.g. an EFI system partition).
Such layouts can be easily created by tools such as xorriso.

When plugging in a USB disk flashed with this type of ISO, blkid presents
a somewhat confusing view of the block devices. Taking the example of
a 'sda' disk with two partitions:
 1. The "iso partition"
 2. An unformatted partition

In such a setup, before the changes here, blkid will currently report the
ISO metadata attributes ID_FS_PUBLISHER_ID, ID_FS_UUID, ID_FS_LABEL, and
ID_FS_TYPE=iso9660 on both sda *and* sda1.

Since sda2 is unformatted, it won't have any ID_FS_ attributes of it's
own. And due to the following standard udev rule:

  # for partitions import parent information
  ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"

sda2 will actually import all of the ID_FS_ stuff from the parent device
sda.

The result at this point is that three udev devices all have the same
ID_FS_ attribute values, leading to strange results such as three
devices all racing to own the link in /dev/disk/by-uuid, so you can't
reliably do a mount-by-UUID.

Clean up this situation by detecting such partitioned ISO disks
in the superblock probing setup. If files of this kind are detected,
we now only expose the ISO metadata attributes on the specific partition
that points to the ISO data (and not the parent disk).

Signed-off-by: Daniel Drake <drake@endlessm.com>
libblkid/src/superblocks/iso9660.c
tests/expected/blkid/iso-partitions-no_partitions [new file with mode: 0644]
tests/expected/blkid/iso-partitions-partitions [new file with mode: 0644]
tests/ts/blkid/iso-partitions [new file with mode: 0755]
tests/ts/blkid/iso-partitions.img.xz [new file with mode: 0644]