Skip to contentSkip to conversation

syscalls/ustat: Fix build for libc without ustat() support

PATCH New Petr Vorel 2 participants 2 messages Oct 11, 2017

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v2 1/1 syscalls/ustat: Fix build for libc without ustat() support

This applies at least for uClibc/uClibc-ng with disabled __UCLIBC_SV4_DEPRECATED__.

Patch taken from buildroot project (thanks!), adjusted it not to be only uClibc/uClibc-ng specific.

---
 configure.ac                              |  6 +++++-
 testcases/kernel/syscalls/ustat/ustat01.c | 17 +++++++++++++++--
 testcases/kernel/syscalls/ustat/ustat02.c | 18 +++++++++++++++---
 3 files changed, 35 insertions(+), 6 deletions(-)
configure.ac +5 -1
index 465655e7b..17a02050a 100644
@@ -44,9 +44,13 @@ AC_CHECK_HEADERS([ \
     sys/inotify.h \
     sys/fanotify.h \
     sys/prctl.h \
+    sys/ustat.h \
 ])
 
-AC_CHECK_FUNCS([profil])
+AC_CHECK_FUNCS([ \
+    profil \
+    ustat \
+])
 
 # Tools knobs
 
testcases/kernel/syscalls/ustat/ustat01.c +15 -2
index 494647bc2..31d7f86dc 100644
@@ -21,15 +21,22 @@
 
 #include <unistd.h>
 #include <errno.h>
-#include <sys/ustat.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#include "config.h"
 #include "test.h"
 #include "safe_macros.h"
 
+char *TCID = "ustat01";
+
+#ifdef HAVE_USTAT
+# ifdef HAVE_SYS_USTAT_H
+#  include <sys/ustat.h>
+# endif
+
 static void setup(void);
 
-char *TCID = "ustat01";
 int TST_TOTAL = 1;
 
 static dev_t dev_num;
@@ -79,3 +86,9 @@ static void setup(void)
 
 	dev_num = buf.st_dev;
 }
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "system doesn't have ustat() support");
+}
+#endif
testcases/kernel/syscalls/ustat/ustat02.c +15 -3
index edada3107..fe644f9a9 100644
@@ -22,16 +22,22 @@
 
 #include <unistd.h>
 #include <errno.h>
-#include <sys/ustat.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+
+#include "config.h"
 #include "test.h"
 #include "safe_macros.h"
 
-static void setup(void);
-
 char *TCID = "ustat02";
 
+#ifdef HAVE_USTAT
+# ifdef HAVE_SYS_USTAT_H
+#  include <sys/ustat.h>
+# endif
+
+static void setup(void);
+
 static dev_t invalid_dev = -1;
 static dev_t root_dev;
 struct ustat ubuf;
@@ -101,3 +107,9 @@ static void setup(void)
 
 	root_dev = buf.st_dev;
 }
+#else
+int main(void)
+{
+	tst_brkm(TCONF, NULL, "system doesn't have ustat() support");
+}
+#endif
Signature · 1 line
2.14.2