]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: ignore private Stratis devices
authorTony Asleson <tasleson@redhat.com>
Thu, 8 Mar 2018 21:41:26 +0000 (15:41 -0600)
committerKarel Zak <kzak@redhat.com>
Fri, 9 Mar 2018 12:34:42 +0000 (13:34 +0100)
[kzak@redhat.com: - tiny coding style changes]

References: 20e1c3dc03399d6988ef35dedc1364cfc12e9263
Signed-off-by: Tony Asleson <tasleson@redhat.com>
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 a46883d1874564ad798335fe33043df839d715ee..dd498a37f82aeee5d70334fa73ffb7b418eb8d2a 100644 (file)
@@ -334,7 +334,7 @@ char *next_proc_partition(FILE **f)
                if (devno <= 0)
                        continue;
 
-               if (sysfs_devno_is_lvm_private(devno, NULL) ||
+               if (sysfs_devno_is_dm_private(devno, NULL) ||
                    sysfs_devno_is_wholedisk(devno) <= 0)
                        continue;
 
index 7e715ee8584e16bc3d14ece19d585a5fdbbf8298..9a72a2009c976a788e084efae571629031608b11 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, char **uuid);
+extern int sysfs_devno_is_dm_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 b1b67c59fef88adf86709bc693415f05b772ee3b..e5437f43a4ada7172ae1034413a60ae2ba3182e7 100644 (file)
@@ -844,10 +844,10 @@ err:
 }
 
 /*
- * Returns 1 if the device is private LVM device. The @uuid (if not NULL)
- * returns DM device UUID, use free() to deallocate.
+ * Returns 1 if the device is private device mapper device. The @uuid
+ * (if not NULL) returns DM device UUID, use free() to deallocate.
  */
-int sysfs_devno_is_lvm_private(dev_t devno, char **uuid)
+int sysfs_devno_is_dm_private(dev_t devno, char **uuid)
 {
        struct sysfs_cxt cxt = UL_SYSFSCXT_EMPTY;
        char *id = NULL;
@@ -857,15 +857,21 @@ int sysfs_devno_is_lvm_private(dev_t devno, char **uuid)
                return 0;
 
        id = sysfs_strdup(&cxt, "dm/uuid");
+       if (id) {
+               /* Private LVM devices use "LVM-<uuid>-<name>" uuid format (important
+                * is the "LVM" prefix and "-<name>" postfix).
+                */
+               if (strncmp(id, "LVM-", 4) == 0) {
+                       char *p = strrchr(id + 4, '-');
 
-       /* Private LVM devices use "LVM-<uuid>-<name>" uuid format (important
-        * is the "LVM" prefix and "-<name>" postfix).
-        */
-       if (id && strncmp(id, "LVM-", 4) == 0) {
-               char *p = strrchr(id + 4, '-');
+                       if (p && *(p + 1))
+                               rc = 1;
 
-               if (p && *(p + 1))
+               /* Private Stratis devices prefix the UUID with "stratis-1-private"
+                */
+               } else if (strncmp(id, "stratis-1-private", 17) == 0) {
                        rc = 1;
+               }
        }
 
        sysfs_deinit(&cxt);
index 74eaffd2b26017a6ee33a9bacaccbddafe969f73..647ae416ab0685464873b5a09b00a9042e5c821a 100644 (file)
@@ -923,8 +923,8 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
                pr->flags |= BLKID_FL_TINY_DEV;
 
        if (S_ISBLK(sb.st_mode) &&
-           sysfs_devno_is_lvm_private(sb.st_rdev, &dm_uuid)) {
-               DBG(LOWPROBE, ul_debug("ignore private LVM device"));
+           sysfs_devno_is_dm_private(sb.st_rdev, &dm_uuid)) {
+               DBG(LOWPROBE, ul_debug("ignore private device mapper device"));
                pr->flags |= BLKID_FL_NOSCAN_DEV;
        }
 
index d84894b108af1748fadd18aada8a3e465466b01d..7f44f5497c8e87fbc0cf4d95b83126de8f65f81c 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, NULL)) {
+       if (sysfs_devno_is_dm_private(st.st_rdev, NULL)) {
                blkid_free_dev(dev);
                return NULL;
        }