From 865deca2242a8b9f40d351e3eb2f5c0f9433bd02 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 2 Apr 2010 11:43:36 +0200 Subject: [PATCH] swapon: move DELETED_SUFFIX to include/pathnames.h Signed-off-by: Karel Zak --- include/pathnames.h | 4 ++++ mount/swapon.c | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/pathnames.h b/include/pathnames.h index 9c4eb009b6..7d57c528f4 100644 --- a/include/pathnames.h +++ b/include/pathnames.h @@ -12,6 +12,10 @@ # error "we need an ANSI compiler" #endif +/* used by kernel in /proc (e.g. /proc/swaps) for deleted files */ +#define PATH_DELETED_SUFFIX "\\040(deleted)" +#define PATH_DELETED_SUFFIX_SZ (sizeof(PATH_DELETED_SUFFIX) - 1) + /* DEFPATHs from don't include /usr/local */ #undef _PATH_DEFPATH #define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin" diff --git a/mount/swapon.c b/mount/swapon.c index 501254bc54..4ee3c2f750 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -121,9 +121,6 @@ swapoff_usage(FILE *fp, int n) { static int numSwaps; static char **swapFiles; /* array of swap file and partition names */ -#define DELETED_SUFFIX "\\040(deleted)" -#define DELETED_SUFFIX_SZ (sizeof(DELETED_SUFFIX) - 1) - static void read_proc_swaps(void) { FILE *swaps; @@ -163,9 +160,9 @@ read_proc_swaps(void) { * in /proc/swaps, we have to remove this junk. */ sz = strlen(line); - if (sz > DELETED_SUFFIX_SZ) { - p = line + (sz - DELETED_SUFFIX_SZ); - if (strcmp(p, DELETED_SUFFIX) == 0) + if (sz > PATH_DELETED_SUFFIX_SZ) { + p = line + (sz - PATH_DELETED_SUFFIX_SZ); + if (strcmp(p, PATH_DELETED_SUFFIX) == 0) *p = '\0'; } -- 2.39.5