]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - lib/swapprober.c
2 * No copyright is claimed. This code is in the public domain; do with
5 * Written by Karel Zak <kzak@redhat.com>
10 #include "swapheader.h"
11 #include "swapprober.h"
13 blkid_probe
get_swap_prober(const char *devname
)
17 const char *version
= NULL
;
18 char *swap_filter
[] = { "swap", NULL
};
20 pr
= blkid_new_probe_from_filename(devname
);
22 warn(_("%s: unable to probe device"), devname
);
26 blkid_probe_enable_superblocks(pr
, TRUE
);
27 blkid_probe_set_superblocks_flags(pr
,
28 BLKID_SUBLKS_LABEL
| BLKID_SUBLKS_UUID
|
29 BLKID_SUBLKS_VERSION
);
31 blkid_probe_filter_superblocks_type(pr
, BLKID_FLTR_ONLYIN
, swap_filter
);
33 rc
= blkid_do_safeprobe(pr
);
35 warn(_("%s: unable to probe device"), devname
);
37 warnx(_("%s: ambiguous probing result; use wipefs(8)"), devname
);
39 warnx(_("%s: not a valid swap partition"), devname
);
42 /* Only the SWAPSPACE2 is supported. */
43 if (blkid_probe_lookup_value(pr
, "VERSION", &version
, NULL
) == 0
45 && strcmp(version
, stringify_value(SWAP_VERSION
)) != 0)
46 warnx(_("%s: unsupported swap version '%s'"),