From e3d8933aaa1786ed78f06e5c9792d2167801d48e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 20 Jan 2010 21:18:15 +0100 Subject: blkid: probe for PT, don't probe for FS on small whole-disks * blkid(8) in low-level mode probes for PT now (blkid is replacement for devkit-disks-part-id) * add ID_PART_TABLE_TYPE= to blkid(8) udev output * don't probe for FS/RAIDs on small devices when PT is detected Signed-off-by: Karel Zak --- misc-utils/blkid.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'misc-utils/blkid.c') diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index 6e055a95..03e3b807 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -255,7 +255,12 @@ 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")) + printf("ID_PART_TABLE_TYPE=%s\n", value); + + /* TODO: ID_PART_ENTRY_{UUID,NAME,FLAG} */ + else printf("ID_FS_%s=%s\n", name, value); } @@ -410,6 +415,7 @@ static int lowprobe_device(blkid_probe pr, const char *devname, char *show[], size_t len; int fd; int rc = 0; + struct stat st; fd = open(devname, O_RDONLY); if (fd < 0) @@ -417,9 +423,35 @@ static int lowprobe_device(blkid_probe pr, const char *devname, char *show[], if (blkid_probe_set_device(pr, fd, offset, size)) goto done; - rc = blkid_do_safeprobe(pr); - if (rc) + + if (fstat(fd, &st)) goto done; + /* + * partitions probing + */ + blkid_probe_enable_superblocks(pr, 0); /* enabled by default ;-( */ + + blkid_probe_enable_partitions(pr, 1); + rc = blkid_do_fullprobe(pr); + blkid_probe_enable_partitions(pr, 0); + + if (rc < 0) + goto done; /* -1 = error, 1 = nothing, 0 = succes */ + + /* + * Don't probe for FS/RAIDs on small devices + */ + if (rc || S_ISCHR(st.st_mode) || + blkid_probe_get_size(pr) > 1024 * 1440) { + /* + * filesystems/RAIDs probing + */ + blkid_probe_enable_superblocks(pr, 1); + + rc = blkid_do_safeprobe(pr); + if (rc < 0) + goto done; + } nvals = blkid_probe_numof_values(pr); @@ -648,8 +680,6 @@ int main(int argc, char **argv) if (!pr) goto exit; - blkid_probe_enable_superblocks(pr, 1); - blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE | -- cgit v1.2.3 From f00aae6d7b6690e030a6596a6fcf9be6f260b8c5 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 27 Jan 2010 18:16:06 +0100 Subject: blkid: add newline when only one value is printed Signed-off-by: Karel Zak --- misc-utils/blkid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'misc-utils/blkid.c') diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c index 03e3b807..56b25b8b 100644 --- a/misc-utils/blkid.c +++ b/misc-utils/blkid.c @@ -469,7 +469,7 @@ static int lowprobe_device(blkid_probe pr, const char *devname, char *show[], print_value(output, num++, devname, (char *) data, name, len); } - if (nvals > 1 && !(output & (OUTPUT_VALUE_ONLY | OUTPUT_UDEV_LIST))) + if (nvals >= 1 && !(output & (OUTPUT_VALUE_ONLY | OUTPUT_UDEV_LIST))) printf("\n"); done: if (rc == -2) { -- cgit v1.2.3