public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/3] fanotify musl fixes
@ 2019-11-13  0:56 Petr Vorel
  2019-11-13  0:56 ` [LTP] [PATCH v2 1/3] fanotify: Move __kernel_fsid_t definition to correct place Petr Vorel
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Petr Vorel @ 2019-11-13  0:56 UTC (permalink / raw)
  To: ltp

Hi,

I generalized previous patch set a bit via autotools checks and also add
other cleanup (base decisions whether to define fallback definitions on
autotools checks).

BTW I tempted to use <linux/fanotify.h>, but not only we'd have to
define fanotify_mark(), but we'd also lost libc header testing.

https://travis-ci.org/pevik/ltp/builds/611138280
(openSUSE Tumbleweed failure is not related to this change)

Kind regards,
Petr

Petr Vorel (3):
  fanotify: Move __kernel_fsid_t definition to correct place
  fanotify: Rework checks for fallback definitions
  fanotify: Detect val vs. __val fanotify_event_info_fid.fsid member

 configure.ac                                  |  1 +
 m4/ltp-fanotify.m4                            |  8 +++++
 testcases/kernel/syscalls/fanotify/fanotify.h | 32 ++++++++++++-------
 .../kernel/syscalls/fanotify/fanotify13.c     |  8 ++---
 .../kernel/syscalls/fanotify/fanotify15.c     |  4 +--
 5 files changed, 35 insertions(+), 18 deletions(-)
 create mode 100644 m4/ltp-fanotify.m4

-- 
2.24.0


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

* [LTP] [PATCH v2 1/3] fanotify: Move __kernel_fsid_t definition to correct place
  2019-11-13  0:56 [LTP] [PATCH v2 0/3] fanotify musl fixes Petr Vorel
@ 2019-11-13  0:56 ` Petr Vorel
  2019-11-13  0:56 ` [LTP] [PATCH v2 2/3] fanotify: Rework checks for fallback definitions Petr Vorel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2019-11-13  0:56 UTC (permalink / raw)
  To: ltp

This fixes errors:

fanotify.h:149:55: error: unknown type name ?__kernel_fsid_t?
 static inline void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid,
                                                       ^~~~~~~~~~~~~~~
fanotify13.c:47:2: error: unknown type name ?__kernel_fsid_t?
  __kernel_fsid_t fsid;

Remove #ifdef HAVE_NAME_TO_HANDLE_AT wrap of __kernel_fsid_t fallback
definition to simplify preprocessor checks.

Fixes: b8aebc835 ("fanotify: Fix missing __kernel_fsid_t definition")

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
 testcases/kernel/syscalls/fanotify/fanotify.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index 435f100d8..573ed5f59 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -116,6 +116,13 @@ struct fanotify_mark_type {
 	const char * name;
 };
 
+#ifndef __kernel_fsid_t
+typedef struct {
+	int	val[2];
+} lapi_fsid_t;
+#define __kernel_fsid_t lapi_fsid_t
+#endif /* __kernel_fsid_t */
+
 #ifndef FAN_REPORT_FID
 #define FAN_REPORT_FID		0x00000200
 
@@ -126,20 +133,13 @@ struct fanotify_event_info_header {
 };
 
 #ifdef HAVE_NAME_TO_HANDLE_AT
-#ifndef __kernel_fsid_t
-typedef struct {
-	int	val[2];
-} lapi_fsid_t;
-#define __kernel_fsid_t lapi_fsid_t
-#endif
-
 struct fanotify_event_info_fid {
 	struct fanotify_event_info_header hdr;
 	__kernel_fsid_t fsid;
 	unsigned char handle[0];
 };
-#endif
-#endif
+#endif /* HAVE_NAME_TO_HANDLE_AT */
+#endif /* ! FAN_REPORT_FID */
 
 #ifdef HAVE_NAME_TO_HANDLE_AT
 /*
-- 
2.24.0


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

* [LTP] [PATCH v2 2/3] fanotify: Rework checks for fallback definitions
  2019-11-13  0:56 [LTP] [PATCH v2 0/3] fanotify musl fixes Petr Vorel
  2019-11-13  0:56 ` [LTP] [PATCH v2 1/3] fanotify: Move __kernel_fsid_t definition to correct place Petr Vorel
@ 2019-11-13  0:56 ` Petr Vorel
  2019-11-13  0:56 ` [LTP] [PATCH v2 3/3] fanotify: Detect val vs. __val fanotify_event_info_fid.fsid member Petr Vorel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2019-11-13  0:56 UTC (permalink / raw)
  To: ltp

Add autoconf checks for struct fanotify_event_info_fid
and struct fanotify_event_info_header.

Instead of detecting via FAN_REPORT_FID or HAVE_NAME_TO_HANDLE_AT.

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Changes v1->v2:
New commit.

 configure.ac                                  |  1 +
 m4/ltp-fanotify.m4                            |  7 +++++++
 testcases/kernel/syscalls/fanotify/fanotify.h | 14 ++++++++------
 3 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 m4/ltp-fanotify.m4

diff --git a/configure.ac b/configure.ac
index 62c5a0bb4..71738b72d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -212,6 +212,7 @@ LTP_CHECK_CAPABILITY_SUPPORT
 LTP_CHECK_CC_WARN_OLDSTYLE
 LTP_CHECK_CLONE_SUPPORTS_7_ARGS
 LTP_CHECK_CRYPTO
+LTP_CHECK_FANOTIFY
 LTP_CHECK_FIDEDUPE
 LTP_CHECK_FORTIFY_SOURCE
 LTP_CHECK_FTS_H
diff --git a/m4/ltp-fanotify.m4 b/m4/ltp-fanotify.m4
new file mode 100644
index 000000000..e7b77d8a4
--- /dev/null
+++ b/m4/ltp-fanotify.m4
@@ -0,0 +1,7 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) 2019 Petr Vorel <petr.vorel@gmail.com>
+
+AC_DEFUN([LTP_CHECK_FANOTIFY],[
+AC_CHECK_TYPES([struct fanotify_event_info_header],,,[#include <sys/fanotify.h>])
+AC_CHECK_TYPES([struct fanotify_event_info_fid],,,[#include <sys/fanotify.h>])
+])
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index 573ed5f59..9d2fded13 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -101,6 +101,10 @@ static long fanotify_mark(int fd, unsigned int flags, uint64_t mask,
 #define FAN_OPEN_EXEC_PERM	0x00040000
 #endif
 
+#ifndef FAN_REPORT_FID
+#define FAN_REPORT_FID		0x00000200
+#endif
+
 /*
  * FAN_ALL_PERM_EVENTS has been deprecated, so any new permission events
  * are not to be added to it. To cover the instance where a new permission
@@ -123,23 +127,21 @@ typedef struct {
 #define __kernel_fsid_t lapi_fsid_t
 #endif /* __kernel_fsid_t */
 
-#ifndef FAN_REPORT_FID
-#define FAN_REPORT_FID		0x00000200
-
+#ifndef HAVE_STRUCT_FANOTIFY_EVENT_INFO_HEADER
 struct fanotify_event_info_header {
 	uint8_t info_type;
 	uint8_t pad;
 	uint16_t len;
 };
+#endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_HEADER */
 
-#ifdef HAVE_NAME_TO_HANDLE_AT
+#ifndef HAVE_STRUCT_FANOTIFY_EVENT_INFO_FID
 struct fanotify_event_info_fid {
 	struct fanotify_event_info_header hdr;
 	__kernel_fsid_t fsid;
 	unsigned char handle[0];
 };
-#endif /* HAVE_NAME_TO_HANDLE_AT */
-#endif /* ! FAN_REPORT_FID */
+#endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_FID */
 
 #ifdef HAVE_NAME_TO_HANDLE_AT
 /*
-- 
2.24.0


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

* [LTP] [PATCH v2 3/3] fanotify: Detect val vs. __val fanotify_event_info_fid.fsid member
  2019-11-13  0:56 [LTP] [PATCH v2 0/3] fanotify musl fixes Petr Vorel
  2019-11-13  0:56 ` [LTP] [PATCH v2 1/3] fanotify: Move __kernel_fsid_t definition to correct place Petr Vorel
  2019-11-13  0:56 ` [LTP] [PATCH v2 2/3] fanotify: Rework checks for fallback definitions Petr Vorel
@ 2019-11-13  0:56 ` Petr Vorel
  2019-11-13  5:58 ` [LTP] [PATCH v2 0/3] fanotify musl fixes Jan Stancek
  2019-11-13  9:48 ` Cyril Hrubis
  4 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2019-11-13  0:56 UTC (permalink / raw)
  To: ltp

via FSID_VAL_MEMBER() macro and autotools detection.

This fixes build on musl, which also defines fanotify_event_info_fid,
but uses fsid_t type for fsid instead of __kernel_fsid_t.
fsid_t type has __val[2] member (unlike val[2] in __kernel_fsid_t).

Fixed error:

fanotify13.c: In function ?do_test?:
fanotify13.c:278:20: error: ?fsid_t? {aka ?struct __fsid_t?} has no member named ?val?; did you mean ?__val??
    event_fid->fsid.val[0],
		    ^~~
../../../../include/tst_test.h:49:53: note: in definition of macro ?tst_res?
  tst_res_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__)
						     ^~~~~~~~~~~
fanotify13.c:279:20: error: ?fsid_t? {aka ?struct __fsid_t?} has no member named ?val?; did you mean ?__val??
    event_fid->fsid.val[1],

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
Changes v1->v2:
* access members via macro FSID_VAL_MEMBER()
* use autotools detection 

 m4/ltp-fanotify.m4                              | 1 +
 testcases/kernel/syscalls/fanotify/fanotify.h   | 6 ++++++
 testcases/kernel/syscalls/fanotify/fanotify13.c | 8 ++++----
 testcases/kernel/syscalls/fanotify/fanotify15.c | 4 ++--
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/m4/ltp-fanotify.m4 b/m4/ltp-fanotify.m4
index e7b77d8a4..f2e31eb68 100644
--- a/m4/ltp-fanotify.m4
+++ b/m4/ltp-fanotify.m4
@@ -4,4 +4,5 @@ dnl Copyright (c) 2019 Petr Vorel <petr.vorel@gmail.com>
 AC_DEFUN([LTP_CHECK_FANOTIFY],[
 AC_CHECK_TYPES([struct fanotify_event_info_header],,,[#include <sys/fanotify.h>])
 AC_CHECK_TYPES([struct fanotify_event_info_fid],,,[#include <sys/fanotify.h>])
+AC_CHECK_MEMBERS([struct fanotify_event_info_fid.fsid.__val],,,[#include <sys/fanotify.h>])
 ])
diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index 9d2fded13..5370e30bb 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -143,6 +143,12 @@ struct fanotify_event_info_fid {
 };
 #endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_FID */
 
+#ifdef HAVE_STRUCT_FANOTIFY_EVENT_INFO_FID_FSID___VAL
+# define FSID_VAL_MEMBER(fsid, i) (fsid.__val[i])
+#else
+# define FSID_VAL_MEMBER(fsid, i) (fsid.val[i])
+#endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_FID_FSID___VAL */
+
 #ifdef HAVE_NAME_TO_HANDLE_AT
 /*
  * Helper function used to obtain fsid and file_handle for a given path.
diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index 030734285..b0d9fb5b6 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -130,8 +130,8 @@ static int setup_marks(unsigned int fd, struct test_case_t *tc)
 					"kernel");
 				return 1;
 			} else if (errno == ENODEV &&
-					!event_set[i].fsid.val[0] &&
-					!event_set[i].fsid.val[1]) {
+					!FSID_VAL_MEMBER(event_set[i].fsid, 0) &&
+					!FSID_VAL_MEMBER(event_set[i].fsid, 1)) {
 				tst_res(TCONF,
 					"FAN_REPORT_FID not supported on "
 					"filesystem type %s",
@@ -275,8 +275,8 @@ static void do_test(unsigned int number)
 			"and name_to_handle_at(2)",
 			metadata->mask,
 			getpid(),
-			event_fid->fsid.val[0],
-			event_fid->fsid.val[1],
+			FSID_VAL_MEMBER(event_fid->fsid, 0),
+			FSID_VAL_MEMBER(event_fid->fsid, 1),
 			*(unsigned long *) event_file_handle->f_handle);
 	}
 out:
diff --git a/testcases/kernel/syscalls/fanotify/fanotify15.c b/testcases/kernel/syscalls/fanotify/fanotify15.c
index e9e926078..48ed368ae 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify15.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify15.c
@@ -192,8 +192,8 @@ static void do_test(void)
 				"fid=%x.%x.%lx values",
 				metadata->mask,
 				getpid(),
-				event_fid->fsid.val[0],
-				event_fid->fsid.val[1],
+				FSID_VAL_MEMBER(event_fid->fsid, 0),
+				FSID_VAL_MEMBER(event_fid->fsid, 1),
 				*(unsigned long *)
 				event_file_handle->f_handle);
 		}
-- 
2.24.0


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

* [LTP] [PATCH v2 0/3] fanotify musl fixes
  2019-11-13  0:56 [LTP] [PATCH v2 0/3] fanotify musl fixes Petr Vorel
                   ` (2 preceding siblings ...)
  2019-11-13  0:56 ` [LTP] [PATCH v2 3/3] fanotify: Detect val vs. __val fanotify_event_info_fid.fsid member Petr Vorel
@ 2019-11-13  5:58 ` Jan Stancek
  2019-11-13  9:48 ` Cyril Hrubis
  4 siblings, 0 replies; 7+ messages in thread
From: Jan Stancek @ 2019-11-13  5:58 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> Hi,
> 
> I generalized previous patch set a bit via autotools checks and also add
> other cleanup (base decisions whether to define fallback definitions on
> autotools checks).
> 
> BTW I tempted to use <linux/fanotify.h>, but not only we'd have to
> define fanotify_mark(), but we'd also lost libc header testing.
> 
> https://travis-ci.org/pevik/ltp/builds/611138280
> (openSUSE Tumbleweed failure is not related to this change)

Hi Petr,

looks good to me. 2/3 rework makes it easier to follow too.
I tried it on couple old/new RHEL distros with no issues.

Acked-by: Jan Stancek <jstancek@redhat.com>


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

* [LTP] [PATCH v2 0/3] fanotify musl fixes
  2019-11-13  0:56 [LTP] [PATCH v2 0/3] fanotify musl fixes Petr Vorel
                   ` (3 preceding siblings ...)
  2019-11-13  5:58 ` [LTP] [PATCH v2 0/3] fanotify musl fixes Jan Stancek
@ 2019-11-13  9:48 ` Cyril Hrubis
  2019-11-14 18:17   ` Petr Vorel
  4 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2019-11-13  9:48 UTC (permalink / raw)
  To: ltp

Hi!
This version looks good to me as well, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2 0/3] fanotify musl fixes
  2019-11-13  9:48 ` Cyril Hrubis
@ 2019-11-14 18:17   ` Petr Vorel
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Vorel @ 2019-11-14 18:17 UTC (permalink / raw)
  To: ltp

Hi Cyril, Jan,

> Hi!
> This version looks good to me as well, acked.

thanks both for your review, merged.

Kind regards,
Petr

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

end of thread, other threads:[~2019-11-14 18:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-13  0:56 [LTP] [PATCH v2 0/3] fanotify musl fixes Petr Vorel
2019-11-13  0:56 ` [LTP] [PATCH v2 1/3] fanotify: Move __kernel_fsid_t definition to correct place Petr Vorel
2019-11-13  0:56 ` [LTP] [PATCH v2 2/3] fanotify: Rework checks for fallback definitions Petr Vorel
2019-11-13  0:56 ` [LTP] [PATCH v2 3/3] fanotify: Detect val vs. __val fanotify_event_info_fid.fsid member Petr Vorel
2019-11-13  5:58 ` [LTP] [PATCH v2 0/3] fanotify musl fixes Jan Stancek
2019-11-13  9:48 ` Cyril Hrubis
2019-11-14 18:17   ` Petr Vorel

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