1 When swap is a symlink, the swap entry in
2 /etc/fstab may not match /proc/swaps. That
3 means strcmp shouldn't be used for swapon.
5 --- util-linux-2.12p/mount/swapon.c.sopwith Wed Dec 22 04:50:19 2004
6 +++ util-linux-2.12p/mount/swapon.c Thu Dec 23 14:44:49 2004
8 is_in_proc_swaps(const char *fname) {
11 - for (i = 0; i < numSwaps; i++)
12 - if (swapFiles[i] && !strcmp(fname, swapFiles[i]))
13 + for (i = 0; i < numSwaps; i++) {
14 + struct stat swapped, swapping;
16 + if (!swapFiles[i]) continue;
18 + if (!strcmp(fname, swapFiles[i])
19 + || (!stat (swapFiles[i], &swapped)
20 + && !stat (fname, &swapping)
21 + && (swapped.st_dev == swapping.st_dev
22 + && swapped.st_ino == swapping.st_ino))