]>
Commit | Line | Data |
---|---|---|
e21677fe KZ |
1 | /* |
2 | * Copyright (C) 2009 Karel Zak <kzak@redhat.com> | |
3 | * | |
4 | * This file may be redistributed under the terms of the | |
5 | * GNU Lesser General Public License. | |
6 | */ | |
7 | ||
8 | #include <stdio.h> | |
9 | #include <stdlib.h> | |
10 | #include <sys/types.h> | |
11 | #include <sys/stat.h> | |
12 | #include <fcntl.h> | |
e21677fe KZ |
13 | #include <errno.h> |
14 | ||
15 | #include <blkid.h> | |
16 | ||
3ebd663b | 17 | #include "c.h" |
e21677fe KZ |
18 | |
19 | int main(int argc, char *argv[]) | |
20 | { | |
f38db0cf | 21 | int rc; |
e21677fe KZ |
22 | char *devname; |
23 | blkid_probe pr; | |
24 | blkid_topology tp; | |
25 | ||
26 | if (argc < 2) { | |
27 | fprintf(stderr, "usage: %s <device> " | |
28 | "-- prints topology details about the device\n", | |
29 | program_invocation_short_name); | |
30 | return EXIT_FAILURE; | |
31 | } | |
32 | ||
33 | devname = argv[1]; | |
f38db0cf | 34 | pr = blkid_new_probe_from_filename(devname); |
e21677fe | 35 | if (!pr) |
9e930041 | 36 | err(EXIT_FAILURE, "%s: failed to create a new libblkid probe", |
f38db0cf | 37 | devname); |
77082c5a KZ |
38 | /* |
39 | * Binary interface | |
40 | */ | |
41 | tp = blkid_probe_get_topology(pr); | |
42 | if (tp) { | |
43 | printf("----- binary interface:\n"); | |
4c3ceac6 | 44 | printf("\talignment offset : %lu\n", |
77082c5a | 45 | blkid_topology_get_alignment_offset(tp)); |
4c3ceac6 | 46 | printf("\tminimum io size : %lu\n", |
77082c5a | 47 | blkid_topology_get_minimum_io_size(tp)); |
4c3ceac6 | 48 | printf("\toptimal io size : %lu\n", |
77082c5a | 49 | blkid_topology_get_optimal_io_size(tp)); |
4c3ceac6 KZ |
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)); | |
77082c5a KZ |
54 | } |
55 | ||
e21677fe KZ |
56 | /* |
57 | * NAME=value interface | |
58 | */ | |
59 | ||
60 | /* enable topology probing */ | |
61 | blkid_probe_enable_topology(pr, TRUE); | |
62 | ||
63 | /* disable superblocks probing (enabled by default) */ | |
64 | blkid_probe_enable_superblocks(pr, FALSE); | |
65 | ||
66 | rc = blkid_do_fullprobe(pr); | |
67 | if (rc == -1) | |
68 | errx(EXIT_FAILURE, "%s: blkid_do_fullprobe() failed", devname); | |
69 | else if (rc == 1) | |
70 | warnx("%s: missing topology information", devname); | |
71 | else { | |
38fb0905 | 72 | int i, nvals = blkid_probe_numof_values(pr); |
e21677fe KZ |
73 | |
74 | printf("----- NAME=value interface (values: %d):\n", nvals); | |
75 | ||
e21677fe KZ |
76 | for (i = 0; i < nvals; i++) { |
77 | const char *name, *data; | |
78 | ||
79 | blkid_probe_get_value(pr, i, &name, &data, NULL); | |
80 | printf("\t%s = %s\n", name, data); | |
81 | } | |
82 | } | |
83 | ||
79e1f9f1 | 84 | blkid_free_probe(pr); |
e21677fe KZ |
85 | return EXIT_SUCCESS; |
86 | } |