From: Petr Vorel <petr.vorel@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 3/3] fanotify: Detect val vs. __val fanotify_event_info_fid.fsid member
Date: Wed, 13 Nov 2019 01:56:26 +0100 [thread overview]
Message-ID: <20191113005626.19585-4-petr.vorel@gmail.com> (raw)
In-Reply-To: <20191113005626.19585-1-petr.vorel@gmail.com>
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
next prev parent reply other threads:[~2019-11-13 0:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20191113005626.19585-4-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