mbox series

[v5,0/4] syscalls/fanotify: FAN_REPORT_FID and Directory Modification Events

Message ID cover.1561018312.git.mbobrowski@mbobrowski.org
Headers show
Series syscalls/fanotify: FAN_REPORT_FID and Directory Modification Events | expand

Message

Matthew Bobrowski June 20, 2019, 9:57 a.m. UTC
This patch series contains the changes needed to validate the new
FAN_REPORT_FID flag and directory modification event functionality
within the fanotify API.

Changes since version 4:
	* Fixed problems with unbalanced file descriptor close.
	* Reorded functions in the test files fanotify13, fanotify14 and
	  fanotify15 so that they all follow a basic template i.e.

	  test()
	  ...
	  do_setup()
	  do_cleanup()

Thank you Amir for your feedback. 

Amir Goldstein (1):
  syscalls/fanotify13: add test coverage for fsid cache bug

Matthew Bobrowski (3):
  syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality
  syscalls/fanotify14: new test to validate FAN_REPORT_FID interface
    return values
  syscalls/fanotify15: verify fid for dirent events

 configure.ac                                    |   1 +
 runtest/syscalls                                |   3 +
 testcases/kernel/syscalls/fanotify/.gitignore   |   3 +
 testcases/kernel/syscalls/fanotify/fanotify.h   |  81 +++++-
 testcases/kernel/syscalls/fanotify/fanotify05.c |   1 +
 testcases/kernel/syscalls/fanotify/fanotify13.c | 328 ++++++++++++++++++++++++
 testcases/kernel/syscalls/fanotify/fanotify14.c | 176 +++++++++++++
 testcases/kernel/syscalls/fanotify/fanotify15.c | 246 ++++++++++++++++++
 8 files changed, 836 insertions(+), 3 deletions(-)
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify13.c
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify14.c
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify15.c

Comments

Petr Vorel June 20, 2019, 1:24 p.m. UTC | #1
Hi Amir, Matthew,

LGTM. Just one of this commits fails on centos 6

https://api.travis-ci.org/v3/job/548162141/log.txt
https://travis-ci.org/pevik/ltp/jobs/548162141

gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -D_FORTIFY_SOURCE=2 -I/usr/src/ltp/include -I/usr/src/ltp/../ltp-build/include -I/usr/src/ltp/include/old/   -L/usr/src/ltp/../ltp-build/lib  /usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify01.c   -lltp -o fanotify01
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -D_FORTIFY_SOURCE=2 -I/usr/src/ltp/include -I/usr/src/ltp/../ltp-build/include -I/usr/src/ltp/include/old/   -L/usr/src/ltp/../ltp-build/lib  /usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify02.c   -lltp -o fanotify02
In file included from /usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify01.c:21:
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:130: error: expected specifier-qualifier-list before '__kernel_fsid_t'
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:141: error: expected declaration specifiers or '...' before '__kernel_fsid_t'
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:142: warning: 'struct file_handle' declared inside parameter list
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:142: warning: its scope is only this definition or declaration, which is probably not what you want
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h: In function 'fanotify_get_fid':
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:150: error: 'fsid' undeclared (first use in this function)
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:150: error: (Each undeclared identifier is reported only once
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:150: error: for each function it appears in.)
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:144: warning: unused variable 'mount_id'
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:142: warning: unused parameter 'handle'
In file included from /usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify02.c:21:
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:130: error: expected specifier-qualifier-list before '__kernel_fsid_t'
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:141: error: expected declaration specifiers or '...' before '__kernel_fsid_t'
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:142: warning: 'struct file_handle' declared inside parameter list
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:142: warning: its scope is only this definition or declaration, which is probably not what you want
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h: In function 'fanotify_get_fid':
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:150: error: 'fsid' undeclared (first use in this function)
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:150: error: (Each undeclared identifier is reported only once
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:150: error: for each function it appears in.)
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:144: warning: unused variable 'mount_id'
/usr/src/ltp/testcases/kernel/syscalls/fanotify/fanotify.h:142: warning: unused parameter 'handle'

Kind regards,
Petr

> This patch series contains the changes needed to validate the new
> FAN_REPORT_FID flag and directory modification event functionality
> within the fanotify API.

> Changes since version 4:
> 	* Fixed problems with unbalanced file descriptor close.
> 	* Reorded functions in the test files fanotify13, fanotify14 and
> 	  fanotify15 so that they all follow a basic template i.e.

> 	  test()
> 	  ...
> 	  do_setup()
> 	  do_cleanup()

> Thank you Amir for your feedback. 

> Amir Goldstein (1):
>   syscalls/fanotify13: add test coverage for fsid cache bug

> Matthew Bobrowski (3):
>   syscalls/fanotify13: new test to verify FAN_REPORT_FID functionality
>   syscalls/fanotify14: new test to validate FAN_REPORT_FID interface
>     return values
>   syscalls/fanotify15: verify fid for dirent events

>  configure.ac                                    |   1 +
>  runtest/syscalls                                |   3 +
>  testcases/kernel/syscalls/fanotify/.gitignore   |   3 +
>  testcases/kernel/syscalls/fanotify/fanotify.h   |  81 +++++-
>  testcases/kernel/syscalls/fanotify/fanotify05.c |   1 +
>  testcases/kernel/syscalls/fanotify/fanotify13.c | 328 ++++++++++++++++++++++++
>  testcases/kernel/syscalls/fanotify/fanotify14.c | 176 +++++++++++++
>  testcases/kernel/syscalls/fanotify/fanotify15.c | 246 ++++++++++++++++++
>  8 files changed, 836 insertions(+), 3 deletions(-)
>  create mode 100644 testcases/kernel/syscalls/fanotify/fanotify13.c
>  create mode 100644 testcases/kernel/syscalls/fanotify/fanotify14.c
>  create mode 100644 testcases/kernel/syscalls/fanotify/fanotify15.c
Amir Goldstein June 20, 2019, 1:57 p.m. UTC | #2
On Thu, Jun 20, 2019 at 4:24 PM Petr Vorel <pvorel@suse.cz> wrote:
>
> Hi Amir, Matthew,
>
> LGTM. Just one of this commits fails on centos 6

Hi Petr,

Can you please try attached patch.

Thanks,
Amir.
From 7d0feb7d7d9677cf348643bddf10507d2d1f0c3a Mon Sep 17 00:00:00 2001
From: Amir Goldstein <amir73il@gmail.com>
Date: Thu, 20 Jun 2019 16:53:46 +0300
Subject: [PATCH] syscalls/fanotify: fix build errors on centos 6

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 testcases/kernel/syscalls/fanotify/fanotify.h | 22 +++++++++++--------
 .../kernel/syscalls/fanotify/fanotify13.c     |  2 +-
 .../kernel/syscalls/fanotify/fanotify15.c     |  2 +-
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify.h b/testcases/kernel/syscalls/fanotify/fanotify.h
index f9803c1cc..05b4d9f2c 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify.h
+++ b/testcases/kernel/syscalls/fanotify/fanotify.h
@@ -125,21 +125,25 @@ struct fanotify_event_info_header {
 	uint16_t len;
 };
 
+typedef struct {
+        int     val[2];
+} ltp_fsid_t;
+
 struct fanotify_event_info_fid {
 	struct fanotify_event_info_header hdr;
-	__kernel_fsid_t fsid;
+	ltp_fsid_t fsid;
 	unsigned char handle[0];
 };
 
 #endif
 
+#ifdef HAVE_NAME_TO_HANDLE_AT
 /*
- * Helper function used to obtain __kernel_fsid_t and file_handle objects
- * for a given path. Used by test files correlated to FAN_REPORT_FID
- * functionality.
+ * Helper function used to obtain fsid and file_handle for a given path.
+ * Used by test files correlated to FAN_REPORT_FID functionality.
  */
-static inline void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid,
-			struct file_handle *handle)
+static inline void fanotify_get_fid(const char *path, ltp_fsid_t *fsid,
+				    struct file_handle *handle)
 {
 	int mount_id;
 	struct statfs stats;
@@ -149,7 +153,6 @@ static inline void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid,
 			"statfs(%s, ...) failed", path);
 	memcpy(fsid, &stats.f_fsid, sizeof(stats.f_fsid));
 
-#ifdef HAVE_NAME_TO_HANDLE_AT
 	if (name_to_handle_at(AT_FDCWD, path, handle, &mount_id, 0) == -1) {
 		if (errno == EOPNOTSUPP) {
 			tst_brk(TCONF,
@@ -159,10 +162,11 @@ static inline void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid,
 		tst_brk(TBROK | TERRNO,
 			"name_to_handle_at(AT_FDCWD, %s, ...) failed", path);
 	}
+}
 #else
-	tst_brk(TCONF, "name_to_handle_at() is not implmented");
+#define fanotify_get_fid(path, fsid, handle) \
+	tst_brk(TCONF, "System does not have required name_to_handle_at() support")
 #endif /* HAVE_NAME_TO_HANDLE_AT */
-}
 
 #define INIT_FANOTIFY_MARK_TYPE(t) \
 	{ FAN_MARK_ ## t, "FAN_MARK_" #t }
diff --git a/testcases/kernel/syscalls/fanotify/fanotify13.c b/testcases/kernel/syscalls/fanotify/fanotify13.c
index 8f9baacfa..f79322fd0 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify13.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify13.c
@@ -40,7 +40,7 @@
 
 struct event_t {
 	unsigned long long expected_mask;
-	__kernel_fsid_t fsid;
+	ltp_fsid_t fsid;
 	struct file_handle handle;
 	char buf[MAX_HANDLE_SZ];
 };
diff --git a/testcases/kernel/syscalls/fanotify/fanotify15.c b/testcases/kernel/syscalls/fanotify/fanotify15.c
index 6981b7891..3be913ba4 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify15.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify15.c
@@ -37,7 +37,7 @@
 
 struct event_t {
 	unsigned long long mask;
-	__kernel_fsid_t fsid;
+	ltp_fsid_t fsid;
 	struct file_handle handle;
 	char buf[MAX_HANDLE_SZ];
 };
Amir Goldstein June 20, 2019, 2:04 p.m. UTC | #3
On Thu, Jun 20, 2019 at 4:57 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Thu, Jun 20, 2019 at 4:24 PM Petr Vorel <pvorel@suse.cz> wrote:
> >
> > Hi Amir, Matthew,
> >
> > LGTM. Just one of this commits fails on centos 6
>
> Hi Petr,
>
> Can you please try attached patch.
>

Wait, it's not enough.
I'll post a new patch.

Thanks,
Amir.