public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
@ 2019-06-17 21:31 Petr Vorel
  2019-07-17 17:34 ` Petr Vorel
  2019-07-18  7:01 ` Li Wang
  0 siblings, 2 replies; 5+ messages in thread
From: Petr Vorel @ 2019-06-17 21:31 UTC (permalink / raw)
  To: ltp

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
  2019-06-17 21:31 [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t Petr Vorel
@ 2019-07-17 17:34 ` Petr Vorel
  2019-07-18  8:26   ` Cyril Hrubis
  2019-07-18  7:01 ` Li Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Petr Vorel @ 2019-07-17 17:34 UTC (permalink / raw)
  To: ltp

Hi,

> 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

Ping, please.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
  2019-06-17 21:31 [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t Petr Vorel
  2019-07-17 17:34 ` Petr Vorel
@ 2019-07-18  7:01 ` Li Wang
  1 sibling, 0 replies; 5+ messages in thread
From: Li Wang @ 2019-07-18  7:01 UTC (permalink / raw)
  To: ltp

Hi Petr,

On Tue, Jun 18, 2019 at 5:32 AM Petr Vorel <petr.vorel@gmail.com> wrote:

> 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>
>
Reviewed-by: Li Wang <liwang@redhat.com>

I don't have a try to build this with musl, but from my code review, the
patch makes sense.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20190718/284ee6d4/attachment.htm>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
  2019-07-17 17:34 ` Petr Vorel
@ 2019-07-18  8:26   ` Cyril Hrubis
  2019-07-29 14:47     ` Petr Vorel
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2019-07-18  8:26 UTC (permalink / raw)
  To: ltp

Hi!
> > 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

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.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t
  2019-07-18  8:26   ` Cyril Hrubis
@ 2019-07-29 14:47     ` Petr Vorel
  0 siblings, 0 replies; 5+ messages in thread
From: Petr Vorel @ 2019-07-29 14:47 UTC (permalink / raw)
  To: ltp

Hi Cyril,

> > > 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

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-29 14:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-17 21:31 [LTP] [PATCH 1/1] syscalls/ustat: Use __kernel_daddr_t instead of daddr_t Petr Vorel
2019-07-17 17:34 ` Petr Vorel
2019-07-18  8:26   ` Cyril Hrubis
2019-07-29 14:47     ` Petr Vorel
2019-07-18  7:01 ` Li Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox