aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2017-11-20 13:54:02 -0600
committerEric Sandeen <sandeen@redhat.com>2017-11-20 13:54:02 -0600
commitce9adab0071e6844e097b695bd800cca135dd440 (patch)
treea88d3c20f36340269f4905a615a5ec98d3eb12a8
parent8bb344f4bf2ef5d90bc02221d8411db603c11416 (diff)
downloadxfsprogs-dev-ce9adab0071e6844e097b695bd800cca135dd440.tar.gz
xfs_io: stat: treat statfs.f_flags as optional
Kernels prior to 2.6.36 didn't contain statfs.f_flags. Distros with initial releases with kernels prior to this may not have updated headers with this member. Only attempt to print it if we have the header with the member defined. Signed-off-by: Jeff Mahoney <jeffm@suse.com> [sandeen: define HAVE_STATFS_FLAGS in io/Makefile] Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r--configure.ac1
-rw-r--r--include/builddefs.in1
-rw-r--r--io/Makefile4
-rw-r--r--io/stat.c2
-rw-r--r--m4/package_libcdev.m414
5 files changed, 22 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 6678207a1f..bf30117702 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,6 +162,7 @@ AC_HAVE_FSETXATTR
AC_HAVE_MREMAP
AC_NEED_INTERNAL_FSXATTR
AC_HAVE_GETFSMAP
+AC_HAVE_STATFS_FLAGS
if test "$enable_blkid" = yes; then
AC_HAVE_BLKID_TOPO
diff --git a/include/builddefs.in b/include/builddefs.in
index 1d454b6ebf..fd274ddc66 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -114,6 +114,7 @@ HAVE_FSETXATTR = @have_fsetxattr@
HAVE_MREMAP = @have_mremap@
NEED_INTERNAL_FSXATTR = @need_internal_fsxattr@
HAVE_GETFSMAP = @have_getfsmap@
+HAVE_STATFS_FLAGS = @have_statfs_flags@
GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
# -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
diff --git a/io/Makefile b/io/Makefile
index 050d6bd012..6725936d82 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -110,6 +110,10 @@ ifeq ($(PKG_PLATFORM),linux)
CFILES += fsmap.c
endif
+ifeq ($(HAVE_STATFS_FLAGS),yes)
+LCFLAGS += -DHAVE_STATFS_FLAGS
+endif
+
default: depend $(LTCOMMAND)
include $(BUILDRULES)
diff --git a/io/stat.c b/io/stat.c
index ffe285c45d..41d4215257 100644
--- a/io/stat.c
+++ b/io/stat.c
@@ -199,7 +199,9 @@ statfs_f(
printf(_("statfs.f_bavail = %lld\n"), (long long) st.f_bavail);
printf(_("statfs.f_files = %lld\n"), (long long) st.f_files);
printf(_("statfs.f_ffree = %lld\n"), (long long) st.f_ffree);
+#ifdef HAVE_STATFS_FLAGS
printf(_("statfs.f_flags = 0x%llx\n"), (long long) st.f_flags);
+#endif
}
if (file->flags & IO_FOREIGN)
return 0;
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index fdf9d69c24..7b4dfc8553 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -314,3 +314,17 @@ AC_DEFUN([AC_HAVE_GETFSMAP],
AC_MSG_RESULT(no))
AC_SUBST(have_getfsmap)
])
+
+AC_DEFUN([AC_HAVE_STATFS_FLAGS],
+ [
+ AC_CHECK_TYPE(struct statfs,
+ [
+ AC_CHECK_MEMBER(struct statfs.f_flags,
+ have_statfs_flags=yes,,
+ [#include <sys/vfs.h>]
+ )
+ ],,
+ [#include <sys/vfs.h>]
+ )
+ AC_SUBST(have_statfs_flags)
+ ])