summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2014-06-17 11:20:32 +0200
committerKarel Zak2014-06-17 11:20:32 +0200
commit39866431eef1329660a30567c6a8de0b60330115 (patch)
tree466c68fef21e11708218d2d15765b52410e06387
parentfindmnt: add --nocanonicalize to avoid realpath() (diff)
downloadkernel-qcow2-util-linux-39866431eef1329660a30567c6a8de0b60330115.tar.gz
kernel-qcow2-util-linux-39866431eef1329660a30567c6a8de0b60330115.tar.xz
kernel-qcow2-util-linux-39866431eef1329660a30567c6a8de0b60330115.zip
lib/sysfs: add sysfs_devno_is_lvm_private() from libblkid
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--include/sysfs.h2
-rw-r--r--lib/sysfs.c28
-rw-r--r--libblkid/src/blkidP.h1
-rw-r--r--libblkid/src/devno.c29
-rw-r--r--libblkid/src/probe.c2
-rw-r--r--libblkid/src/verify.c2
6 files changed, 32 insertions, 32 deletions
diff --git a/include/sysfs.h b/include/sysfs.h
index 739f9de12..2b77bf6da 100644
--- a/include/sysfs.h
+++ b/include/sysfs.h
@@ -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,
diff --git a/lib/sysfs.c b/lib/sysfs.c
index b51a4ff26..fe85f34cf 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -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)
{
diff --git a/libblkid/src/blkidP.h b/libblkid/src/blkidP.h
index 538a368b5..05d81e0d3 100644
--- a/libblkid/src/blkidP.h
+++ b/libblkid/src/blkidP.h
@@ -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);
diff --git a/libblkid/src/devno.c b/libblkid/src/devno.c
index de65dd4b4..f4a36e4f5 100644
--- a/libblkid/src/devno.c
+++ b/libblkid/src/devno.c
@@ -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)
{
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index f2431dcf4..fbb07b1b7 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -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;
}
diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c
index b245daa01..9dfdcc4fa 100644
--- a/libblkid/src/verify.c
+++ b/libblkid/src/verify.c
@@ -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;
}