Magellan Linux

Contents of /trunk/util-linux/patches/util-linux-2.12p-swapon-check-symlinks.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download)
Tue May 8 20:52:56 2007 UTC (17 years ago) by niro
File size: 864 byte(s)
-import

1 --- util-linux-2.12b/mount/swapon.c
2 +++ util-linux-2.12b/mount/swapon.c
3 @@ -7,2 +7,3 @@
4 #include <stdlib.h>
5 +#include <sys/param.h>
6 #include <stdio.h>
7 @@ -137,10 +138,27 @@
8 static int
9 is_in_proc_swaps(const char *fname) {
10 int i;
11 + struct stat fstatbuf;
12
13 for (i = 0; i < numSwaps; i++)
14 if (swapFiles[i] && !strcmp(fname, swapFiles[i]))
15 return 1;
16 +
17 + /* fallback:
18 + * if the device in /etc/fstab is a symlink, the entry
19 + * in /proc/swaps won't match because the kernel stores
20 + * absolute pathnames. Here we compare dev_t's.
21 + */
22 + if (!lstat(fname, &fstatbuf))
23 + if (S_ISLNK(fstatbuf.st_mode)) {
24 + struct stat swapstatbuf;
25 + stat(fname, &fstatbuf);
26 + for (i = 0; i < numSwaps; i++)
27 + if (swapFiles[i] && !stat(swapFiles[i], &swapstatbuf) && \
28 + swapstatbuf.st_rdev == fstatbuf.st_rdev)
29 + return 1;
30 + }
31 +
32 return 0;
33 }
34