summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2010-02-18 16:46:56 +0100
committerKarel Zak2010-02-18 16:46:56 +0100
commit4f74ffdbfe1f8d967cec0bc060a0a45c38aeb244 (patch)
tree47f21643083d5cf7ac7306aba13a10f101856878
parentlibblkid: add support for PART_ENTRY_* values (diff)
downloadkernel-qcow2-util-linux-4f74ffdbfe1f8d967cec0bc060a0a45c38aeb244.tar.gz
kernel-qcow2-util-linux-4f74ffdbfe1f8d967cec0bc060a0a45c38aeb244.tar.xz
kernel-qcow2-util-linux-4f74ffdbfe1f8d967cec0bc060a0a45c38aeb244.zip
blkid: export ID_PART_ENTRY_* variables for udev
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--misc-utils/blkid.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 8c66e0a83..882eeaad8 100644
--- a/misc-utils/blkid.c
+++ b/misc-utils/blkid.c
@@ -252,10 +252,19 @@ static void print_udev_format(const char *name, const char *value, size_t sz)
blkid_encode_string(value, enc, sizeof(enc));
printf("ID_FS_%s_ENC=%s\n", name, enc);
- } else if (!strcmp(name, "PTTYPE"))
+ } else if (!strcmp(name, "PTTYPE")) {
printf("ID_PART_TABLE_TYPE=%s\n", value);
- /* TODO: ID_PART_ENTRY_{UUID,NAME,FLAG} */
+ } else if (!strcmp(name, "PART_ENTRY_NAME")) {
+
+ blkid_safe_string(value, safe, sizeof(safe));
+ printf("ID_%s=%s\n", name, safe);
+
+ blkid_encode_string(value, enc, sizeof(enc));
+ printf("ID_%s_ENC=%s\n", name, enc);
+
+ } else if (!strncmp(name, "PART_ENTRY_", 11))
+ printf("ID_%s=%s\n", name, value);
else
printf("ID_FS_%s=%s\n", name, value);
@@ -407,7 +416,7 @@ static int lowprobe_device(blkid_probe pr, const char *devname, char *show[],
{
const char *data;
const char *name;
- int nvals = 0, n, num = 1;
+ int nvals = 0, n, num = 1, has_pt = 0;
size_t len;
int fd;
int rc = 0;
@@ -429,16 +438,45 @@ static int lowprobe_device(blkid_probe pr, const char *devname, char *show[],
blkid_probe_enable_superblocks(pr, 0); /* enabled by default ;-( */
blkid_probe_enable_partitions(pr, 1);
+
+ /* This is for PART_ENTRY_{UUID,NAME,TYPE,...} values and it will
+ * open() whole-disk device.
+ */
+ blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
+
rc = blkid_do_fullprobe(pr);
blkid_probe_enable_partitions(pr, 0);
if (rc < 0)
goto done; /* -1 = error, 1 = nothing, 0 = succes */
+ if (blkid_probe_lookup_value(pr, "PTTYPE", NULL, NULL))
+ /* partition table detected */
+ has_pt = 1;
+
/*
- * Don't probe for FS/RAIDs on small devices
+ * filesystems/raids probing
+ *
+ * Q: Why do we try to probe for FS/RAID on device with partiton table?
+ *
+ * A: For some devices the kernel creates partitions because it is too
+ * dumb to find out, that the device contains a RAID signature or
+ * other metadata that signifies, that this device should not be
+ * handled.
+ *
+ * Many RAID signatures are at the end of the device, or at least
+ * still allow that the volume contains a partition table at the
+ * beginning of the device, which the kernel will find. Udev needs
+ * to look at the disk, if there are such RAID signatures, and then
+ * it needs to handle it, and in many cases just kill all the
+ * wrongly kernel-created partitions.
+ *
+ * -- Kay Sievers
+ * http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/2888/focus=2890
+ *
+ * This all is unncecessary for very small devices (<= 1.44MiB).
*/
- if (rc || S_ISCHR(st.st_mode) ||
+ if (has_pt == 0 || S_ISCHR(st.st_mode) ||
blkid_probe_get_size(pr) > 1024 * 1440) {
/*
* filesystems/RAIDs probing