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
"-- checks based on libblkid for mkfs-like programs.\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",
40
* check Filesystems / Partitions overwrite
43
/* enable partitions probing (superblocks are enabled by default) */
44
blkid_probe_enable_partitions(pr, TRUE);
46
rc = blkid_do_fullprobe(pr);
48
errx(EXIT_FAILURE, "%s: blkid_do_fullprobe() failed", devname);
52
if (!blkid_probe_lookup_value(pr, "TYPE", &type, NULL))
53
errx(EXIT_FAILURE, "%s: appears to contain an existing "
54
"%s superblock", devname, type);
56
if (!blkid_probe_lookup_value(pr, "PTTYPE", &type, NULL))
57
errx(EXIT_FAILURE, "%s: appears to contain an partition "
58
"table (%s)", devname, type);
62
* get topology details
64
tp = blkid_probe_get_topology(pr);
66
errx(EXIT_FAILURE, "%s: failed to read topology", devname);
69
/* ... your mkfs.<type> code or so ...
71
off = blkid_topology_get_alignment_offset(tp);