summaryrefslogtreecommitdiff
path: root/misc-utils/blkid.c
diff options
context:
space:
mode:
authorLaMont Jones <lamont@debian.org>2010-02-03 16:26:41 -0700
committerLaMont Jones <lamont@debian.org>2010-02-03 16:26:41 -0700
commit2bd3ccad2133d3aefdc2caeb3034c0725414d2e9 (patch)
tree64db9a6968f1d398d386ddc1d46d2e0a7396ff44 /misc-utils/blkid.c
parentc3701c1d965cdc905bd580ece68a1c4008b4d1b0 (diff)
parentcdfb1e88228c10c28f8bfe0f4b0ff1b3b06d1ed4 (diff)
downloadutil-linux-old-2bd3ccad2133d3aefdc2caeb3034c0725414d2e9.tar.gz
Merge remote branch 'origin/master'
Conflicts: tests/ts/blkid/images-fs/adaptec-raid.img.bz2 tests/ts/blkid/images-fs/ddf-raid.img.bz2 tests/ts/blkid/images-fs/gfs2.img.bz2 tests/ts/blkid/images-fs/hpt37x-raid.img.bz2 tests/ts/blkid/images-fs/isw-raid.img.bz2 tests/ts/blkid/images-fs/jbd.img.bz2 tests/ts/blkid/images-fs/jmicron-raid.img.bz2 tests/ts/blkid/images-fs/lvm2.img.bz2 tests/ts/blkid/images-fs/nvidia-raid.img.bz2 tests/ts/blkid/images-fs/ocfs2.img.bz2 tests/ts/blkid/images-fs/promise-raid.img.bz2 tests/ts/blkid/images-fs/reiser4.img.bz2 tests/ts/blkid/images-fs/romfs.img.bz2 tests/ts/blkid/images-fs/silicon-raid.img.bz2 tests/ts/blkid/images-fs/swap0.img.bz2 tests/ts/blkid/images-fs/swap1.img.bz2 tests/ts/blkid/images-fs/via-raid.img.bz2 tests/ts/blkid/images-fs/vmfs_volume.img.bz2 tests/ts/blkid/images-fs/zfs.img.bz2
Diffstat (limited to 'misc-utils/blkid.c')
-rw-r--r--misc-utils/blkid.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
index 6e055a95..56b25b8b 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);
@@ -437,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) {
@@ -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 |