From 7b4c7a681cc4c0a53dc8a8baf4853e921cfbf5de Mon Sep 17 00:00:00 2001 From: bigbiff Date: Thu, 1 Jan 2015 19:44:14 -0500 Subject: Update blkid to 2.25.0 Break libblkid into 4 libraries: libblkid, libuuid, libutil-linux and libfdisk. This should help in later patch updates. Change-Id: I680d9a7feb031e5c29a603e9c58aff4b65826262 --- libblkid/samples/superblocks.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 libblkid/samples/superblocks.c (limited to 'libblkid/samples/superblocks.c') diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c new file mode 100644 index 000000000..20e39c97e --- /dev/null +++ b/libblkid/samples/superblocks.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Karel Zak + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "c.h" + +int main(int argc, char *argv[]) +{ + int rc; + char *devname; + blkid_probe pr; + + if (argc < 2) { + fprintf(stderr, "usage: %s " + "-- prints superblocks details about the device\n", + program_invocation_short_name); + return EXIT_FAILURE; + } + + devname = argv[1]; + pr = blkid_new_probe_from_filename(devname); + if (!pr) + err(EXIT_FAILURE, "%s: faild to create a new libblkid probe", + devname); + + /* enable topology probing */ + blkid_probe_enable_superblocks(pr, TRUE); + + /* set all flags */ + blkid_probe_set_superblocks_flags(pr, + BLKID_SUBLKS_LABEL | BLKID_SUBLKS_LABELRAW | + BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW | + BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE | + BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION | + BLKID_SUBLKS_MAGIC); + + rc = blkid_do_safeprobe(pr); + if (rc == -1) + errx(EXIT_FAILURE, "%s: blkid_do_safeprobe() failed", devname); + else if (rc == 1) + warnx("%s: cannot gather information about superblocks", devname); + else { + int i, nvals = blkid_probe_numof_values(pr); + + for (i = 0; i < nvals; i++) { + const char *name, *data; + + blkid_probe_get_value(pr, i, &name, &data, NULL); + printf("\t%s = %s\n", name, data); + } + } + + blkid_free_probe(pr); + return EXIT_SUCCESS; +} -- cgit v1.2.3