]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: add sysfs_devno_is_lvm_private() from libblkid
authorKarel Zak <kzak@redhat.com>
Tue, 17 Jun 2014 09:20:32 +0000 (11:20 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 17 Jun 2014 09:20:32 +0000 (11:20 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/sysfs.h
lib/sysfs.c
libblkid/src/blkidP.h
libblkid/src/devno.c
libblkid/src/probe.c
libblkid/src/verify.c

index 739f9de127090b416e943093c4d1b3495833255a..2b77bf6daba2cb087c74afd6dbbaf545ced66522 100644 (file)
@@ -73,6 +73,8 @@ 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_scsi_get_hctl(struct sysfs_cxt *cxt, int *h,
                               int *c, int *t, int *l);
 extern char *sysfs_scsi_host_strdup_attribute(struct sysfs_cxt *cxt,
index b51a4ff26db6de6a11fb03bd34f99791b4237ace..fe85f34cfec778f3737688f3932e9f2fcab3d203 100644 (file)
@@ -629,6 +629,34 @@ err:
     return -1;
 }
 
+/*
+ * Returns 1 if the device is private LVM device.
+ */
+int sysfs_devno_is_lvm_private(dev_t devno)
+{
+       struct sysfs_cxt cxt = UL_SYSFSCXT_EMPTY;
+       char *uuid = NULL;
+       int rc = 0;
+
+       if (sysfs_init(&cxt, devno, NULL) != 0)
+               return 0;
+
+       uuid = 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 (p && *(p + 1))
+                       rc = 1;
+       }
+
+       sysfs_deinit(&cxt);
+       free(uuid);
+       return rc;
+}
 
 int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h, int *c, int *t, int *l)
 {
index 538a368b532057c537f42f764d19b848813db9ae..05d81e0d33dbf44eb39aa611243fbbdef083e314 100644 (file)
@@ -348,7 +348,6 @@ extern void blkid__scan_dir(char *, dev_t, struct dir_list **, char **)
                        __attribute__((nonnull(1,4)));
 extern int blkid_driver_has_major(const char *drvname, int major)
                        __attribute__((warn_unused_result));
-extern int blkid_lvm_private(dev_t devno);
 
 /* lseek.c */
 extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence);
index de65dd4b403f87487e75e9311bb4d519aaef471e..f4a36e4f566e5ca2be76eef80414011e86607966 100644 (file)
@@ -326,35 +326,6 @@ int blkid_driver_has_major(const char *drvname, int major)
        return match;
 }
 
-/*
- * Returns 1 if the device is private LVM device.
- */
-int blkid_lvm_private(dev_t devno)
-{
-       struct sysfs_cxt cxt = UL_SYSFSCXT_EMPTY;
-       char *uuid = NULL;
-       int rc = 0;
-
-       if (sysfs_init(&cxt, devno, NULL) != 0)
-               return 0;
-
-       uuid = 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 (p && *(p + 1))
-                       rc = 1;
-       }
-
-       sysfs_deinit(&cxt);
-       free(uuid);
-       return rc;
-}
-
 #ifdef TEST_PROGRAM
 int main(int argc, char** argv)
 {
index f2431dcf4e68f16ad2ca80c1712f417904f36a5c..fbb07b1b7502e2635fda8a418ae5f3e823daf68a 100644 (file)
@@ -725,7 +725,7 @@ 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)) {
+       if (S_ISBLK(sb.st_mode) && sysfs_devno_is_lvm_private(sb.st_rdev)) {
                DBG(LOWPROBE, ul_debug("ignore private LVM device"));
                pr->flags |= BLKID_FL_NOSCAN_DEV;
        }
index b245daa014f96f4276b08abd953eeb428818f1ec..9dfdcc4fafb5391bca7757caed6d66258ac7bd16 100644 (file)
@@ -112,7 +112,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
                   (unsigned long)diff));
 #endif
 
-       if (blkid_lvm_private(st.st_rdev)) {
+       if (sysfs_devno_is_lvm_private(st.st_rdev)) {
                blkid_free_dev(dev);
                return NULL;
        }