Handle the case where blkid(8) detects both a filesystem and a partition table
authorDavid Zeuthen <davidz@redhat.com>
Tue, 25 Oct 2011 20:42:09 +0000 (16:42 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Tue, 25 Oct 2011 20:42:09 +0000 (16:42 -0400)
commit6cf7e7c87cbe7695ca4e4cd261f20262625367fe
treec5fb15862c1a4c389bbeffd581188965c1275c13
parentcf40c75ad33cc41bccc1e54b7433a2552a7e08ce
Handle the case where blkid(8) detects both a filesystem and a partition table

The F15 x86_64 live cd is both an ISO filesystem and a partition
table, presumably on purpose:

 # blkid -o udev -p ~davidz/Downloads/Fedora-15-x86_64-Live-Desktop.iso
 ID_FS_LABEL=Fedora-15-x86_64-Live-Desktop.is
 ID_FS_LABEL_ENC=Fedora-15-x86_64-Live-Desktop.is
 ID_FS_TYPE=iso9660
 ID_FS_USAGE=filesystem
 ID_PART_TABLE_TYPE=dos

If just used on an optical disc this presents no problem per se
because the kernel does not create partitions. However, if you dd the
image to a USB stick, the kernel will in fact recognize the partition
table and create a partition for it:

 # blkid -o udev -p /dev/sdb
 ID_FS_LABEL=Fedora-15-x86_64-Live-Desktop.is
 ID_FS_LABEL_ENC=Fedora-15-x86_64-Live-Desktop.is
 ID_FS_TYPE=iso9660
 ID_FS_USAGE=filesystem
 ID_PART_TABLE_TYPE=dos

 # blkid -o udev -p /dev/sdb1
 ID_FS_LABEL=Fedora-15-x86_64-Live-Desktop.is
 ID_FS_LABEL_ENC=Fedora-15-x86_64-Live-Desktop.is
 ID_FS_TYPE=iso9660
 ID_FS_USAGE=filesystem
 ID_PART_TABLE_TYPE=dos
 ID_PART_ENTRY_SCHEME=dos
 ID_PART_ENTRY_TYPE=0x17
 ID_PART_ENTRY_FLAGS=0x80
 ID_PART_ENTRY_NUMBER=1
 ID_PART_ENTRY_OFFSET=0
 ID_PART_ENTRY_SIZE=1161216
 ID_PART_ENTRY_DISK=8:16

There is nothing, per se, wrong with this ... except that applications
(such as udisks and GNOME sitting on top) need to be careful and not
e.g. offer *two icons* for the iso9660 filesystem (one for sdb and one
for sdb1).

The fix is fortunately simple - we only allow a 'disk' block device to
be a PartitionTable or a Filesystem and not both at the same time. The
way we do this is to look at whether the kernel has already
partitioned the device or not (and this works only because the kernel
partiitoner guarantees that partition kobjects are created prior to
announcing the 'disk' block device).

Also stress in the docs that applications shouldn't be looking at
IdUsage or IdType (a direct copy of whatever blkid(8) puts in the udev
database) and that they instead should be looking at what D-Bus
interfaces are implemented.

Signed-off-by: David Zeuthen <davidz@redhat.com>
data/org.freedesktop.UDisks2.xml
src/udiskslinuxblockobject.c