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);
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]);