summaryrefslogtreecommitdiffstats
path: root/sys-utils/swapon-common.c
diff options
context:
space:
mode:
authorKarel Zak2014-09-22 13:16:25 +0200
committerKarel Zak2014-09-22 13:16:25 +0200
commit18b3e5495b2bd1d89286f452d1d2952e065dfecd (patch)
tree008f4099b0814ad1e7408b7de6572fcc804031f8 /sys-utils/swapon-common.c
parentlogger: gettimeofday needs <sys/time.h> (diff)
downloadkernel-qcow2-util-linux-18b3e5495b2bd1d89286f452d1d2952e065dfecd.tar.gz
kernel-qcow2-util-linux-18b3e5495b2bd1d89286f452d1d2952e065dfecd.tar.xz
kernel-qcow2-util-linux-18b3e5495b2bd1d89286f452d1d2952e065dfecd.zip
swapon: split swapon-common.c
swapon - requires libmount and libblkid swapoff - requires libmount swaplabel - requires libblkid This patch add lib/swapprober.c with blkid stuff for swap. It allows to use and link libblkid only when necessary. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/swapon-common.c')
-rw-r--r--sys-utils/swapon-common.c47
1 files changed, 2 insertions, 45 deletions
diff --git a/sys-utils/swapon-common.c b/sys-utils/swapon-common.c
index 203d5c4d0..8f7788cb0 100644
--- a/sys-utils/swapon-common.c
+++ b/sys-utils/swapon-common.c
@@ -1,11 +1,10 @@
-#include <blkid.h>
#include "c.h"
#include "nls.h"
-#include "swapheader.h"
-#include "swapon-common.h"
#include "xalloc.h"
+#include "swapon-common.h"
+
/*
* content of /proc/swaps and /etc/fstab
*/
@@ -106,45 +105,3 @@ size_t numof_uuids(void)
return ulct;
}
-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: ambivalent 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;
-}