3
0
forked from pool/util-linux
util-linux/util-linux-2.12a-mount_procswapcheck.patch

32 lines
1003 B
Diff
Raw Normal View History

Index: util-linux-ng-2.12r+git20070330/mount/swapon.c
===================================================================
--- util-linux-ng-2.12r+git20070330.orig/mount/swapon.c
+++ util-linux-ng-2.12r+git20070330/mount/swapon.c
@@ -138,6 +138,7 @@ static int
is_in_proc_swaps(const char *fname) {
int i;
char canonical[PATH_MAX + 2];
+ struct stat stfname, stswapFile;
if (!myrealpath(fname, canonical, PATH_MAX + 1)) {
fprintf(stderr, _("%s: cannot canonicalize %s: %s\n"),
@@ -146,9 +147,15 @@ is_in_proc_swaps(const char *fname) {
*(canonical + (PATH_MAX + 1)) = '\0';
}
- for (i = 0; i < numSwaps; i++)
- if (swapFiles[i] && !strcmp(canonical, swapFiles[i]))
- return 1;
+ 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(canonical, swapFiles[i]))
+ return 1;
+ }
return 0;
}