From: Petr Vorel <petr.vorel@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
Date: Mon, 17 Jun 2019 23:31:38 +0200 [thread overview]
Message-ID: <20190617213138.15896-1-petr.vorel@gmail.com> (raw)
This fixes build for musl, which does not have <sys/ustat.h> nor
typedef daddr_t. Musl does not define these as ustat is deprecated
in favor of statfs() and daddr_t is ancient [1].
Other libc also does not have <sys/ustat.h> (ustat support was removed
from glibc in 2.28), but they have daddr_t.
This brings <linux/types.h> dependency for ustat testing.
Typedef is needed as sparc and mips have __kernel_daddr_t long,
otherwise it's int.
[1] https://www.openwall.com/lists/musl/2019/06/10/1
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
configure.ac | 1 +
include/lapi/ustat.h | 5 +++--
testcases/kernel/syscalls/ustat/ustat01.c | 8 +++++++-
testcases/kernel/syscalls/ustat/ustat02.c | 8 +++++++-
4 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 53ad784d7..8ca7e8065 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,7 @@ AC_CHECK_HEADERS([ \
linux/mempolicy.h \
linux/module.h \
linux/netlink.h \
+ linux/types.h \
linux/userfaultfd.h \
mm.h \
netinet/sctp.h \
diff --git a/include/lapi/ustat.h b/include/lapi/ustat.h
index 12c073582..98633e749 100644
--- a/include/lapi/ustat.h
+++ b/include/lapi/ustat.h
@@ -9,9 +9,10 @@
#ifdef HAVE_SYS_USTAT_H
# include <sys/ustat.h>
-#else
+#elif HAVE_LINUX_TYPES_H
+# include <linux/types.h>
struct ustat {
- daddr_t f_tfree;
+ __kernel_daddr_t f_tfree;
ino_t f_tinode;
char f_fname[6];
char f_fpack[6];
diff --git a/testcases/kernel/syscalls/ustat/ustat01.c b/testcases/kernel/syscalls/ustat/ustat01.c
index 2e7dcc9d7..0252858be 100644
--- a/testcases/kernel/syscalls/ustat/ustat01.c
+++ b/testcases/kernel/syscalls/ustat/ustat01.c
@@ -5,6 +5,10 @@
* Check that ustat() succeeds given correct parameters.
*/
+#include "config.h"
+#include "tst_test.h"
+
+#if defined(HAVE_SYS_USTAT_H) || defined(HAVE_LINUX_TYPES_H)
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
@@ -12,7 +16,6 @@
#include "lapi/syscalls.h"
#include "lapi/ustat.h"
-#include "tst_test.h"
static dev_t dev_num;
@@ -42,3 +45,6 @@ static struct tst_test test = {
.test_all = run,
.setup = setup,
};
+#else
+TST_TEST_TCONF("testing ustat requires <sys/ustat.h> or <linux/types.h>");
+#endif
diff --git a/testcases/kernel/syscalls/ustat/ustat02.c b/testcases/kernel/syscalls/ustat/ustat02.c
index 9bbe4f3f5..4c171f7b8 100644
--- a/testcases/kernel/syscalls/ustat/ustat02.c
+++ b/testcases/kernel/syscalls/ustat/ustat02.c
@@ -6,6 +6,10 @@
* invalid dev_t parameter and for bad address paramater.
*/
+#include "config.h"
+#include "tst_test.h"
+
+#if defined(HAVE_SYS_USTAT_H) || defined(HAVE_LINUX_TYPES_H)
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
@@ -13,7 +17,6 @@
#include "lapi/syscalls.h"
#include "lapi/ustat.h"
-#include "tst_test.h"
static dev_t invalid_dev = -1;
static dev_t root_dev;
@@ -61,3 +64,6 @@ static struct tst_test test = {
.setup = setup,
.tcnt = ARRAY_SIZE(tc),
};
+#else
+TST_TEST_TCONF("testing ustat requires <sys/ustat.h> or <linux/types.h>");
+#endif
--
2.20.1
next reply other threads:[~2019-06-17 21:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 21:31 Petr Vorel [this message]
2019-07-17 17:34 ` [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t Petr Vorel
2019-07-18 8:26 ` Cyril Hrubis
2019-07-29 14:47 ` Petr Vorel
2019-07-18 7:01 ` Li Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190617213138.15896-1-petr.vorel@gmail.com \
--to=petr.vorel@gmail.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox