]> err.no Git - util-linux/commitdiff
blkid: probe for PT, don't probe for FS on small whole-disks
authorKarel Zak <kzak@redhat.com>
Wed, 20 Jan 2010 20:18:15 +0000 (21:18 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Feb 2010 08:58:56 +0000 (09:58 +0100)
 * blkid(8) in low-level mode probes for PT now (blkid is replacement
   for devkit-disks-part-id)

 * add ID_PART_TABLE_TYPE=<name> to blkid(8) udev output

 * don't probe for FS/RAIDs on small devices when PT is detected

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/blkid.c

index 6e055a9533fd07c3c29ddf73f3a1c8d1087328f7..03e3b8075b801b6941f1bda9d983a142b668d10e 100644 (file)
@@ -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 |