swapon_SOURCES = swapon.c xmalloc.c \
get_label_uuid.c mount_by_label.c mount_blkid.c \
- swap_constants.h
+ swap_constants.h realpath.c
losetup_SOURCES = lomount.c loop.h lomount.h
losetup_CFLAGS = -DMAIN
#include "nls.h"
#include "mount_blkid.h"
#include "mount_by_label.h"
+#include "realpath.h"
+
+#include <limits.h> /* for PATH_MAX */
+#ifndef PATH_MAX
+#define PATH_MAX 8192
+#endif
#define streq(s, t) (strcmp ((s), (t)) == 0)
static int
is_in_proc_swaps(const char *fname) {
int i;
+ char canonical[PATH_MAX + 2];
+
+ if (!myrealpath(fname, canonical, PATH_MAX + 1)) {
+ fprintf(stderr, _("%s: cannot canonicalize %s: %s\n"),
+ progname, fname, strerror(errno));
+ strncpy(canonical, fname, PATH_MAX + 1);
+ *(canonical + (PATH_MAX + 1)) = '\0';
+ }
for (i = 0; i < numSwaps; i++)
- if (swapFiles[i] && !strcmp(fname, swapFiles[i]))
+ if (swapFiles[i] && !strcmp(canonical, swapFiles[i]))
return 1;
return 0;
}