cdown / rpms / util-linux

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