X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=package%2Futils%2Futil-linux%2Fpatches%2F0001-switch_root-improve-statfs-f_type-portability.patch;fp=package%2Futils%2Futil-linux%2Fpatches%2F0001-switch_root-improve-statfs-f_type-portability.patch;h=761ace77ab1d92243b182f44f768c7574c7dec1b;hp=0000000000000000000000000000000000000000;hb=3534e26463e74586700800ca96f1443da338832d;hpb=62100c31d60d1af9831f9cb85bc00cd019f1170e diff --git a/package/utils/util-linux/patches/0001-switch_root-improve-statfs-f_type-portability.patch b/package/utils/util-linux/patches/0001-switch_root-improve-statfs-f_type-portability.patch new file mode 100644 index 0000000000..761ace77ab --- /dev/null +++ b/package/utils/util-linux/patches/0001-switch_root-improve-statfs-f_type-portability.patch @@ -0,0 +1,49 @@ +From 8f806bb1ea30f15db7ca36d1cfa79349f8115302 Mon Sep 17 00:00:00 2001 +From: Karel Zak +Date: Thu, 6 Nov 2014 12:50:27 +0100 +Subject: [PATCH] switch_root: improve statfs->f_type portability + +__SWORD_TYPE is not available everywhere, for example it's not defined +by musl libc. It also seems that __SWORD_TYPE is not used for f_type +on some architectures (s390x). + +Reported-by: Natanael Copa +Signed-off-by: Karel Zak +--- + include/statfs_magic.h | 11 +++++++++++ + sys-utils/switch_root.c | 4 ++-- + 2 files changed, 13 insertions(+), 2 deletions(-) + +--- 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 ++ ++/* ++ * 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 is incomplete + * mess and kernel returns by statfs f_type many numbers that are nowhere +--- a/sys-utils/switch_root.c ++++ b/sys-utils/switch_root.c +@@ -181,8 +181,8 @@ static int switchroot(const char *newroo + 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"));