3
0
forked from pool/util-linux
util-linux/util-linux-2.12a-procswapscheck.diff

25 lines
604 B
Diff

--- util-linux-2.12q/mount/swapon.c
+++ util-linux-2.12q/mount/swapon.c
@@ -160,10 +160,19 @@
static int
is_in_proc_swaps(const char *fname) {
int i;
+ struct stat stfname, stswapFile;
- for (i = 0; i < numSwaps; i++)
- if (swapFiles[i] && !strcmp(fname, swapFiles[i]))
+ stat(fname, &stfname);
+
+ for (i = 0; i < numSwaps; i++) {
+ if(S_ISBLK(stfname.st_mode)) {
+ stat(swapFiles[i], &stswapFile);
+ if(S_ISBLK(stswapFile.st_mode))
+ if(stfname.st_rdev == stswapFile.st_rdev)
+ return 1;
+ } else if (swapFiles[i] && !strcmp(fname, swapFiles[i]))
return 1;
+ }
return 0;
}