syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
PATCH 1/1 syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
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
--- 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(-)
configure.ac +1 -0
@@ -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 \
include/lapi/ustat.h +3 -2
@@ -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];
testcases/kernel/syscalls/ustat/ustat01.c +7 -1
@@ -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
testcases/kernel/syscalls/ustat/ustat02.c +7 -1
@@ -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
Signature · 1 line
2.20.1
PATCH 1/1 syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
Hi,
Quoted 7 lines
This fixes build for musl, which does not have <
sys/ustat.h> nor typedefdaddr_t. Musl does not define these as ustat is deprecated in favor ofstatfs()anddaddr_tis ancient [1].Other libc also does not have <
sys/ustat.h> (ustat support was removed from glibc in 2.28), but they havedaddr_t.
Quoted 6 lines
This brings <
linux/types.h> dependency for ustat testing.Typedef is needed as sparc and mips have
__kernel_daddr_tlong, otherwise it's int.
Ping, please.
Kind regards,
Petr
PATCH 1/1 syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
Hi!
Quoted 7 lines
Quoted 6 lines
This fixes build for musl, which does not have <
sys/ustat.h> nor typedefdaddr_t. Musl does not define these as ustat is deprecated in favor ofstatfs()anddaddr_tis ancient [1].Other libc also does not have <
sys/ustat.h> (ustat support was removed from glibc in 2.28), but they havedaddr_t.
Quoted 6 lines
Quoted 6 lines
This brings <
linux/types.h> dependency for ustat testing.Typedef is needed as sparc and mips have
__kernel_daddr_tlong, otherwise it's int.
I'm always worried when we use types starting with double underscores but let's apply this one, we can always revert it in a case that it breaks build somewhere.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
Hi Cyril,
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
This fixes build for musl, which does not have <
sys/ustat.h> nor typedefdaddr_t. Musl does not define these as ustat is deprecated in favor ofstatfs()anddaddr_tis ancient [1].Other libc also does not have <
sys/ustat.h> (ustat support was removed from glibc in 2.28), but they havedaddr_t.This brings <
linux/types.h> dependency for ustat testing.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Typedef is needed as sparc and mips have
__kernel_daddr_tlong, otherwise it's int.I'm always worried when we use types starting with double underscores but let's apply this one, we can always revert it in a case that it breaks build somewhere.
Thanks, merged.
BTW <linux/types.h> is also checked in m4/ltp-signalfd.m4 so there is duplicity in check, but I gave up cleanup it now.
Kind regards,
Petr
PATCH 1/1 syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
In reply to Petr VorelHi Petr,
Quoted 7 lines · Petr Vorel
This fixes build for musl, which does not have <
sys/ustat.h> nor typedefdaddr_t. Musl does not define these as ustat is deprecated in favor ofstatfs()anddaddr_tis ancient [1].Other libc also does not have <
sys/ustat.h> (ustat support was removed from glibc in 2.28), but they havedaddr_t.
Quoted 9 lines
This brings <
linux/types.h> dependency for ustat testing.Typedef is needed as sparc and mips have
__kernel_daddr_tlong, otherwise it's int.[1] https://www.openwall.com/lists/musl/2019/06/10/1
Signed-off-by Petr Vorel <[email protected]>
I don't have a try to build this with musl, but from my code review, the patch makes sense.
Signature · 5 lines
Regards, Li Wang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.linux.it/pipermail/ltp/attachments/20190718/284ee6d4/attachment.htm>