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/lib/swapprober.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libblkid/lib/swapprober.c (limited to 'libblkid/lib/swapprober.c') diff --git a/libblkid/lib/swapprober.c b/libblkid/lib/swapprober.c new file mode 100644 index 000000000..5a4b112e1 --- /dev/null +++ b/libblkid/lib/swapprober.c @@ -0,0 +1,49 @@ + +#include "c.h" +#include "nls.h" + +#include "swapheader.h" +#include "swapprober.h" + +blkid_probe get_swap_prober(const char *devname) +{ + blkid_probe pr; + int rc; + const char *version = NULL; + char *swap_filter[] = { "swap", NULL }; + + pr = blkid_new_probe_from_filename(devname); + if (!pr) { + warn(_("%s: unable to probe device"), devname); + return NULL; + } + + blkid_probe_enable_superblocks(pr, TRUE); + blkid_probe_set_superblocks_flags(pr, + BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | + BLKID_SUBLKS_VERSION); + + blkid_probe_filter_superblocks_type(pr, BLKID_FLTR_ONLYIN, swap_filter); + + rc = blkid_do_safeprobe(pr); + if (rc == -1) + warn(_("%s: unable to probe device"), devname); + else if (rc == -2) + warnx(_("%s: ambiguous probing result; use wipefs(8)"), devname); + else if (rc == 1) + warnx(_("%s: not a valid swap partition"), devname); + + if (rc == 0) { + /* Only the SWAPSPACE2 is supported. */ + if (blkid_probe_lookup_value(pr, "VERSION", &version, NULL) == 0 + && version + && strcmp(version, stringify_value(SWAP_VERSION))) + warnx(_("%s: unsupported swap version '%s'"), + devname, version); + else + return pr; + } + + blkid_free_probe(pr); + return NULL; +} -- cgit v1.2.3