summaryrefslogtreecommitdiffstats
path: root/libblkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2014-06-10 12:16:59 +0200
committerKarel Zak2014-06-10 12:16:59 +0200
commit20e1c3dc03399d6988ef35dedc1364cfc12e9263 (patch)
treea408b0e5509cefef16d8ef32b7affdd707f830bd /libblkid/src/probe.c
parenttests: fix fdisk/bsd for big endian systems (diff)
downloadkernel-qcow2-util-linux-20e1c3dc03399d6988ef35dedc1364cfc12e9263.tar.gz
kernel-qcow2-util-linux-20e1c3dc03399d6988ef35dedc1364cfc12e9263.tar.xz
kernel-qcow2-util-linux-20e1c3dc03399d6988ef35dedc1364cfc12e9263.zip
libblkid: ignore private LVM devices
The virtual private LVM devices do not contain any blkid relevant data and it does not make any sense to scan for superblocks or partitions on the devices, because we can interpret data from the devices in bad way. Unfortunately, for LVM has "private" very special meaning. The private LVM devices are accessible and readable (according to LVM guys it's feature, because debugging etc.). The problem is pretty visible with LVM thin provisioning where a virtual pool device contains segments from the top-level thin devices. Mountable top-level LVM-thin device: # blkid -o udev -p /dev/mapper/vg-thin1 ID_FS_UUID=57ed6490-903b-416c-91d2-6d06804ec60c ID_FS_TYPE=ext4 Virtual private LVM-pool device (contains data from all thin devices): # blkid -o udev -p /dev/mapper/vg-pool0 ID_FS_UUID=57ed6490-903b-416c-91d2-6d06804ec60c ID_FS_TYPE=ext4 ... this is incorrect, vg-pool0 is unmountable. LVM uses special UUID suffixes for private devices. All devices with uuid in format "LVM-<uuid>-<type>" are private. This patch modifies libblkid to not scan such devices. The high-level API ignores such devices at all now. The low-level API allows to assign the device to blkid_prober, but all scan functions always return nothing and library does not read anything from the device. The another functionality (get parental device, topology, sector sizes, etc.) still works as expected. The change affects only probing code. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1101345 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/probe.c')
-rw-r--r--libblkid/src/probe.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index 93035f93a..f2431dcf4 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -696,6 +696,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
if (!S_ISBLK(sb.st_mode) && !S_ISCHR(sb.st_mode) && !S_ISREG(sb.st_mode))
goto err;
+
pr->mode = sb.st_mode;
if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode))
pr->devno = sb.st_rdev;
@@ -724,8 +725,13 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
if (pr->size <= 1440 * 1024 && !S_ISCHR(sb.st_mode))
pr->flags |= BLKID_FL_TINY_DEV;
+ if (S_ISBLK(sb.st_mode) && blkid_lvm_private(sb.st_rdev)) {
+ DBG(LOWPROBE, ul_debug("ignore private LVM device"));
+ pr->flags |= BLKID_FL_NOSCAN_DEV;
+ }
+
#ifdef CDROM_GET_CAPABILITY
- if (S_ISBLK(sb.st_mode) &&
+ else if (S_ISBLK(sb.st_mode) &&
!blkid_probe_is_tiny(pr) &&
blkid_probe_is_wholedisk(pr) &&
ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0)
@@ -896,6 +902,9 @@ int blkid_do_probe(blkid_probe pr)
if (!pr)
return -1;
+ if (pr->flags & BLKID_FL_NOSCAN_DEV)
+ return 1;
+
do {
struct blkid_chain *chn = pr->cur_chain;
@@ -1147,6 +1156,8 @@ int blkid_do_safeprobe(blkid_probe pr)
if (!pr)
return -1;
+ if (pr->flags & BLKID_FL_NOSCAN_DEV)
+ return 1;
blkid_probe_start(pr);
@@ -1201,6 +1212,8 @@ int blkid_do_fullprobe(blkid_probe pr)
if (!pr)
return -1;
+ if (pr->flags & BLKID_FL_NOSCAN_DEV)
+ return 1;
blkid_probe_start(pr);