]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - lib/swapprober.c
5 #include "swapheader.h"
6 #include "swapprober.h"
8 blkid_probe
get_swap_prober(const char *devname
)
12 const char *version
= NULL
;
13 char *swap_filter
[] = { "swap", NULL
};
15 pr
= blkid_new_probe_from_filename(devname
);
17 warn(_("%s: unable to probe device"), devname
);
21 blkid_probe_enable_superblocks(pr
, TRUE
);
22 blkid_probe_set_superblocks_flags(pr
,
23 BLKID_SUBLKS_LABEL
| BLKID_SUBLKS_UUID
|
24 BLKID_SUBLKS_VERSION
);
26 blkid_probe_filter_superblocks_type(pr
, BLKID_FLTR_ONLYIN
, swap_filter
);
28 rc
= blkid_do_safeprobe(pr
);
30 warn(_("%s: unable to probe device"), devname
);
32 warnx(_("%s: ambiguous probing result; use wipefs(8)"), devname
);
34 warnx(_("%s: not a valid swap partition"), devname
);
37 /* Only the SWAPSPACE2 is supported. */
38 if (blkid_probe_lookup_value(pr
, "VERSION", &version
, NULL
) == 0
40 && strcmp(version
, stringify_value(SWAP_VERSION
)) != 0)
41 warnx(_("%s: unsupported swap version '%s'"),