dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
b3c25a
diff -up util-linux-2.23.2/fdisks/fdisk.c.kzak util-linux-2.23.2/fdisks/fdisk.c
d2bdca
--- util-linux-2.23.2/fdisks/fdisk.c.kzak	2015-07-02 12:37:24.465906322 +0200
d2bdca
+++ util-linux-2.23.2/fdisks/fdisk.c	2015-07-02 12:37:57.870673753 +0200
b3c25a
@@ -34,6 +34,7 @@
b3c25a
 #include "canonicalize.h"
b3c25a
 #include "strutils.h"
b3c25a
 #include "closestream.h"
b3c25a
+#include "sysfs.h"
b3c25a
 
b3c25a
 #include "fdisksunlabel.h"
b3c25a
 #include "fdisksgilabel.h"
b3c25a
diff -up util-linux-2.23.2/include/sysfs.h.kzak util-linux-2.23.2/include/sysfs.h
d2bdca
--- util-linux-2.23.2/include/sysfs.h.kzak	2015-07-02 12:12:50.408196320 +0200
d2bdca
+++ util-linux-2.23.2/include/sysfs.h	2015-07-02 12:13:09.708061372 +0200
d2bdca
@@ -74,6 +74,8 @@ extern int sysfs_devno_to_wholedisk(dev_
b3c25a
             size_t len, dev_t *diskdevno);
d2bdca
 extern int sysfs_devno_is_wholedisk(dev_t devno);
b3c25a
 
b3c25a
+extern int sysfs_devno_is_lvm_private(dev_t devno);
b3c25a
+
b3c25a
 extern int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h,
b3c25a
 			       int *c, int *t, int *l);
b3c25a
 extern char *sysfs_scsi_host_strdup_attribute(struct sysfs_cxt *cxt,
b3c25a
diff -up util-linux-2.23.2/libblkid/src/blkidP.h.kzak util-linux-2.23.2/libblkid/src/blkidP.h
d2bdca
--- util-linux-2.23.2/libblkid/src/blkidP.h.kzak	2015-07-02 12:18:27.349840375 +0200
d2bdca
+++ util-linux-2.23.2/libblkid/src/blkidP.h	2015-07-02 12:19:07.797557558 +0200
b3c25a
@@ -221,6 +221,7 @@ struct blkid_struct_probe
b3c25a
 #define BLKID_FL_PRIVATE_FD	(1 << 1)	/* see blkid_new_probe_from_filename() */
b3c25a
 #define BLKID_FL_TINY_DEV	(1 << 2)	/* <= 1.47MiB (floppy or so) */
b3c25a
 #define BLKID_FL_CDROM_DEV	(1 << 3)	/* is a CD/DVD drive */
b3c25a
+#define BLKID_FL_NOSCAN_DEV	(1 << 4)        /* do not scan this device */
b3c25a
 
b3c25a
 /* private per-probing flags */
b3c25a
 #define BLKID_PROBE_FL_IGNORE_PT (1 << 1)	/* ignore partition table */
b3c25a
diff -up util-linux-2.23.2/libblkid/src/partitions/partitions.c.kzak util-linux-2.23.2/libblkid/src/partitions/partitions.c
d2bdca
--- util-linux-2.23.2/libblkid/src/partitions/partitions.c.kzak	2015-07-02 12:19:11.669530485 +0200
d2bdca
+++ util-linux-2.23.2/libblkid/src/partitions/partitions.c	2015-07-02 12:28:24.166667964 +0200
b3c25a
@@ -537,6 +537,8 @@ static int idinfo_probe(blkid_probe pr,
b3c25a
 
b3c25a
 	if (pr->size <= 0 || (id->minsz && id->minsz > pr->size))
b3c25a
 		goto nothing;	/* the device is too small */
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		goto nothing;
b3c25a
 
b3c25a
 	rc = blkid_probe_get_idmag(pr, id, &off, &mag;;
b3c25a
 	if (rc != BLKID_PROBE_OK)
b3c25a
@@ -576,8 +578,12 @@ static int partitions_probe(blkid_probe
b3c25a
 
b3c25a
 	if (!pr || chn->idx < -1)
b3c25a
 		return -EINVAL;
b3c25a
+
b3c25a
 	blkid_probe_chain_reset_vals(pr, chn);
b3c25a
 
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		return BLKID_PROBE_NONE;
b3c25a
+
b3c25a
 	if (chn->binary)
b3c25a
 		partitions_init_data(chn);
b3c25a
 
b3c25a
@@ -653,6 +659,8 @@ int blkid_partitions_do_subprobe(blkid_p
b3c25a
 
b3c25a
 	if (!pr || !parent || !parent->size)
b3c25a
 		return -EINVAL;
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		return BLKID_PROBE_NONE;
b3c25a
 
b3c25a
 	/* range defined by parent */
b3c25a
 	sz = ((blkid_loff_t) parent->size) << 9;
b3c25a
@@ -707,6 +715,9 @@ static int blkid_partitions_probe_partit
b3c25a
 	blkid_partition par;
b3c25a
 	dev_t devno;
b3c25a
 
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		goto nothing;
b3c25a
+
b3c25a
 	devno = blkid_probe_get_devno(pr);
b3c25a
 	if (!devno)
b3c25a
 		goto nothing;
b3c25a
@@ -779,7 +790,7 @@ nothing:
b3c25a
 int blkid_probe_is_covered_by_pt(blkid_probe pr,
b3c25a
 				 blkid_loff_t offset, blkid_loff_t size)
b3c25a
 {
b3c25a
-	blkid_probe prc;
b3c25a
+	blkid_probe prc = NULL;
b3c25a
 	blkid_partlist ls = NULL;
b3c25a
 	blkid_loff_t start, end;
b3c25a
 	int nparts, i, rc = 0;
b3c25a
@@ -788,6 +799,9 @@ int blkid_probe_is_covered_by_pt(blkid_p
b3c25a
 		"=> checking if off=%jd size=%jd covered by PT",
b3c25a
 		offset, size));
b3c25a
 
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		goto done;
b3c25a
+
b3c25a
 	prc = blkid_clone_probe(pr);
b3c25a
 	if (!prc)
b3c25a
 		goto done;
b3c25a
diff -up util-linux-2.23.2/libblkid/src/probe.c.kzak util-linux-2.23.2/libblkid/src/probe.c
d2bdca
--- util-linux-2.23.2/libblkid/src/probe.c.kzak	2015-07-02 12:13:48.823787869 +0200
d2bdca
+++ util-linux-2.23.2/libblkid/src/probe.c	2015-07-02 12:38:20.110518915 +0200
b3c25a
@@ -110,6 +110,7 @@
b3c25a
 
b3c25a
 #include "blkidP.h"
b3c25a
 #include "all-io.h"
b3c25a
+#include "sysfs.h"
b3c25a
 
b3c25a
 /* chains */
b3c25a
 extern const struct blkid_chaindrv superblocks_drv;
b3c25a
@@ -714,8 +715,13 @@ int blkid_probe_set_device(blkid_probe p
b3c25a
 	if (pr->size <= 1440 * 1024 && !S_ISCHR(sb.st_mode))
b3c25a
 		pr->flags |= BLKID_FL_TINY_DEV;
b3c25a
 
b3c25a
+	if (S_ISBLK(sb.st_mode) && sysfs_devno_is_lvm_private(sb.st_rdev)) {
b3c25a
+		DBG(LOWPROBE, blkid_debug("ignore private LVM device"));
b3c25a
+		pr->flags |= BLKID_FL_NOSCAN_DEV;
b3c25a
+        }
b3c25a
+
b3c25a
 #ifdef CDROM_GET_CAPABILITY
b3c25a
-	if (S_ISBLK(sb.st_mode) &&
b3c25a
+	else if (S_ISBLK(sb.st_mode) &&
b3c25a
 	    !blkid_probe_is_tiny(pr) &&
b3c25a
 	    blkid_probe_is_wholedisk(pr) &&
b3c25a
 	    ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0)
b3c25a
@@ -892,6 +898,9 @@ int blkid_do_probe(blkid_probe pr)
b3c25a
 	if (!pr)
b3c25a
 		return -1;
b3c25a
 
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		return 1;
b3c25a
+
b3c25a
 	do {
b3c25a
 		struct blkid_chain *chn = pr->cur_chain;
b3c25a
 
b3c25a
@@ -1143,6 +1152,8 @@ int blkid_do_safeprobe(blkid_probe pr)
b3c25a
 
b3c25a
 	if (!pr)
b3c25a
 		return -1;
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		return 1;
b3c25a
 
b3c25a
 	blkid_probe_start(pr);
b3c25a
 
b3c25a
@@ -1197,6 +1208,8 @@ int blkid_do_fullprobe(blkid_probe pr)
b3c25a
 
b3c25a
 	if (!pr)
b3c25a
 		return -1;
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		return 1;
b3c25a
 
b3c25a
 	blkid_probe_start(pr);
b3c25a
 
b3c25a
diff -up util-linux-2.23.2/libblkid/src/superblocks/superblocks.c.kzak util-linux-2.23.2/libblkid/src/superblocks/superblocks.c
d2bdca
--- util-linux-2.23.2/libblkid/src/superblocks/superblocks.c.kzak	2015-07-02 12:29:32.370193121 +0200
d2bdca
+++ util-linux-2.23.2/libblkid/src/superblocks/superblocks.c	2015-07-02 12:31:06.897535008 +0200
d2bdca
@@ -338,6 +338,9 @@ static int superblocks_probe(blkid_probe
b3c25a
 
b3c25a
 	if (!pr || chn->idx < -1)
b3c25a
 		return -EINVAL;
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		goto nothing;
b3c25a
+
b3c25a
 	blkid_probe_chain_reset_vals(pr, chn);
b3c25a
 
b3c25a
 	DBG(LOWPROBE, blkid_debug("--> starting probing loop [SUBLKS idx=%d]",
d2bdca
@@ -453,6 +456,9 @@ static int superblocks_safeprobe(blkid_p
b3c25a
 	int intol = 0;
b3c25a
 	int rc;
b3c25a
 
b3c25a
+	if (pr->flags & BLKID_FL_NOSCAN_DEV)
b3c25a
+		return 1;				/* nothing */
b3c25a
+
b3c25a
 	while ((rc = superblocks_probe(pr, chn)) == 0) {
b3c25a
 
b3c25a
 		if (blkid_probe_is_tiny(pr) && !count)
b3c25a
diff -up util-linux-2.23.2/libblkid/src/verify.c.kzak util-linux-2.23.2/libblkid/src/verify.c
d2bdca
--- util-linux-2.23.2/libblkid/src/verify.c.kzak	2015-07-02 12:15:51.782928121 +0200
d2bdca
+++ util-linux-2.23.2/libblkid/src/verify.c	2015-07-02 12:16:45.078555470 +0200
b3c25a
@@ -112,6 +112,10 @@ blkid_dev blkid_verify(blkid_cache cache
b3c25a
 		   (unsigned long)diff));
b3c25a
 #endif
b3c25a
 
b3c25a
+	if (sysfs_devno_is_lvm_private(st.st_rdev)) {
b3c25a
+		blkid_free_dev(dev);
b3c25a
+		return NULL;
b3c25a
+	}
b3c25a
 	if (!cache->probe) {
b3c25a
 		cache->probe = blkid_new_probe();
b3c25a
 		if (!cache->probe) {
b3c25a
diff -up util-linux-2.23.2/lib/sysfs.c.kzak util-linux-2.23.2/lib/sysfs.c
d2bdca
--- util-linux-2.23.2/lib/sysfs.c.kzak	2015-07-02 12:12:29.193344657 +0200
d2bdca
+++ util-linux-2.23.2/lib/sysfs.c	2015-07-02 12:12:13.565453930 +0200
d2bdca
@@ -639,6 +639,35 @@ err:
b3c25a
 }
b3c25a
 
d2bdca
 /*
b3c25a
+ * Returns 1 if the device is private LVM device.
b3c25a
+ */
b3c25a
+int sysfs_devno_is_lvm_private(dev_t devno)
b3c25a
+{
b3c25a
+	struct sysfs_cxt cxt = UL_SYSFSCXT_EMPTY;
b3c25a
+	char *uuid = NULL;
b3c25a
+	int rc = 0;
b3c25a
+
b3c25a
+	if (sysfs_init(&cxt, devno, NULL) != 0)
b3c25a
+		return 0;
b3c25a
+
b3c25a
+	uuid = sysfs_strdup(&cxt, "dm/uuid");
b3c25a
+
b3c25a
+	/* Private LVM devices use "LVM-<uuid>-<name>" uuid format (important
b3c25a
+	 * is the "LVM" prefix and "-<name>" postfix).
b3c25a
+	 */
b3c25a
+	if (uuid && strncmp(uuid, "LVM-", 4) == 0) {
b3c25a
+		char *p = strrchr(uuid + 4, '-');
b3c25a
+
b3c25a
+		if (p && *(p + 1))
b3c25a
+			rc = 1;
b3c25a
+	}
b3c25a
+
b3c25a
+	sysfs_deinit(&cxt);
b3c25a
+	free(uuid);
b3c25a
+	return rc;
b3c25a
+}
b3c25a
+
d2bdca
+/*
d2bdca
  * Return 0 or 1, or < 0 in case of error
d2bdca
  */
d2bdca
 int sysfs_devno_is_wholedisk(dev_t devno)
d2bdca
@@ -651,6 +680,9 @@ int sysfs_devno_is_wholedisk(dev_t devno
d2bdca
 	return devno == disk;
d2bdca
 }
b3c25a
 
d2bdca
+
d2bdca
+
d2bdca
+
b3c25a
 int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h, int *c, int *t, int *l)
b3c25a
 {
d2bdca
 	char buf[PATH_MAX], *hctl;