2 * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
4 * This file may be redistributed under the terms of the
5 * GNU Lesser General Public License.
10 #include <sys/types.h>
19 int main(int argc
, char *argv
[])
27 fprintf(stderr
, "usage: %s <device> "
28 "-- prints topology details about the device\n",
29 program_invocation_short_name
);
34 pr
= blkid_new_probe_from_filename(devname
);
36 err(EXIT_FAILURE
, "%s: faild to create a new libblkid probe",
41 tp
= blkid_probe_get_topology(pr
);
43 printf("----- binary interface:\n");
44 printf("\talignment offset : %lu\n",
45 blkid_topology_get_alignment_offset(tp
));
46 printf("\tminimum io size : %lu\n",
47 blkid_topology_get_minimum_io_size(tp
));
48 printf("\toptimal io size : %lu\n",
49 blkid_topology_get_optimal_io_size(tp
));
50 printf("\tlogical sector size : %lu\n",
51 blkid_topology_get_logical_sector_size(tp
));
52 printf("\tphysical sector size : %lu\n",
53 blkid_topology_get_physical_sector_size(tp
));
57 * NAME=value interface
60 /* enable topology probing */
61 blkid_probe_enable_topology(pr
, TRUE
);
63 /* disable superblocks probing (enabled by default) */
64 blkid_probe_enable_superblocks(pr
, FALSE
);
66 rc
= blkid_do_fullprobe(pr
);
68 errx(EXIT_FAILURE
, "%s: blkid_do_fullprobe() failed", devname
);
70 warnx("%s: missing topology information", devname
);
72 int i
, nvals
= blkid_probe_numof_values(pr
);
74 printf("----- NAME=value interface (values: %d):\n", nvals
);
76 for (i
= 0; i
< nvals
; i
++) {
77 const char *name
, *data
;
79 blkid_probe_get_value(pr
, i
, &name
, &data
, NULL
);
80 printf("\t%s = %s\n", name
, data
);