]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: don't use CDROM_GET_CAPABILITY ioctl for DM devices
authorKarel Zak <kzak@redhat.com>
Wed, 12 Jul 2017 12:35:53 +0000 (14:35 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 12 Jul 2017 12:35:53 +0000 (14:35 +0200)
For some reason kernel commit e980f62353c697cbf0c4325e43df6e44399aeb64
add extra warning when the ioctl is used for DM devices. It seems we
can avoid this ioctl when the device has dm/uuid.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1469532
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/fdisk-list.c
include/sysfs.h
lib/sysfs.c
libblkid/src/probe.c
libblkid/src/verify.c

index 08732e95a0ca2be976cbe51a7b8d7f228c03ee8c..a46883d1874564ad798335fe33043df839d715ee 100644 (file)
@@ -334,7 +334,7 @@ char *next_proc_partition(FILE **f)
                if (devno <= 0)
                        continue;
 
-               if (sysfs_devno_is_lvm_private(devno) ||
+               if (sysfs_devno_is_lvm_private(devno, NULL) ||
                    sysfs_devno_is_wholedisk(devno) <= 0)
                        continue;
 
index 36d3cbd4f00f9565b98e1ba81f809c260ccd8d80..7e715ee8584e16bc3d14ece19d585a5fdbbf8298 100644 (file)
@@ -81,7 +81,7 @@ extern int sysfs_is_partition_dirent(DIR *dir, struct dirent *d,
 extern int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
             size_t len, dev_t *diskdevno);
 
-extern int sysfs_devno_is_lvm_private(dev_t devno);
+extern int sysfs_devno_is_lvm_private(dev_t devno, char **uuid);
 extern int sysfs_devno_is_wholedisk(dev_t devno);
 
 extern int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h,
index 68b43aaa33eb4a356819279d4ac3245d44433e40..e8125e511de1f9a67cc0d6f733b85a67fa42da5b 100644 (file)
@@ -833,31 +833,35 @@ err:
 }
 
 /*
- * Returns 1 if the device is private LVM device.
+ * Returns 1 if the device is private LVM device. The @uuid (if not NULL)
+ * returns DM device UUID, use free() to deallocate.
  */
-int sysfs_devno_is_lvm_private(dev_t devno)
+int sysfs_devno_is_lvm_private(dev_t devno, char **uuid)
 {
        struct sysfs_cxt cxt = UL_SYSFSCXT_EMPTY;
-       char *uuid = NULL;
+       char *id = NULL;
        int rc = 0;
 
        if (sysfs_init(&cxt, devno, NULL) != 0)
                return 0;
 
-       uuid = sysfs_strdup(&cxt, "dm/uuid");
+       id = sysfs_strdup(&cxt, "dm/uuid");
 
        /* Private LVM devices use "LVM-<uuid>-<name>" uuid format (important
         * is the "LVM" prefix and "-<name>" postfix).
         */
-       if (uuid && strncmp(uuid, "LVM-", 4) == 0) {
-               char *p = strrchr(uuid + 4, '-');
+       if (id && strncmp(id, "LVM-", 4) == 0) {
+               char *p = strrchr(id + 4, '-');
 
                if (p && *(p + 1))
                        rc = 1;
        }
 
        sysfs_deinit(&cxt);
-       free(uuid);
+       if (uuid)
+               *uuid = id;
+       else
+               free(id);
        return rc;
 }
 
index 9f56f528f71a00b9fae26a8a15c33cbd9d126b3c..21cd790e95d679f0189ff7083318e78c51889d22 100644 (file)
@@ -862,6 +862,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
 {
        struct stat sb;
        uint64_t devsiz = 0;
+       char *dm_uuid = NULL;
 
        blkid_reset_probe(pr);
        blkid_probe_reset_buffers(pr);
@@ -925,7 +926,8 @@ 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) && sysfs_devno_is_lvm_private(sb.st_rdev)) {
+       if (S_ISBLK(sb.st_mode) &&
+           sysfs_devno_is_lvm_private(sb.st_rdev, &dm_uuid)) {
                DBG(LOWPROBE, ul_debug("ignore private LVM device"));
                pr->flags |= BLKID_FL_NOSCAN_DEV;
        }
@@ -933,6 +935,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
 #ifdef CDROM_GET_CAPABILITY
        else if (S_ISBLK(sb.st_mode) &&
            !blkid_probe_is_tiny(pr) &&
+           !dm_uuid &&
            blkid_probe_is_wholedisk(pr) &&
            ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) {
 
@@ -940,6 +943,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
                cdrom_size_correction(pr);
        }
 #endif
+       free(dm_uuid);
 
        DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%"PRIu64", size=%"PRIu64"",
                                pr->off, pr->size));
index 412eb66ba856611c1abad82fe5ade242f741a5c4..d84894b108af1748fadd18aada8a3e465466b01d 100644 (file)
@@ -114,7 +114,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
                   (unsigned long)diff));
 #endif
 
-       if (sysfs_devno_is_lvm_private(st.st_rdev)) {
+       if (sysfs_devno_is_lvm_private(st.st_rdev, NULL)) {
                blkid_free_dev(dev);
                return NULL;
        }