@@ -12,6 +12,17 @@
#include "libswap.h"
#include "lapi/syscalls.h"
+static const char *const swap_supported_fs[] = {
+ "ext2",
+ "ext3",
+ "ext4",
+ "xfs",
+ "vfat",
+ "exfat",
+ "ntfs",
+ NULL
+};
+
/*
* Make a swap file
*/
@@ -26,6 +37,7 @@ int make_swapfile(const char *swapfile, int safe)
/* make the file swapfile */
const char *argv[2 + 1];
+
argv[0] = "mkswap";
argv[1] = swapfile;
argv[2] = NULL;
@@ -40,13 +52,22 @@ int make_swapfile(const char *swapfile, int safe)
*/
void is_swap_supported(const char *filename)
{
+ int i, sw_support = 0;
int fibmap = tst_fibmap(filename);
long fs_type = tst_fs_type(filename);
const char *fstype = tst_fs_type_name(fs_type);
+ for (i = 0; swap_supported_fs[i]; i++) {
+ if (strstr(fstype, swap_supported_fs[i])) {
+ sw_support = 1;
+ break;
+ }
+ }
+
int ret = make_swapfile(filename, 1);
+
if (ret != 0) {
- if (fibmap == 1)
+ if (fibmap == 1 && sw_support == 0)
tst_brk(TCONF, "mkswap on %s not supported", fstype);
else
tst_brk(TFAIL, "mkswap on %s failed", fstype);
@@ -56,7 +77,7 @@ void is_swap_supported(const char *filename)
if (TST_RET == -1) {
if (errno == EPERM)
tst_brk(TCONF, "Permission denied for swapon()");
- else if (fibmap == 1 && errno == EINVAL)
+ else if (fibmap == 1 && errno == EINVAL && sw_support == 0)
tst_brk(TCONF, "Swapfile on %s not implemented", fstype);
else
tst_brk(TFAIL | TTERRNO, "swapon() on %s failed", fstype);