From: Jo-Philipp Wich Date: Thu, 25 Jul 2013 14:17:52 +0000 (+0200) Subject: block: restore support for using swap files X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3637b9f8e7097d38a17d5b6ffa9a4d6eb1249eb3;p=oweals%2Fubox.git block: restore support for using swap files --- diff --git a/block.c b/block.c index 5ae0fd0..b5bc494 100644 --- a/block.c +++ b/block.c @@ -910,8 +910,8 @@ static int main_swapon(int argc, char **argv) struct stat s; int err; - if (stat(argv[1], &s) || !S_ISBLK(s.st_mode)) { - fprintf(stderr, "%s is not a block device\n", argv[1]); + if (stat(argv[1], &s) || (!S_ISBLK(s.st_mode) && !S_ISREG(s.st_mode))) { + fprintf(stderr, "%s is not a block device or file\n", argv[1]); return -1; } err = swapon(argv[1], 0); @@ -956,8 +956,8 @@ static int main_swapoff(int argc, char **argv) struct stat s; int err; - if (stat(argv[1], &s) || !S_ISBLK(s.st_mode)) { - fprintf(stderr, "%s is not a block device\n", argv[1]); + if (stat(argv[1], &s) || (!S_ISBLK(s.st_mode) && !S_ISREG(s.st_mode))) { + fprintf(stderr, "%s is not a block device or file\n", argv[1]); return -1; } err = swapoff(argv[1]);