summaryrefslogtreecommitdiffstats
path: root/include/statfs_magic.h
diff options
context:
space:
mode:
authorKarel Zak2014-11-06 12:50:27 +0100
committerKarel Zak2014-11-06 12:50:27 +0100
commit8f806bb1ea30f15db7ca36d1cfa79349f8115302 (patch)
tree7128f0c36bc2d04ca4513f11fe3daf631845762a /include/statfs_magic.h
parentlib/loopdev: remove test program (diff)
downloadkernel-qcow2-util-linux-8f806bb1ea30f15db7ca36d1cfa79349f8115302.tar.gz
kernel-qcow2-util-linux-8f806bb1ea30f15db7ca36d1cfa79349f8115302.tar.xz
kernel-qcow2-util-linux-8f806bb1ea30f15db7ca36d1cfa79349f8115302.zip
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 <ncopa@alpinelinux.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/statfs_magic.h')
-rw-r--r--include/statfs_magic.h11
1 files changed, 11 insertions, 0 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