summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/statfs_magic.h11
-rw-r--r--sys-utils/switch_root.c4
2 files changed, 13 insertions, 2 deletions
diff --git a/include/statfs_magic.h b/include/statfs_magic.h
index b5fde1a23..d27be1cff 100644
--- a/include/statfs_magic.h
+++ b/include/statfs_magic.h
@@ -1,6 +1,17 @@
#ifndef UTIL_LINUX_STATFS_MAGIC_H
#define UTIL_LINUX_STATFS_MAGIC_H
+#include <sys/statfs.h>
+
+/*
+ * If possible then don't depend on internal libc __SWORD_TYPE type.
+ */
+#ifdef __GNUC__
+typedef __typeof__( ((struct statfs *)0)->f_type ) ul_statfs_ftype_t;
+#else
+typedef __SWORD_TYPE ul_statfs_ftype_t;
+#endif
+
/*
* Unfortunately, Linux kernel hedeader file <linux/magic.h> is incomplete
* mess and kernel returns by statfs f_type many numbers that are nowhere
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index 6822a5d0c..c6a2eff8e 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -181,8 +181,8 @@ static int switchroot(const char *newroot)
if (pid <= 0) {
struct statfs stfs;
if (fstatfs(cfd, &stfs) == 0 &&
- (stfs.f_type == (__SWORD_TYPE)STATFS_RAMFS_MAGIC ||
- stfs.f_type == (__SWORD_TYPE)STATFS_TMPFS_MAGIC))
+ (stfs.f_type == (ul_statfs_ftype_t) STATFS_RAMFS_MAGIC ||
+ stfs.f_type == (ul_statfs_ftype_t) STATFS_TMPFS_MAGIC))
recursiveRemove(cfd);
else
warn(_("old root filesystem is not an initramfs"));