Check that the swap-device has been activated, runs in swapon by searching for the device name in /proc/swaps. In the /proc/swaps always specifies the path to the real device file, even if the symlink passed in the swapon() system call. This differs from the situation with /proc/mounts, where remembered exactly the string passed in the system call mount*(). If you use a swap partition on lvm, libblkid returns the name /dev/mapper/*, but there are now symlinks pointing to the device files /dev/dm-*, resulting the /proc/swaps contain /dev/dm-*, but the swapon is looking for /dev/mapper/* and tries to activate the swap partition again. Signed-off-by: Alexey Gladkov <gladkov.alexey@xxxxxxxxx> --- mount/swapon.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mount/swapon.c b/mount/swapon.c index a2dd9dc..a5362ef 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -177,7 +177,11 @@ read_proc_swaps(void) { break; swapFiles = q; - swapFiles[numSwaps++] = unmangle(line); + if ((p = unmangle(line)) == NULL) + break; + + swapFiles[numSwaps++] = canonicalize_path(p); + free(p); } fclose(swaps); } @@ -185,10 +189,14 @@ read_proc_swaps(void) { static int is_in_proc_swaps(const char *fname) { int i; + char *p = canonicalize_path(fname); for (i = 0; i < numSwaps; i++) - if (swapFiles[i] && !strcmp(fname, swapFiles[i])) + if (swapFiles[i] && !strcmp(p, swapFiles[i])) { + free(p); return 1; + } + free(p); return 0; } -- 1.7.3.2 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html