From: Karel Zak Date: Wed, 20 Jan 2010 20:18:15 +0000 (+0100) Subject: blkid: probe for PT, don't probe for FS on small whole-disks X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bf4bdb2c2b22c6839e49197fa7d83fda0afdf7e;p=util-linux 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 --- 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 |