syscalls/fanotify08: add sanity check for FAN_CLOEXEC
PATCH 1/1 syscalls/fanotify08: add sanity check for FAN_CLOEXEC
--- testcases/kernel/syscalls/fanotify/fanotify08.c | 144 ++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify08.c
testcases/kernel/syscalls/fanotify/fanotify08.c new file +144 -0
@@ -0,0 +1,144 @@ +/* +* Copyright (c) 2017 RedHat. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* Further, this software is distributed without any warranty that it is +* free of the rightful claim of any third person regarding infringement +* or the like. Any license provided herein, whether implied or +* otherwise, applies only to this software file. Patent licenses, if +* any, provided herein do not apply to combinations of this program with +* other software, or any other product whatsoever. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Started by Xiong Zhou <[email protected]> +* +* DESCRIPTION +* Check fanotify_init flag O_CLOEXEC. +*/ +#define _GNU_SOURCE +#include "config.h" + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <sys/syscall.h> +#include "test.h" +#include "linux_syscall_numbers.h" +#include "fanotify.h" +#include "safe_macros.h" + +char *TCID ="fanotify01" ; +int TST_TOTAL =12 ; + +#if defined(HAVE_SYS_FANOTIFY_H ) +#include <sys/fanotify.h> + +#define EVENT_MAX 1024 +/* size of the event structure, not counting name */ +#define EVENT_SIZE (sizeof (struct fanotify_event_metadata)) +/* reasonable guess as to size of 1024 events */ +#define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE) + +static void setup (void ); +static void cleanup (void ); + +#define BUF_SIZE 256 +static int fd_notify; + +int main (int ac,char **av) +{ +int lc; + +tst_parse_opts (ac, av,NULL ,NULL ); + +setup (); + +for (lc =0 ;TEST_LOOPING (lc); lc++) { +int coe; + + tst_count =0 ; + +if ((fd_notify =fanotify_init (FAN_CLASS_NOTIF , +O_RDONLY )) <0 ) { +if (errno ==ENOSYS ) { +tst_brkm (TCONF , cleanup, +"fanotify is not configured in this kernel." ); + }else { +tst_brkm (TBROK |TERRNO , cleanup, +"fanotify_init failed" ); + } + } + + coe =fcntl (fd_notify,F_GETFD ); +if (coe ==-1 ) { +tst_brkm (TBROK |TERRNO , cleanup, +"fcntl failed" ); + } +if (coe &FD_CLOEXEC ) { +tst_brkm (TFAIL , cleanup, +"fanotify_init set close-on-exit" ); + } +close (fd_notify); + +if ((fd_notify =fanotify_init (FAN_CLASS_NOTIF |FAN_CLOEXEC , +O_RDONLY )) <0 ) { +if (errno ==ENOSYS ) { +tst_brkm (TCONF , cleanup, +"fanotify is not configured in this kernel." ); + }else { +tst_brkm (TBROK |TERRNO , cleanup, +"fanotify_init(FAN_CLOEXEC) failed" ); + } + } + + coe =fcntl (fd_notify,F_GETFD ); +if (coe ==-1 ) { +tst_brkm (TBROK |TERRNO , cleanup,"fcntl failed" ); + }else if ((coe &FD_CLOEXEC ) ==0 ) { +tst_brkm (TFAIL , cleanup, +"fanotify_init set close-on-exit" ); + }else { +tst_resm (TPASS ,"fanotify_init(FAN_CLOEXEC) PASSED" ); + } +close (fd_notify); + } + +cleanup (); +tst_exit (); +} + +static void setup (void ) +{ +tst_sig (NOFORK ,DEF_HANDLER , cleanup); + +TEST_PAUSE ; + +tst_tmpdir (); +} + +static void cleanup (void ) +{ +tst_rmdir (); +} + +#else + +int main (void ) +{ +tst_brkm (TCONF ,NULL ,"system doesn't have required fanotify support" ); +} + +#endif
Signature · 1 line
1.8.3.1
PATCH 1/1 syscalls/fanotify08: add sanity check for FAN_CLOEXEC
Hi!
Quoted 1 line
Signed-off-by Xiong Zhou <[email protected]>
First of all, new testcases has to be coded using the new library API, that's the one you get with including the tst_test.h header instead of test.h.
Quoted 54 lines
--- testcases/kernel/syscalls/fanotify/fanotify08.c | 144 ++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify08.ctestcases/kernel/syscalls/fanotify/fanotify08.c new file +43
-0@@ -0,0 +1,144 @@ +/* +* Copyright (c) 2017 RedHat. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* Further, this software is distributed without any warranty that it is +* free of the rightful claim of any third person regarding infringement +* or the like. Any license provided herein, whether implied or +* otherwise, applies only to this software file. Patent licenses, if +* any, provided herein do not apply to combinations of this program with +* other software, or any other product whatsoever. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Started by Xiong Zhou <[email protected]> +* +* DESCRIPTION +* Check fanotify_init flag O_CLOEXEC. +*/ +#define _GNU_SOURCE +#include "config.h" + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <sys/syscall.h> +#include "test.h" +#include "linux_syscall_numbers.h" +#include "fanotify.h" +#include "safe_macros.h" + +char *TCID ="fanotify01" ;
testcases/kernel/syscalls/fanotify/fanotify08.c line 53
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +10
-0+int TST_TOTAL =12 ; + +#if defined(HAVE_SYS_FANOTIFY_H ) +#include <sys/fanotify.h> + +#define EVENT_MAX 1024 +/* size of the event structure, not counting name */ +#define EVENT_SIZE (sizeof (struct fanotify_event_metadata)) +/* reasonable guess as to size of 1024 events */ +#define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE)
These macros are unused.
Quoted 17 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +17
-0+static void setup (void ); +static void cleanup (void ); + +#define BUF_SIZE 256 +static int fd_notify; + +int main (int ac,char **av) +{ +int lc; + +tst_parse_opts (ac, av,NULL ,NULL ); + +setup (); + +for (lc =0 ;TEST_LOOPING (lc); lc++) { +int coe; +
testcases/kernel/syscalls/fanotify/fanotify08.c line 81
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +10
-0+ tst_count =0 ; + +if ((fd_notify =fanotify_init (FAN_CLASS_NOTIF , +O_RDONLY )) <0 ) { +if (errno ==ENOSYS ) { +tst_brkm (TCONF , cleanup, +"fanotify is not configured in this kernel." ); + }else { +tst_brkm (TBROK |TERRNO , cleanup, +"fanotify_init failed" );
Else branch in a case that the if () branch calls tst_brkm() is useless. The tst_brkm() exit the test so the test will not exit the if () branch once it gets there.
testcases/kernel/syscalls/fanotify/fanotify08.c line 89
Quoted 8 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +8
-0+ } + } + + coe =fcntl (fd_notify,F_GETFD ); +if (coe ==-1 ) { +tst_brkm (TBROK |TERRNO , cleanup, +"fcntl failed" ); + }
Don't we have SAFE_FCNTL()?
testcases/kernel/syscalls/fanotify/fanotify08.c line 92
Quoted 3 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +3
-0+if (coe &FD_CLOEXEC ) { +tst_brkm (TFAIL , cleanup, +"fanotify_init set close-on-exit" );
This should be tst_res() instead.
testcases/kernel/syscalls/fanotify/fanotify08.c line 92
Quoted 1 line
testcases/kernel/syscalls/fanotify/fanotify08.c new file +1
-0+ }
And here should be tst_res() with TPASS.
Quoted 13 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +13
-0+close (fd_notify); + +if ((fd_notify =fanotify_init (FAN_CLASS_NOTIF |FAN_CLOEXEC , +O_RDONLY )) <0 ) { +if (errno ==ENOSYS ) { +tst_brkm (TCONF , cleanup, +"fanotify is not configured in this kernel." ); + }else { +tst_brkm (TBROK |TERRNO , cleanup, +"fanotify_init(FAN_CLOEXEC) failed" ); + } + } +
testcases/kernel/syscalls/fanotify/fanotify08.c line 116
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +10
-0+ coe =fcntl (fd_notify,F_GETFD ); +if (coe ==-1 ) { +tst_brkm (TBROK |TERRNO , cleanup,"fcntl failed" ); + }else if ((coe &FD_CLOEXEC ) ==0 ) { +tst_brkm (TFAIL , cleanup, +"fanotify_init set close-on-exit" ); + }else { +tst_resm (TPASS ,"fanotify_init(FAN_CLOEXEC) PASSED" ); + } +close (fd_notify);
This part is more or less the same, maybe the code should be put into a function that gets either FAN_CLOEXEC or 0 as a parameter.
testcases/kernel/syscalls/fanotify/fanotify08.c line 129
Quoted 13 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +13
-0+ } + +cleanup (); +tst_exit (); +} + +static void setup (void ) +{ +tst_sig (NOFORK ,DEF_HANDLER , cleanup); + +TEST_PAUSE ; + +tst_tmpdir ();
Do we really need to create temporary directory for this test?
Quoted 21 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +15
-0+} + +static void cleanup (void ) +{ +tst_rmdir (); +} + +#else + +int main (void ) +{ +tst_brkm (TCONF ,NULL ,"system doesn't have required fanotify support" ); +} + +#endif Signature · 5 lines
1.8.3.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 syscalls/fanotify08: add sanity check for FAN_CLOEXEC
--- testcases/kernel/syscalls/fanotify/fanotify08.c | 101 ++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify08.c
testcases/kernel/syscalls/fanotify/fanotify08.c new file +101 -0
@@ -0,0 +1,101 @@ +/* +* Copyright (c) 2017 RedHat. All Rights Reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* Further, this software is distributed without any warranty that it is +* free of the rightful claim of any third person regarding infringement +* or the like. Any license provided herein, whether implied or +* otherwise, applies only to this software file. Patent licenses, if +* any, provided herein do not apply to combinations of this program with +* other software, or any other product whatsoever. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Started by Xiong Zhou <[email protected]> +* +* DESCRIPTION +* Check fanotify_init flag O_CLOEXEC. +*/ +#define _GNU_SOURCE +#include "config.h" + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <sys/syscall.h> +#include "tst_test.h" +#include "fanotify.h" + +#if defined(HAVE_SYS_FANOTIFY_H ) +#include <sys/fanotify.h> + +static void cleanup (void ); +static void test01 (int flag); +static int fd_notify; + +void test_coe (void ) +{ +test01 (FAN_CLOEXEC ); +test01 (0 ); +} + +static void test01 (int flag) +{ +int coe; + + fd_notify =fanotify_init (FAN_CLASS_NOTIF |flag,O_RDONLY ); + +if (fd_notify <0 ) { + +if (errno ==ENOSYS ) { +tst_brk (TCONF , +"fanotify is not configured in this kernel." ); + }else { +tst_brk (TBROK |TERRNO ,"fanotify_init failed" ); + } + } + + coe =SAFE_FCNTL (fd_notify,F_GETFD ); + +if (coe &FD_CLOEXEC ) { +if (flag ==0 ) +tst_res (TFAIL ,"set close-on-exit" ); +else +tst_res (TPASS ,"set close-on-exit" ); + }else { +if (flag ==0 ) +tst_res (TPASS ,"not set close-on-exit" ); +else +tst_res (TFAIL ,"not set close-on-exit" ); + } + +SAFE_CLOSE (fd_notify); +} + +static void cleanup (void ) +{ +if (fd_notify >0 ) +SAFE_CLOSE (fd_notify); +} + +static struct tst_test test = { + .test_all = test_coe, + .cleanup = cleanup, + .needs_root =1 , +}; + +#else +TST_TEST_TCONF ("system doesn't have required fanotify support" ); +#endif
Signature · 1 line
1.8.3.1
PATCH v2 1/1 syscalls/fanotify08: add sanity check for FAN_CLOEXEC
Hi!
Quoted 7 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +7
-0+#define _GNU_SOURCE +#include "config.h" + +#include <stdio.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <fcntl.h>
testcases/kernel/syscalls/fanotify/fanotify08.c line 44
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +10
-0+#include <errno.h> +#include <string.h> +#include <sys/syscall.h> +#include "tst_test.h" +#include "fanotify.h" + +#if defined(HAVE_SYS_FANOTIFY_H ) +#include <sys/fanotify.h> + +static void cleanup (void );
This cleanup definition is completely useless here as the test structure is defined at the end of the code.
testcases/kernel/syscalls/fanotify/fanotify08.c line 52
Quoted 8 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +8
-0+static void test01 (int flag); +static int fd_notify; + +void test_coe (void ) +{ +test01 (FAN_CLOEXEC ); +test01 (0 ); +}
Can we turn this into two separate testcases?
Quoted 19 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +19
-0+static void test01 (int flag) +{ +int coe; + + fd_notify =fanotify_init (FAN_CLASS_NOTIF |flag,O_RDONLY ); + +if (fd_notify <0 ) { + +if (errno ==ENOSYS ) { +tst_brk (TCONF , +"fanotify is not configured in this kernel." ); + }else { +tst_brk (TBROK |TERRNO ,"fanotify_init failed" ); + } + } + + coe =SAFE_FCNTL (fd_notify,F_GETFD ); + +if (coe &FD_CLOEXEC ) {
testcases/kernel/syscalls/fanotify/fanotify08.c line 82
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +10
-0+if (flag ==0 ) +tst_res (TFAIL ,"set close-on-exit" ); +else +tst_res (TPASS ,"set close-on-exit" ); + }else { +if (flag ==0 ) +tst_res (TPASS ,"not set close-on-exit" ); +else +tst_res (TFAIL ,"not set close-on-exit" ); + }
I would mildly prefer if we split this test functions into two one for FAN_CLOEXEC and one for case without the flag. All we need is to put the part that checks the fanotify_init() return value into a separate function and ideally we should put it into a header so that it could be reused in all fanotify testcases, but unfortunately we would have to convert the rest of the fanotify tests to the new library first...
Quoted 21 lines
testcases/kernel/syscalls/fanotify/fanotify08.c new file +18
-0+ SAFE_CLOSE(fd_notify); +} + +static void cleanup (void ) +{ +if (fd_notify >0 ) +SAFE_CLOSE (fd_notify); +} + +static struct tst_test test = { + .test_all = test_coe, + .cleanup = cleanup, + .needs_root =1 , +}; + +#else +TST_TEST_TCONF ("system doesn't have required fanotify support" ); +#endif Signature · 1 line
1.8.3.1
Signature · 2 lines
Cyril Hrubis [email protected]
v3 cover add SAFE_FANOTIFY_INIT and FAN_CLOEXEC cases
v3:
Add SAFE_FANOTIFY_INIT helper.
Rewrite old cases. Too big a patch, we can also split it. Split FAN_CLOEXEC case to 2 separate cases.
Thanks for reviewing!
Xiong Zhou (3):
lib: add helper SAFE_FANOTIFY_INIT
fanotify: rewrite old cases with new lib syscalls/fanotify0[89]: add sanity check for FAN_CLOEXEC
include/tst_safe_macros.h | 5 + lib/tst_safe_macros.c | 23 ++ runtest/syscalls | 2 + testcases/kernel/syscalls/fanotify/fanotify01.c | 520 +++++++++++------------- testcases/kernel/syscalls/fanotify/fanotify02.c | 320 +++++++-------- testcases/kernel/syscalls/fanotify/fanotify03.c | 248 +++++------ testcases/kernel/syscalls/fanotify/fanotify04.c | 159 +++----- testcases/kernel/syscalls/fanotify/fanotify05.c | 153 +++---- testcases/kernel/syscalls/fanotify/fanotify06.c | 191 ++++----- testcases/kernel/syscalls/fanotify/fanotify07.c | 9 +- testcases/kernel/syscalls/fanotify/fanotify08.c | 77 ++++ testcases/kernel/syscalls/fanotify/fanotify09.c | 77 ++++ 12 files changed, 891 insertions(+), 893 deletions(-) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify08.c create mode 100644 testcases/kernel/syscalls/fanotify/fanotify09.c
Signature · 1 line
1.8.3.1
PATCH v3 1/3 lib: add helper SAFE_FANOTIFY_INIT
--- include/tst_safe_macros.h | 5 +++++ lib/tst_safe_macros.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+)
include/tst_safe_macros.h +5 -0
@@ -438,4 +438,9 @@ int safe_mknod(const char *file, const int lineno, const char *pathname,#define SAFE_MKNOD (pathname, mode, dev) \ safe_mknod(__FILE__, __LINE__, (pathname), (mode), (dev)) +int safe_fanotify_init (const char *file,const int lineno, +unsigned int flags,unsigned int event_f_flags); +#define SAFE_FANOTIFY_INIT (fan, mode) \ + safe_fanotify_init(__FILE__, __LINE__, (fan), (mode)) +#endif /* SAFE_MACROS_H__ */
lib/tst_safe_macros.c +23 -0
@@ -17,6 +17,7 @@#define _GNU_SOURCE#include <unistd.h> +#include <errno.h> #define TST_NO_DEFAULT_MAIN #include "tst_test.h" #include "tst_safe_macros.h"
@@ -47,3 +48,25 @@ pid_t safe_getpgid(const char *file, const int lineno, pid_t pid)return pgid; } + +int safe_fanotify_init (const char *file,const int lineno, +unsigned int flags,unsigned int event_f_flags) +{ +int rval; + + rval =fanotify_init (flags, event_f_flags); + +if (rval ==-1 ) { + +if (errno ==ENOSYS ) { +tst_brk (TCONF , +"fanotify is not configured in this kernel." ); + }else { +tst_brk (TBROK |TERRNO , +"%s:%d: fanotify_init() failed" , + file, lineno); + } + } + +return rval; +}
Signature · 1 line
1.8.3.1
PATCH v3 1/3 lib: add helper SAFE_FANOTIFY_INIT
Hi!
Quoted 24 lines
lib/tst_safe_macros.c +9
-0@@ -17,6 +17,7 @@#define _GNU_SOURCE#include <unistd.h> +#include <errno.h> #define TST_NO_DEFAULT_MAIN #include "tst_test.h" #include "tst_safe_macros.h" @@ -47,3 +48,25 @@ pid_t safe_getpgid(const char *file, const int lineno, pid_t pid)return pgid; } + +int safe_fanotify_init (const char *file,const int lineno, +unsigned int flags,unsigned int event_f_flags) +{ +int rval; + + rval =fanotify_init (flags, event_f_flags); +
lib/tst_safe_macros.c pid_t safe_getpgid(const char *file, const int lineno, pid_t pid) · line 68
Quoted 10 lines
lib/tst_safe_macros.c +10
-0+if (rval ==-1 ) { + +if (errno ==ENOSYS ) { +tst_brk (TCONF , +"fanotify is not configured in this kernel." ); + }else { +tst_brk (TBROK |TERRNO , +"%s:%d: fanotify_init() failed" , + file, lineno); + }
There is no need for the else branch here, the tst_brk() will exit the test execution.
Quoted 7 lines
lib/tst_safe_macros.c +4
-0+ } + +return rval; +}Signature · 1 line
1.8.3.1
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v3 2/3 fanotify: rewrite old cases with new lib
In reply to Xiong ZhouTo use SAFE_FANOTIFY_INIT helper.
--- testcases/kernel/syscalls/fanotify/fanotify01.c | 520 +++++++++++------------- testcases/kernel/syscalls/fanotify/fanotify02.c | 320 +++++++-------- testcases/kernel/syscalls/fanotify/fanotify03.c | 248 +++++------ testcases/kernel/syscalls/fanotify/fanotify04.c | 159 +++----- testcases/kernel/syscalls/fanotify/fanotify05.c | 153 +++---- testcases/kernel/syscalls/fanotify/fanotify06.c | 191 ++++----- testcases/kernel/syscalls/fanotify/fanotify07.c | 9 +- 7 files changed, 707 insertions(+), 893 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify01.c +244 -276
@@ -35,12 +35,9 @@#include <errno.h> #include <string.h> #include <sys/syscall.h> -#include "test.h" -#include "lapi/syscalls.h" +#include "tst_test.h" #include "fanotify.h" -#include "safe_macros.h" -char *TCID ="fanotify01" ;int TST_TOTAL =12 ;#if defined(HAVE_SYS_FANOTIFY_H )
@@ -52,9 +49,6 @@ int TST_TOTAL = 12;/* reasonable guess as to size of 1024 events */ #define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE) -static void setup (void ); -static void cleanup (void ); -#define BUF_SIZE 256static char fname[BUF_SIZE ];static char buf[BUF_SIZE ];
@@ -64,308 +58,282 @@ static unsigned long long event_set[EVENT_MAX];static char event_buf[EVENT_BUF_LEN ]; -int main (int ac,char **av) +void test01 (void ) { -int lc; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); lc++) { -int ret, len, i =0 , test_num =0 ; - - tst_count =0 ; - -if (fanotify_mark (fd_notify,FAN_MARK_ADD ,FAN_ACCESS |FAN_MODIFY | -FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | " -"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " -"failed" , fd_notify, fname); - } - -/* -* generate sequence of events -*/ - fd =SAFE_OPEN (cleanup, fname,O_RDONLY ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); - event_set[tst_count] =FAN_ACCESS ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_NOWRITE ; - tst_count++; - -/* -* Get list of events so far. We get events here to avoid -* merging of following events with the previous ones. -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf,EVENT_BUF_LEN ); - len = ret; - - fd =SAFE_OPEN (cleanup, fname,O_RDWR |O_CREAT ,0700 ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -SAFE_WRITE (cleanup,1 , fd, fname,strlen (fname)); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; +int ret, len, i =0 , test_num =0 ; -/* -* get another list of events -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -/* -* Ignore mask testing -*/ - -/* Ignore access events */ -if (fanotify_mark (fd_notify, -FAN_MARK_ADD |FAN_MARK_IGNORED_MASK , -FAN_ACCESS ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD | " -"FAN_MARK_IGNORED_MASK, FAN_ACCESS, " -"AT_FDCWD, %s) failed" , fd_notify, fname); - } - - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -/* This event should be ignored */ -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); +int tst_count =0 ; -/* -* get another list of events to verify the last one got ignored -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -lseek (fd,0 ,SEEK_SET ); -/* Generate modify event to clear ignore mask */ -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -/* -* This event shouldn't be ignored because previous modification -* should have removed the ignore mask -*/ -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); - event_set[tst_count] =FAN_ACCESS ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; - -/* Read events to verify previous access was properly generated */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; +if (fanotify_mark (fd_notify,FAN_MARK_ADD ,FAN_ACCESS |FAN_MODIFY | +FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | " +"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " +"failed" , fd_notify, fname); + } -/* -* Now ignore open & close events regardless of file -* modifications -*/ -if (fanotify_mark (fd_notify, -FAN_MARK_ADD |FAN_MARK_IGNORED_MASK |FAN_MARK_IGNORED_SURV_MODIFY , -FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD | " -"FAN_MARK_IGNORED_MASK | " -"FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | " -"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, - fname); - } +/* +* generate sequence of events +*/ + fd =SAFE_OPEN (fname,O_RDONLY ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +SAFE_READ (0 , fd, buf,BUF_SIZE ); + event_set[tst_count] =FAN_ACCESS ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_NOWRITE ; + tst_count++; + +/* +* Get list of events so far. We get events here to avoid +* merging of following events with the previous ones. +*/ + ret =SAFE_READ (0 , fd_notify, event_buf,EVENT_BUF_LEN ); + len = ret; + + fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0700 ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +SAFE_WRITE (1 , fd, fname,strlen (fname)); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; + +/* +* get another list of events +*/ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* +* Ignore mask testing +*/ + +/* Ignore access events */ +if (fanotify_mark (fd_notify, +FAN_MARK_ADD |FAN_MARK_IGNORED_MASK , +FAN_ACCESS ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD | " +"FAN_MARK_IGNORED_MASK, FAN_ACCESS, " +"AT_FDCWD, %s) failed" , fd_notify, fname); + } -/* This event should be ignored */ - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -/* This event should be still ignored */ -SAFE_CLOSE (cleanup, fd); - -/* This event should still be ignored */ - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - -/* Read events to verify open & close were ignored */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -/* Now remove open and close from ignored mask */ -if (fanotify_mark (fd_notify, -FAN_MARK_REMOVE |FAN_MARK_IGNORED_MASK , -FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_REMOVE | " -"FAN_MARK_IGNORED_MASK, FAN_OPEN | " -"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, - fname); - } + fd =SAFE_OPEN (fname,O_RDWR ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +/* This event should be ignored */ +SAFE_READ (0 , fd, buf,BUF_SIZE ); + +/* +* get another list of events to verify the last one got ignored +*/ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +lseek (fd,0 ,SEEK_SET ); +/* Generate modify event to clear ignore mask */ +SAFE_WRITE (1 , fd, fname,1 ); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +/* +* This event shouldn't be ignored because previous modification +* should have removed the ignore mask +*/ +SAFE_READ (0 , fd, buf,BUF_SIZE ); + event_set[tst_count] =FAN_ACCESS ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; + +/* Read events to verify previous access was properly generated */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* +* Now ignore open & close events regardless of file +* modifications +*/ +if (fanotify_mark (fd_notify, +FAN_MARK_ADD |FAN_MARK_IGNORED_MASK |FAN_MARK_IGNORED_SURV_MODIFY , +FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD | " +"FAN_MARK_IGNORED_MASK | " +"FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | " +"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, + fname); + } -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; +/* This event should be ignored */ + fd =SAFE_OPEN (fname,O_RDWR ); + +SAFE_WRITE (1 , fd, fname,1 ); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +/* This event should be still ignored */ +SAFE_CLOSE (fd); + +/* This event should still be ignored */ + fd =SAFE_OPEN (fname,O_RDWR ); + +/* Read events to verify open & close were ignored */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* Now remove open and close from ignored mask */ +if (fanotify_mark (fd_notify, +FAN_MARK_REMOVE |FAN_MARK_IGNORED_MASK , +FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_REMOVE | " +"FAN_MARK_IGNORED_MASK, FAN_OPEN | " +"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, + fname); + } -/* Read events to verify close was generated */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; -if (TST_TOTAL != tst_count) { -tst_brkm (TBROK , cleanup, -"TST_TOTAL (%d) and tst_count (%d) are not " -"equal" ,TST_TOTAL , tst_count); - } - tst_count =0 ; +/* Read events to verify close was generated */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; -/* -* check events -*/ -while (i < len) { -struct fanotify_event_metadata *event; - - event = (struct fanotify_event_metadata *)&event_buf[i]; -if (test_num >=TST_TOTAL ) { -tst_resm (TFAIL , -"get unnecessary event: mask=%llx " -"pid=%u fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, event->fd); - }else if (!(event->mask & event_set[test_num])) { -tst_resm (TFAIL , -"get event: mask=%llx (expected %llx) " -"pid=%u fd=%u" , +if (TST_TOTAL != tst_count) { +tst_brk (TBROK , +"TST_TOTAL (%d) and tst_count (%d) are not " +"equal" ,TST_TOTAL , tst_count); + } + tst_count =0 ; + +/* +* check events +*/ +while (i < len) { +struct fanotify_event_metadata *event; + + event = (struct fanotify_event_metadata *)&event_buf[i]; +if (test_num >=TST_TOTAL ) { +tst_res (TFAIL , +"get unnecessary event: mask=%llx " +"pid=%u fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, event->fd); + }else if (!(event->mask & event_set[test_num])) { +tst_res (TFAIL , +"get event: mask=%llx (expected %llx) " +"pid=%u fd=%u" , + (unsigned long long )event->mask, + event_set[test_num], + (unsigned )event->pid, event->fd); + }else if (event->pid !=getpid ()) { +tst_res (TFAIL , +"get event: mask=%llx pid=%u " +"(expected %u) fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, + (unsigned )getpid (), + event->fd); + }else { +if (event->fd ==-2 ) + goto pass; + ret =read (event->fd, buf,BUF_SIZE ); +if (ret !=strlen (fname)) { +tst_res (TFAIL , +"cannot read from returned fd " +"of event: mask=%llx pid=%u " +"fd=%u ret=%d (errno=%d)" , (unsigned long long )event->mask, - event_set[test_num], - (unsigned )event->pid, event->fd); - }else if (event->pid !=getpid ()) { -tst_resm (TFAIL , -"get event: mask=%llx pid=%u " -"(expected %u) fd=%u" , + (unsigned )event->pid, + event->fd, ret, errno); + }else if (memcmp (buf, fname,strlen (fname))) { +tst_res (TFAIL , +"wrong data read from returned fd " +"of event: mask=%llx pid=%u " +"fd=%u" , (unsigned long long )event->mask, (unsigned )event->pid, - (unsigned )getpid (), event->fd); }else { -if (event->fd ==-2 ) - goto pass; - ret =read (event->fd, buf,BUF_SIZE ); -if (ret !=strlen (fname)) { -tst_resm (TFAIL , -"cannot read from returned fd " -"of event: mask=%llx pid=%u " -"fd=%u ret=%d (errno=%d)" , - (unsigned long long )event->mask, - (unsigned )event->pid, - event->fd, ret, errno); - }else if (memcmp (buf, fname,strlen (fname))) { -tst_resm (TFAIL , -"wrong data read from returned fd " -"of event: mask=%llx pid=%u " -"fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, - event->fd); - }else { pass: -tst_resm (TPASS , -"get event: mask=%llx pid=%u fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, event->fd); - } +tst_res (TPASS , +"get event: mask=%llx pid=%u fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, event->fd); } -/* -* We have verified the data now so close fd and -* invalidate it so that we don't check it again -* unnecessarily -*/ -close (event->fd); - event->fd =-2 ; - event->mask &= ~event_set[test_num]; -/* No events left in current mask? Go for next event */ -if (event->mask ==0 ) { - i += event->event_len; - } - test_num++; - } -for (; test_num <TST_TOTAL ; test_num++) { -tst_resm (TFAIL ,"didn't get event: mask=%llx" , - event_set[test_num]); - } -/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */ -if (fanotify_mark (fd_notify,FAN_MARK_REMOVE ,FAN_ACCESS |FAN_MODIFY | -FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | " -"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " -"failed" , fd_notify, fname); +/* +* We have verified the data now so close fd and +* invalidate it so that we don't check it again +* unnecessarily +*/ +close (event->fd); + event->fd =-2 ; + event->mask &= ~event_set[test_num]; +/* No events left in current mask? Go for next event */ +if (event->mask ==0 ) { + i += event->event_len; } - + test_num++; } +for (; test_num <TST_TOTAL ; test_num++) { +tst_res (TFAIL ,"didn't get event: mask=%llx" , + event_set[test_num]); -cleanup (); -tst_exit (); + } +/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */ +if (fanotify_mark (fd_notify,FAN_MARK_REMOVE ,FAN_ACCESS |FAN_MODIFY | +FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | " +"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " +"failed" , fd_notify, fname); + } }static void setup (void ) { -tst_sig (NOFORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; - -tst_tmpdir (); -sprintf (fname,"tfile_%d" ,getpid ()); - fd =SAFE_OPEN (cleanup, fname,O_RDWR |O_CREAT ,0700 ); -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - + fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0700 ); +SAFE_WRITE (1 , fd, fname,1 );/* close the file we have open */ -SAFE_CLOSE (cleanup, fd); +SAFE_CLOSE (fd); -if ((fd_notify =fanotify_init (FAN_CLASS_NOTIF ,O_RDONLY )) <0 ) { -if (errno ==ENOSYS ) { -tst_brkm (TCONF , cleanup, -"fanotify is not configured in this kernel." ); - }else { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_init failed" ); - } - } + fd_notify =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF ,O_RDONLY ); }static void cleanup (void ) {if (fd_notify >0 &&close (fd_notify)) -tst_resm (TWARN |TERRNO ,"close(%d) failed" , fd_notify); - -tst_rmdir (); +tst_res (TWARN |TERRNO ,"close(%d) failed" , fd_notify); } -#else - -int main (void ) -{ -tst_brkm (TCONF ,NULL ,"system doesn't have required fanotify support" ); -} +static struct tst_test test = { + .test_all = test01, + .setup = setup, + .cleanup = cleanup, + .needs_tmpdir =1 , + .needs_root =1 +}; +#else +TST_TEST_TCONF ("system doesn't have required fanotify support" );#endif
testcases/kernel/syscalls/fanotify/fanotify02.c +145 -175
363 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify03.c +110 -138
332 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify04.c +65 -94
253 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify05.c +61 -92
200 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify06.c +81 -110
273 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify07.c +1 -8
@@ -119,14 +119,7 @@ static int setup_instance(void) {int fd; -if ((fd =fanotify_init (FAN_CLASS_CONTENT ,O_RDONLY )) <0 ) { -if (errno ==ENOSYS ) { -tst_brk (TCONF , -"fanotify is not configured in this kernel." ); - }else { -tst_brk (TBROK |TERRNO ,"fanotify_init failed" ); - } - } + fd =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY );if (fanotify_mark (fd,FAN_MARK_ADD ,FAN_ACCESS_PERM ,AT_FDCWD , fname) <0 ) {
Signature · 1 line
1.8.3.1
PATCH v3 2/3 fanotify: rewrite old cases with new lib
Hi!
Quoted 6 lines
testcases/kernel/syscalls/fanotify/fanotify01.c +0
-0@@ -35,12 +35,9 @@#include <errno.h>
testcases/kernel/syscalls/fanotify/fanotify01.c line 41
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify01.c +1
-4#include <string.h> #include <sys/syscall.h> -#include "test.h" -#include "lapi/syscalls.h" +#include "tst_test.h" #include "fanotify.h" -#include "safe_macros.h" -char *TCID ="fanotify01" ;int TST_TOTAL =12 ;
Can we declare this to be macro instead?
Otherwise it looks like we left old library leftovers here.
Quoted 534 lines
testcases/kernel/syscalls/fanotify/fanotify01.c +232
-263#if defined(HAVE_SYS_FANOTIFY_H )@@ -52,9 +49,6 @@ int TST_TOTAL = 12;/* reasonable guess as to size of 1024 events */ #define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE) -static void setup (void ); -static void cleanup (void ); -#define BUF_SIZE 256static char fname[BUF_SIZE ];static char buf[BUF_SIZE ];@@ -64,308 +58,282 @@ static unsigned long long event_set[EVENT_MAX];static char event_buf[EVENT_BUF_LEN ]; -int main (int ac,char **av) +void test01 (void ) { -int lc; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); lc++) { -int ret, len, i =0 , test_num =0 ; - - tst_count =0 ; - -if (fanotify_mark (fd_notify,FAN_MARK_ADD ,FAN_ACCESS |FAN_MODIFY | -FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | " -"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " -"failed" , fd_notify, fname); - } - -/* -* generate sequence of events -*/ - fd =SAFE_OPEN (cleanup, fname,O_RDONLY ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); - event_set[tst_count] =FAN_ACCESS ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_NOWRITE ; - tst_count++; - -/* -* Get list of events so far. We get events here to avoid -* merging of following events with the previous ones. -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf,EVENT_BUF_LEN ); - len = ret; - - fd =SAFE_OPEN (cleanup, fname,O_RDWR |O_CREAT ,0700 ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -SAFE_WRITE (cleanup,1 , fd, fname,strlen (fname)); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; +int ret, len, i =0 , test_num =0 ; -/* -* get another list of events -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -/* -* Ignore mask testing -*/ - -/* Ignore access events */ -if (fanotify_mark (fd_notify, -FAN_MARK_ADD |FAN_MARK_IGNORED_MASK , -FAN_ACCESS ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD | " -"FAN_MARK_IGNORED_MASK, FAN_ACCESS, " -"AT_FDCWD, %s) failed" , fd_notify, fname); - } - - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -/* This event should be ignored */ -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); +int tst_count =0 ; -/* -* get another list of events to verify the last one got ignored -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -lseek (fd,0 ,SEEK_SET ); -/* Generate modify event to clear ignore mask */ -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -/* -* This event shouldn't be ignored because previous modification -* should have removed the ignore mask -*/ -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); - event_set[tst_count] =FAN_ACCESS ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; - -/* Read events to verify previous access was properly generated */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; +if (fanotify_mark (fd_notify,FAN_MARK_ADD ,FAN_ACCESS |FAN_MODIFY | +FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | " +"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " +"failed" , fd_notify, fname); + } -/* -* Now ignore open & close events regardless of file -* modifications -*/ -if (fanotify_mark (fd_notify, -FAN_MARK_ADD |FAN_MARK_IGNORED_MASK |FAN_MARK_IGNORED_SURV_MODIFY , -FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD | " -"FAN_MARK_IGNORED_MASK | " -"FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | " -"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, - fname); - } +/* +* generate sequence of events +*/ + fd =SAFE_OPEN (fname,O_RDONLY ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +SAFE_READ (0 , fd, buf,BUF_SIZE ); + event_set[tst_count] =FAN_ACCESS ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_NOWRITE ; + tst_count++; + +/* +* Get list of events so far. We get events here to avoid +* merging of following events with the previous ones. +*/ + ret =SAFE_READ (0 , fd_notify, event_buf,EVENT_BUF_LEN ); + len = ret; + + fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0700 ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +SAFE_WRITE (1 , fd, fname,strlen (fname)); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; + +/* +* get another list of events +*/ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* +* Ignore mask testing +*/ + +/* Ignore access events */ +if (fanotify_mark (fd_notify, +FAN_MARK_ADD |FAN_MARK_IGNORED_MASK , +FAN_ACCESS ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD | " +"FAN_MARK_IGNORED_MASK, FAN_ACCESS, " +"AT_FDCWD, %s) failed" , fd_notify, fname); + } -/* This event should be ignored */ - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -/* This event should be still ignored */ -SAFE_CLOSE (cleanup, fd); - -/* This event should still be ignored */ - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - -/* Read events to verify open & close were ignored */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -/* Now remove open and close from ignored mask */ -if (fanotify_mark (fd_notify, -FAN_MARK_REMOVE |FAN_MARK_IGNORED_MASK , -FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_REMOVE | " -"FAN_MARK_IGNORED_MASK, FAN_OPEN | " -"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, - fname); - } + fd =SAFE_OPEN (fname,O_RDWR ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +/* This event should be ignored */ +SAFE_READ (0 , fd, buf,BUF_SIZE ); + +/* +* get another list of events to verify the last one got ignored +*/ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +lseek (fd,0 ,SEEK_SET ); +/* Generate modify event to clear ignore mask */ +SAFE_WRITE (1 , fd, fname,1 ); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +/* +* This event shouldn't be ignored because previous modification +* should have removed the ignore mask +*/ +SAFE_READ (0 , fd, buf,BUF_SIZE ); + event_set[tst_count] =FAN_ACCESS ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; + +/* Read events to verify previous access was properly generated */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* +* Now ignore open & close events regardless of file +* modifications +*/ +if (fanotify_mark (fd_notify, +FAN_MARK_ADD |FAN_MARK_IGNORED_MASK |FAN_MARK_IGNORED_SURV_MODIFY , +FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD | " +"FAN_MARK_IGNORED_MASK | " +"FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | " +"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, + fname); + } -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; +/* This event should be ignored */ + fd =SAFE_OPEN (fname,O_RDWR ); + +SAFE_WRITE (1 , fd, fname,1 ); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +/* This event should be still ignored */ +SAFE_CLOSE (fd); + +/* This event should still be ignored */ + fd =SAFE_OPEN (fname,O_RDWR ); + +/* Read events to verify open & close were ignored */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* Now remove open and close from ignored mask */ +if (fanotify_mark (fd_notify, +FAN_MARK_REMOVE |FAN_MARK_IGNORED_MASK , +FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_REMOVE | " +"FAN_MARK_IGNORED_MASK, FAN_OPEN | " +"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, + fname); + } -/* Read events to verify close was generated */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; -if (TST_TOTAL != tst_count) { -tst_brkm (TBROK , cleanup, -"TST_TOTAL (%d) and tst_count (%d) are not " -"equal" ,TST_TOTAL , tst_count); - } - tst_count =0 ; +/* Read events to verify close was generated */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; -/* -* check events -*/ -while (i < len) { -struct fanotify_event_metadata *event; - - event = (struct fanotify_event_metadata *)&event_buf[i]; -if (test_num >=TST_TOTAL ) { -tst_resm (TFAIL , -"get unnecessary event: mask=%llx " -"pid=%u fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, event->fd); - }else if (!(event->mask & event_set[test_num])) { -tst_resm (TFAIL , -"get event: mask=%llx (expected %llx) " -"pid=%u fd=%u" , +if (TST_TOTAL != tst_count) { +tst_brk (TBROK , +"TST_TOTAL (%d) and tst_count (%d) are not " +"equal" ,TST_TOTAL , tst_count); + } + tst_count =0 ; + +/* +* check events +*/ +while (i < len) { +struct fanotify_event_metadata *event; + + event = (struct fanotify_event_metadata *)&event_buf[i]; +if (test_num >=TST_TOTAL ) { +tst_res (TFAIL , +"get unnecessary event: mask=%llx " +"pid=%u fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, event->fd); + }else if (!(event->mask & event_set[test_num])) { +tst_res (TFAIL , +"get event: mask=%llx (expected %llx) " +"pid=%u fd=%u" , + (unsigned long long )event->mask, + event_set[test_num], + (unsigned )event->pid, event->fd); + }else if (event->pid !=getpid ()) { +tst_res (TFAIL , +"get event: mask=%llx pid=%u " +"(expected %u) fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, + (unsigned )getpid (), + event->fd); + }else { +if (event->fd ==-2 ) + goto pass; + ret =read (event->fd, buf,BUF_SIZE ); +if (ret !=strlen (fname)) { +tst_res (TFAIL , +"cannot read from returned fd " +"of event: mask=%llx pid=%u " +"fd=%u ret=%d (errno=%d)" , (unsigned long long )event->mask, - event_set[test_num], - (unsigned )event->pid, event->fd); - }else if (event->pid !=getpid ()) { -tst_resm (TFAIL , -"get event: mask=%llx pid=%u " -"(expected %u) fd=%u" , + (unsigned )event->pid, + event->fd, ret, errno); + }else if (memcmp (buf, fname,strlen (fname))) { +tst_res (TFAIL , +"wrong data read from returned fd " +"of event: mask=%llx pid=%u " +"fd=%u" , (unsigned long long )event->mask, (unsigned )event->pid, - (unsigned )getpid (), event->fd); }else { -if (event->fd ==-2 ) - goto pass; - ret =read (event->fd, buf,BUF_SIZE ); -if (ret !=strlen (fname)) { -tst_resm (TFAIL , -"cannot read from returned fd " -"of event: mask=%llx pid=%u " -"fd=%u ret=%d (errno=%d)" , - (unsigned long long )event->mask, - (unsigned )event->pid, - event->fd, ret, errno); - }else if (memcmp (buf, fname,strlen (fname))) { -tst_resm (TFAIL , -"wrong data read from returned fd " -"of event: mask=%llx pid=%u " -"fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, - event->fd); - }else { pass: -tst_resm (TPASS , -"get event: mask=%llx pid=%u fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, event->fd); - } +tst_res (TPASS , +"get event: mask=%llx pid=%u fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, event->fd); } -/* -* We have verified the data now so close fd and -* invalidate it so that we don't check it again -* unnecessarily -*/ -close (event->fd); - event->fd =-2 ; - event->mask &= ~event_set[test_num]; -/* No events left in current mask? Go for next event */ -if (event->mask ==0 ) { - i += event->event_len; - } - test_num++; - } -for (; test_num <TST_TOTAL ; test_num++) { -tst_resm (TFAIL ,"didn't get event: mask=%llx" , - event_set[test_num]); - } -/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */ -if (fanotify_mark (fd_notify,FAN_MARK_REMOVE ,FAN_ACCESS |FAN_MODIFY | -FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | " -"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " -"failed" , fd_notify, fname); +/* +* We have verified the data now so close fd and +* invalidate it so that we don't check it again +* unnecessarily +*/ +close (event->fd); + event->fd =-2 ; + event->mask &= ~event_set[test_num]; +/* No events left in current mask? Go for next event */ +if (event->mask ==0 ) { + i += event->event_len; } - + test_num++; } +for (; test_num <TST_TOTAL ; test_num++) { +tst_res (TFAIL ,"didn't get event: mask=%llx" , + event_set[test_num]); -cleanup (); -tst_exit (); + } +/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */ +if (fanotify_mark (fd_notify,FAN_MARK_REMOVE ,FAN_ACCESS |FAN_MODIFY | +FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | " +"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " +"failed" , fd_notify, fname); + } }static void setup (void ) { -tst_sig (NOFORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; - -tst_tmpdir (); -sprintf (fname,"tfile_%d" ,getpid ()); - fd =SAFE_OPEN (cleanup, fname,O_RDWR |O_CREAT ,0700 ); -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - + fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0700 ); +SAFE_WRITE (1 , fd, fname,1 );/* close the file we have open */ -SAFE_CLOSE (cleanup, fd); +SAFE_CLOSE (fd); -if ((fd_notify =fanotify_init (FAN_CLASS_NOTIF ,O_RDONLY )) <0 ) { -if (errno ==ENOSYS ) { -tst_brkm (TCONF , cleanup, -"fanotify is not configured in this kernel." ); - }else { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_init failed" ); - } - }
testcases/kernel/syscalls/fanotify/fanotify01.c static unsigned long long event_set[EVENT_MAX]; · line 326
Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify01.c +2
-3+ fd_notify =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF ,O_RDONLY ); }static void cleanup (void ) {if (fd_notify >0 &&close (fd_notify)) -tst_resm (TWARN |TERRNO ,"close(%d) failed" , fd_notify); - -tst_rmdir (); +tst_res (TWARN |TERRNO ,"close(%d) failed" , fd_notify);
We can use safe macros in test cleanup now, so this should be changed to:
if (fd_notify > 0) SAFE_CLOSE(fd_notify);
And that applies to most of the tests, otherwise it looks pretty much straightforward.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v3 3/3 syscalls/fanotify0[89]: add sanity check for FAN_CLOEXEC
In reply to Xiong Zhou--- runtest/syscalls | 2 + testcases/kernel/syscalls/fanotify/fanotify08.c | 77 +++++++++++++++++++++++++ testcases/kernel/syscalls/fanotify/fanotify09.c | 77 +++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify08.c create mode 100644 testcases/kernel/syscalls/fanotify/fanotify09.c
runtest/syscalls +2 -0
@@ -479,6 +479,8 @@ fanotify04 fanotify04 fanotify05 fanotify05 fanotify06 fanotify06 fanotify07 fanotify07 +fanotify08 fanotify08 +fanotify09 fanotify09 ioperm01 ioperm01 ioperm02 ioperm02
testcases/kernel/syscalls/fanotify/fanotify08.c new file +77 -0
77 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify09.c new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 3/3 syscalls/fanotify0[89]: add sanity check for FAN_CLOEXEC
Hi!
Quoted 2 lines
testcases/kernel/syscalls/fanotify/fanotify08.c | 77 +++++++++++++++++++++++++ testcases/kernel/syscalls/fanotify/fanotify09.c | 77 +++++++++++++++++++++++++
There is no reason to put these tests into two separate files.
We even have that described in the tutorial:
https://github.com/linux-test-project/ltp/wiki/C-Test-Case-Tutorial#6-split-the-test
Signature · 2 lines
Cyril Hrubis [email protected]
v4 cover add SAFE_FANOTIFY_INIT and FAN_CLOEXEC check
v4:
Delete else branch in helper.
Make TST_TOTAL a macro instead of integer. Use SAFE_CLOSE in cleanup in old cases. Use iteration of tst_test.test instead of 2 files.
v3:
Add SAFE_FANOTIFY_INIT helper.
Rewrite old cases. Too big a patch, we can also split it. Split FAN_CLOEXEC case to 2 separate cases.
Thanks for reviewing!
Xiong Zhou (3):
lib: add helper SAFE_FANOTIFY_INIT
fanotify: rewrite old cases with new lib syscalls/fanotify08: add sanity check for FAN_CLOEXEC
include/tst_safe_macros.h | 5 + lib/tst_safe_macros.c | 21 + runtest/syscalls | 1 + testcases/kernel/syscalls/fanotify/fanotify01.c | 526 +++++++++++------------- testcases/kernel/syscalls/fanotify/fanotify02.c | 326 +++++++-------- testcases/kernel/syscalls/fanotify/fanotify03.c | 254 +++++------- testcases/kernel/syscalls/fanotify/fanotify04.c | 165 +++----- testcases/kernel/syscalls/fanotify/fanotify05.c | 155 +++---- testcases/kernel/syscalls/fanotify/fanotify06.c | 193 ++++----- testcases/kernel/syscalls/fanotify/fanotify07.c | 9 +- testcases/kernel/syscalls/fanotify/fanotify08.c | 91 ++++ 11 files changed, 838 insertions(+), 908 deletions(-) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify08.c
Signature · 1 line
1.8.3.1
PATCH v4 1/3 lib: add helper SAFE_FANOTIFY_INIT
--- include/tst_safe_macros.h | 5 +++++ lib/tst_safe_macros.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+)
include/tst_safe_macros.h +5 -0
@@ -438,4 +438,9 @@ int safe_mknod(const char *file, const int lineno, const char *pathname,#define SAFE_MKNOD (pathname, mode, dev) \ safe_mknod(__FILE__, __LINE__, (pathname), (mode), (dev)) +int safe_fanotify_init (const char *file,const int lineno, +unsigned int flags,unsigned int event_f_flags); +#define SAFE_FANOTIFY_INIT (fan, mode) \ + safe_fanotify_init(__FILE__, __LINE__, (fan), (mode)) +#endif /* SAFE_MACROS_H__ */
lib/tst_safe_macros.c +21 -0
@@ -17,6 +17,7 @@#define _GNU_SOURCE#include <unistd.h> +#include <errno.h> #define TST_NO_DEFAULT_MAIN #include "tst_test.h" #include "tst_safe_macros.h"
@@ -47,3 +48,23 @@ pid_t safe_getpgid(const char *file, const int lineno, pid_t pid)return pgid; } + +int safe_fanotify_init (const char *file,const int lineno, +unsigned int flags,unsigned int event_f_flags) +{ +int rval; + + rval =fanotify_init (flags, event_f_flags); + +if (rval ==-1 ) { + +if (errno ==ENOSYS ) { +tst_brk (TCONF , +"fanotify is not configured in this kernel." ); + } +tst_brk (TBROK |TERRNO , +"%s:%d: fanotify_init() failed" , file, lineno); + } + +return rval; +}
Signature · 1 line
1.8.3.1
PATCH v4 1/3 lib: add helper SAFE_FANOTIFY_INIT
Hi!
Pushed with following patch (to fix warnings), thanks.
lib/tst_safe_macros.c +8 -1
@@ -18,6 +18,10 @@#define _GNU_SOURCE#include <unistd.h> #include <errno.h> +#include "config.h" +#ifdef HAVE_SYS_FANOTIFY_H +# include <sys/fanotify.h> +#endif #define TST_NO_DEFAULT_MAIN #include "tst_test.h" #include "tst_safe_macros.h"
@@ -54,10 +58,10 @@ int safe_fanotify_init(const char *file, const int lineno, {int rval; +#ifdef HAVE_SYS_FANOTIFY_H rval =fanotify_init (flags, event_f_flags);if (rval ==-1 ) { -if (errno ==ENOSYS ) {tst_brk (TCONF ,"fanotify is not configured in this kernel." );
@@ -65,6 +69,9 @@ int safe_fanotify_init(const char *file, const int lineno,tst_brk (TBROK |TERRNO , "%s:%d: fanotify_init() failed", file, lineno); } +#else +tst_brk (TCONF ,"Header <sys/fanotify.h> is not present" ); +#endif /* HAVE_SYS_FANOTIFY_H */ return rval; }
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 1/3 lib: add helper SAFE_FANOTIFY_INIT
Quoted 2 lines · Cyril Hrubis
Hi!
Pushed with following patch (to fix warnings), thanks.
Thanks very much!
Do you have any tool detecting these warnings ?
Quoted 1 line
PATCH v4 1/3 lib: add helper SAFE_FANOTIFY_INIT
Hi!
Quoted 3 lines
Thanks very much!
Do you have any tool detecting these warnings ?
Just recent enough gcc (5.4 at this point), there was a quite a lot of work done on warnings and error message in gcc in the last few years.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 2/3 fanotify: rewrite old cases with new lib
In reply to Xiong ZhouTo use SAFE_FANOTIFY_INIT helper.
--- testcases/kernel/syscalls/fanotify/fanotify01.c | 526 +++++++++++------------- testcases/kernel/syscalls/fanotify/fanotify02.c | 326 +++++++-------- testcases/kernel/syscalls/fanotify/fanotify03.c | 254 +++++------- testcases/kernel/syscalls/fanotify/fanotify04.c | 165 +++----- testcases/kernel/syscalls/fanotify/fanotify05.c | 155 +++---- testcases/kernel/syscalls/fanotify/fanotify06.c | 193 ++++----- testcases/kernel/syscalls/fanotify/fanotify07.c | 9 +- 7 files changed, 720 insertions(+), 908 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify01.c +247 -279
@@ -35,13 +35,8 @@#include <errno.h> #include <string.h> #include <sys/syscall.h> -#include "test.h" -#include "lapi/syscalls.h" +#include "tst_test.h" #include "fanotify.h" -#include "safe_macros.h" - -char *TCID ="fanotify01" ; -int TST_TOTAL =12 ;#if defined(HAVE_SYS_FANOTIFY_H )#include <sys/fanotify.h>
@@ -52,10 +47,9 @@ int TST_TOTAL = 12;/* reasonable guess as to size of 1024 events */ #define EVENT_BUF_LEN (EVENT_MAX * EVENT_SIZE) -static void setup (void ); -static void cleanup (void ); -#define BUF_SIZE 256 +#define TST_TOTAL 12 +static char fname[BUF_SIZE ];static char buf[BUF_SIZE ];static int fd, fd_notify;
@@ -64,308 +58,282 @@ static unsigned long long event_set[EVENT_MAX];static char event_buf[EVENT_BUF_LEN ]; -int main (int ac,char **av) +void test01 (void ) { -int lc; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); lc++) { -int ret, len, i =0 , test_num =0 ; - - tst_count =0 ; - -if (fanotify_mark (fd_notify,FAN_MARK_ADD ,FAN_ACCESS |FAN_MODIFY | -FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | " -"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " -"failed" , fd_notify, fname); - } - -/* -* generate sequence of events -*/ - fd =SAFE_OPEN (cleanup, fname,O_RDONLY ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); - event_set[tst_count] =FAN_ACCESS ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_NOWRITE ; - tst_count++; - -/* -* Get list of events so far. We get events here to avoid -* merging of following events with the previous ones. -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf,EVENT_BUF_LEN ); - len = ret; - - fd =SAFE_OPEN (cleanup, fname,O_RDWR |O_CREAT ,0700 ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -SAFE_WRITE (cleanup,1 , fd, fname,strlen (fname)); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; - -/* -* get another list of events -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -/* -* Ignore mask testing -*/ - -/* Ignore access events */ -if (fanotify_mark (fd_notify, -FAN_MARK_ADD |FAN_MARK_IGNORED_MASK , -FAN_ACCESS ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD | " -"FAN_MARK_IGNORED_MASK, FAN_ACCESS, " -"AT_FDCWD, %s) failed" , fd_notify, fname); - } - - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - event_set[tst_count] =FAN_OPEN ; - tst_count++; - -/* This event should be ignored */ -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); - -/* -* get another list of events to verify the last one got ignored -*/ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -lseek (fd,0 ,SEEK_SET ); -/* Generate modify event to clear ignore mask */ -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -/* -* This event shouldn't be ignored because previous modification -* should have removed the ignore mask -*/ -SAFE_READ (cleanup,0 , fd, buf,BUF_SIZE ); - event_set[tst_count] =FAN_ACCESS ; - tst_count++; +int ret, len, i =0 , test_num =0 ; -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; +int tst_count =0 ; -/* Read events to verify previous access was properly generated */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; +if (fanotify_mark (fd_notify,FAN_MARK_ADD ,FAN_ACCESS |FAN_MODIFY | +FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS | " +"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " +"failed" , fd_notify, fname); + } -/* -* Now ignore open & close events regardless of file -* modifications -*/ -if (fanotify_mark (fd_notify, -FAN_MARK_ADD |FAN_MARK_IGNORED_MASK |FAN_MARK_IGNORED_SURV_MODIFY , -FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_ADD | " -"FAN_MARK_IGNORED_MASK | " -"FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | " -"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, - fname); - } +/* +* generate sequence of events +*/ + fd =SAFE_OPEN (fname,O_RDONLY ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +SAFE_READ (0 , fd, buf,BUF_SIZE ); + event_set[tst_count] =FAN_ACCESS ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_NOWRITE ; + tst_count++; + +/* +* Get list of events so far. We get events here to avoid +* merging of following events with the previous ones. +*/ + ret =SAFE_READ (0 , fd_notify, event_buf,EVENT_BUF_LEN ); + len = ret; + + fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0700 ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +SAFE_WRITE (1 , fd, fname,strlen (fname)); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; + +/* +* get another list of events +*/ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* +* Ignore mask testing +*/ + +/* Ignore access events */ +if (fanotify_mark (fd_notify, +FAN_MARK_ADD |FAN_MARK_IGNORED_MASK , +FAN_ACCESS ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD | " +"FAN_MARK_IGNORED_MASK, FAN_ACCESS, " +"AT_FDCWD, %s) failed" , fd_notify, fname); + } -/* This event should be ignored */ - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - event_set[tst_count] =FAN_MODIFY ; - tst_count++; - -/* This event should be still ignored */ -SAFE_CLOSE (cleanup, fd); - -/* This event should still be ignored */ - fd =SAFE_OPEN (cleanup, fname,O_RDWR ); - -/* Read events to verify open & close were ignored */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; - -/* Now remove open and close from ignored mask */ -if (fanotify_mark (fd_notify, -FAN_MARK_REMOVE |FAN_MARK_IGNORED_MASK , -FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_REMOVE | " -"FAN_MARK_IGNORED_MASK, FAN_OPEN | " -"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, - fname); - } + fd =SAFE_OPEN (fname,O_RDWR ); + event_set[tst_count] =FAN_OPEN ; + tst_count++; + +/* This event should be ignored */ +SAFE_READ (0 , fd, buf,BUF_SIZE ); + +/* +* get another list of events to verify the last one got ignored +*/ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +lseek (fd,0 ,SEEK_SET ); +/* Generate modify event to clear ignore mask */ +SAFE_WRITE (1 , fd, fname,1 ); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +/* +* This event shouldn't be ignored because previous modification +* should have removed the ignore mask +*/ +SAFE_READ (0 , fd, buf,BUF_SIZE ); + event_set[tst_count] =FAN_ACCESS ; + tst_count++; + +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; + +/* Read events to verify previous access was properly generated */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* +* Now ignore open & close events regardless of file +* modifications +*/ +if (fanotify_mark (fd_notify, +FAN_MARK_ADD |FAN_MARK_IGNORED_MASK |FAN_MARK_IGNORED_SURV_MODIFY , +FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_ADD | " +"FAN_MARK_IGNORED_MASK | " +"FAN_MARK_IGNORED_SURV_MODIFY, FAN_OPEN | " +"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, + fname); + } -SAFE_CLOSE (cleanup, fd); - event_set[tst_count] =FAN_CLOSE_WRITE ; - tst_count++; +/* This event should be ignored */ + fd =SAFE_OPEN (fname,O_RDWR ); + +SAFE_WRITE (1 , fd, fname,1 ); + event_set[tst_count] =FAN_MODIFY ; + tst_count++; + +/* This event should be still ignored */ +SAFE_CLOSE (fd); + +/* This event should still be ignored */ + fd =SAFE_OPEN (fname,O_RDWR ); + +/* Read events to verify open & close were ignored */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; + +/* Now remove open and close from ignored mask */ +if (fanotify_mark (fd_notify, +FAN_MARK_REMOVE |FAN_MARK_IGNORED_MASK , +FAN_OPEN |FAN_CLOSE ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_REMOVE | " +"FAN_MARK_IGNORED_MASK, FAN_OPEN | " +"FAN_CLOSE, AT_FDCWD, %s) failed" , fd_notify, + fname); + } -/* Read events to verify close was generated */ - ret =SAFE_READ (cleanup,0 , fd_notify, event_buf + len, -EVENT_BUF_LEN - len); - len += ret; +SAFE_CLOSE (fd); + event_set[tst_count] =FAN_CLOSE_WRITE ; + tst_count++; -if (TST_TOTAL != tst_count) { -tst_brkm (TBROK , cleanup, -"TST_TOTAL (%d) and tst_count (%d) are not " -"equal" ,TST_TOTAL , tst_count); - } - tst_count =0 ; +/* Read events to verify close was generated */ + ret =SAFE_READ (0 , fd_notify, event_buf + len, +EVENT_BUF_LEN - len); + len += ret; -/* -* check events -*/ -while (i < len) { -struct fanotify_event_metadata *event; - - event = (struct fanotify_event_metadata *)&event_buf[i]; -if (test_num >=TST_TOTAL ) { -tst_resm (TFAIL , -"get unnecessary event: mask=%llx " -"pid=%u fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, event->fd); - }else if (!(event->mask & event_set[test_num])) { -tst_resm (TFAIL , -"get event: mask=%llx (expected %llx) " -"pid=%u fd=%u" , +if (TST_TOTAL != tst_count) { +tst_brk (TBROK , +"TST_TOTAL (%d) and tst_count (%d) are not " +"equal" ,TST_TOTAL , tst_count); + } + tst_count =0 ; + +/* +* check events +*/ +while (i < len) { +struct fanotify_event_metadata *event; + + event = (struct fanotify_event_metadata *)&event_buf[i]; +if (test_num >=TST_TOTAL ) { +tst_res (TFAIL , +"get unnecessary event: mask=%llx " +"pid=%u fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, event->fd); + }else if (!(event->mask & event_set[test_num])) { +tst_res (TFAIL , +"get event: mask=%llx (expected %llx) " +"pid=%u fd=%u" , + (unsigned long long )event->mask, + event_set[test_num], + (unsigned )event->pid, event->fd); + }else if (event->pid !=getpid ()) { +tst_res (TFAIL , +"get event: mask=%llx pid=%u " +"(expected %u) fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, + (unsigned )getpid (), + event->fd); + }else { +if (event->fd ==-2 ) + goto pass; + ret =read (event->fd, buf,BUF_SIZE ); +if (ret !=strlen (fname)) { +tst_res (TFAIL , +"cannot read from returned fd " +"of event: mask=%llx pid=%u " +"fd=%u ret=%d (errno=%d)" , (unsigned long long )event->mask, - event_set[test_num], - (unsigned )event->pid, event->fd); - }else if (event->pid !=getpid ()) { -tst_resm (TFAIL , -"get event: mask=%llx pid=%u " -"(expected %u) fd=%u" , + (unsigned )event->pid, + event->fd, ret, errno); + }else if (memcmp (buf, fname,strlen (fname))) { +tst_res (TFAIL , +"wrong data read from returned fd " +"of event: mask=%llx pid=%u " +"fd=%u" , (unsigned long long )event->mask, (unsigned )event->pid, - (unsigned )getpid (), event->fd); }else { -if (event->fd ==-2 ) - goto pass; - ret =read (event->fd, buf,BUF_SIZE ); -if (ret !=strlen (fname)) { -tst_resm (TFAIL , -"cannot read from returned fd " -"of event: mask=%llx pid=%u " -"fd=%u ret=%d (errno=%d)" , - (unsigned long long )event->mask, - (unsigned )event->pid, - event->fd, ret, errno); - }else if (memcmp (buf, fname,strlen (fname))) { -tst_resm (TFAIL , -"wrong data read from returned fd " -"of event: mask=%llx pid=%u " -"fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, - event->fd); - }else { pass: -tst_resm (TPASS , -"get event: mask=%llx pid=%u fd=%u" , - (unsigned long long )event->mask, - (unsigned )event->pid, event->fd); - } - } -/* -* We have verified the data now so close fd and -* invalidate it so that we don't check it again -* unnecessarily -*/ -close (event->fd); - event->fd =-2 ; - event->mask &= ~event_set[test_num]; -/* No events left in current mask? Go for next event */ -if (event->mask ==0 ) { - i += event->event_len; +tst_res (TPASS , +"get event: mask=%llx pid=%u fd=%u" , + (unsigned long long )event->mask, + (unsigned )event->pid, event->fd); } - test_num++; - } -for (; test_num <TST_TOTAL ; test_num++) { -tst_resm (TFAIL ,"didn't get event: mask=%llx" , - event_set[test_num]); - } -/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */ -if (fanotify_mark (fd_notify,FAN_MARK_REMOVE ,FAN_ACCESS |FAN_MODIFY | -FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | " -"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " -"failed" , fd_notify, fname); +/* +* We have verified the data now so close fd and +* invalidate it so that we don't check it again +* unnecessarily +*/ +close (event->fd); + event->fd =-2 ; + event->mask &= ~event_set[test_num]; +/* No events left in current mask? Go for next event */ +if (event->mask ==0 ) { + i += event->event_len; } - + test_num++; } +for (; test_num <TST_TOTAL ; test_num++) { +tst_res (TFAIL ,"didn't get event: mask=%llx" , + event_set[test_num]); -cleanup (); -tst_exit (); + } +/* Remove mark to clear FAN_MARK_IGNORED_SURV_MODIFY */ +if (fanotify_mark (fd_notify,FAN_MARK_REMOVE ,FAN_ACCESS |FAN_MODIFY | +FAN_CLOSE |FAN_OPEN ,AT_FDCWD , fname) <0 ) { +tst_brk (TBROK |TERRNO , +"fanotify_mark (%d, FAN_MARK_REMOVE, FAN_ACCESS | " +"FAN_MODIFY | FAN_CLOSE | FAN_OPEN, AT_FDCWD, %s) " +"failed" , fd_notify, fname); + } }static void setup (void ) { -tst_sig (NOFORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; - -tst_tmpdir (); -sprintf (fname,"tfile_%d" ,getpid ()); - fd =SAFE_OPEN (cleanup, fname,O_RDWR |O_CREAT ,0700 ); -SAFE_WRITE (cleanup,1 , fd, fname,1 ); - + fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0700 ); +SAFE_WRITE (1 , fd, fname,1 );/* close the file we have open */ -SAFE_CLOSE (cleanup, fd); +SAFE_CLOSE (fd); -if ((fd_notify =fanotify_init (FAN_CLASS_NOTIF ,O_RDONLY )) <0 ) { -if (errno ==ENOSYS ) { -tst_brkm (TCONF , cleanup, -"fanotify is not configured in this kernel." ); - }else { -tst_brkm (TBROK |TERRNO , cleanup, -"fanotify_init failed" ); - } - } + fd_notify =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF ,O_RDONLY ); }static void cleanup (void ) { -if (fd_notify >0 &&close (fd_notify)) -tst_resm (TWARN |TERRNO ,"close(%d) failed" , fd_notify); - -tst_rmdir (); +if (fd_notify >0 ) +SAFE_CLOSE (fd_notify); } -#else - -int main (void ) -{ -tst_brkm (TCONF ,NULL ,"system doesn't have required fanotify support" ); -} +static struct tst_test test = { + .test_all = test01, + .setup = setup, + .cleanup = cleanup, + .needs_tmpdir =1 , + .needs_root =1 +}; +#else +TST_TEST_TCONF ("system doesn't have required fanotify support" );#endif
testcases/kernel/syscalls/fanotify/fanotify02.c +148 -178
368 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify03.c +113 -141
338 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify04.c +68 -97
258 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify05.c +62 -93
202 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify06.c +81 -112
281 lines not on this page · raw message
testcases/kernel/syscalls/fanotify/fanotify07.c +1 -8
@@ -119,14 +119,7 @@ static int setup_instance(void) {int fd; -if ((fd =fanotify_init (FAN_CLASS_CONTENT ,O_RDONLY )) <0 ) { -if (errno ==ENOSYS ) { -tst_brk (TCONF , -"fanotify is not configured in this kernel." ); - }else { -tst_brk (TBROK |TERRNO ,"fanotify_init failed" ); - } - } + fd =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY );if (fanotify_mark (fd,FAN_MARK_ADD ,FAN_ACCESS_PERM ,AT_FDCWD , fname) <0 ) {
Signature · 1 line
1.8.3.1
PATCH v4 2/3 fanotify: rewrite old cases with new lib
Hi!
Pushed with minor fixes (mostly warnings), thanks.
testcases/kernel/syscalls/fanotify/fanotify01.c +1 -1
@@ -256,7 +256,7 @@ void test01(void)if (event->fd ==-2 ) goto pass; ret =read (event->fd, buf,BUF_SIZE ); -if (ret !=strlen (fname)) { +if (ret != (int )strlen (fname)) {tst_res (TFAIL ,"cannot read from returned fd " "of event: mask=%llx pid=%u "
testcases/kernel/syscalls/fanotify/fanotify03.c +4 -4
@@ -38,6 +38,7 @@#include <string.h> #include <signal.h> #include <sys/syscall.h> +#include <stdlib.h> #include "tst_test.h" #include "fanotify.h"
@@ -86,6 +87,7 @@ static void generate_events(void)static void child_handler (int tmp) { + (void )tmp;/* * Close notification fd so that we cannot block while reading * from it
@@ -107,14 +109,12 @@ static void run_child(void) "sigaction(SIGCHLD, &child_action, NULL) failed"); } -switch (child_pid =fork ()) { -case 0 : + child_pid =SAFE_FORK (); +if (child_pid ==0 ) {/* Child will generate events now */ close (fd_notify);generate_events ();exit (0 ); -case -1 : -tst_brk (TBROK |TERRNO ,"fork() failed" ); } }
testcases/kernel/syscalls/fanotify/fanotify04.c +8 -12
@@ -105,7 +105,7 @@ static void check_mark(char *file, unsigned long long flag, char *flagstr,#define CHECK_MARK (file, flag, expect, func) check_mark(file, flag, #flag, expect, func) -static void do_open (char *file,int flag,char *flagstr) +static void do_open (char *file,int flag) {int fd;
@@ -113,16 +113,14 @@ static void do_open(char *file, int flag, char *flagstr)SAFE_CLOSE (fd); } -#define DO_OPEN (file, flag) do_open(file, flag, #flag) -static void open_file (char *file) { -DO_OPEN (file,0 ); +do_open (file,0 ); }static void open_dir (char *file) { -DO_OPEN (file,O_DIRECTORY ); +do_open (file,O_DIRECTORY ); }static void verify_event (int mask)
@@ -143,7 +141,7 @@ static void verify_event(int mask) }else if (fstat (event->fd, &st) <0 ) {tst_res (TFAIL ,"failed to stat event->fd (%s)" ,strerror (errno)); - }else if ((st.st_mode &S_IFMT ) != mask) { + }else if ((int )(st.st_mode &S_IFMT ) != mask) {tst_res (TFAIL ,"event->fd points to object of different type " "(%o != %o)" , st.st_mode &S_IFMT , mask); }else {
@@ -152,18 +150,16 @@ static void verify_event(int mask)close (event->fd); } -static void do_open_test (char *file,int flag,char *flagstr,int mask) +static void do_open_test (char *file,int flag,int mask) { -do_open (file, flag, flagstr); +do_open (file, flag);verify_event (mask); } -#define DO_OPEN_TEST (file, flag, mask) do_open_test(file, flag, #flag, mask) -static void test_open_file (char *file) { -DO_OPEN_TEST (file,0 ,S_IFREG ); +do_open_test (file,0 ,S_IFREG ); }static void verify_no_event (void )
@@ -190,7 +186,7 @@ static void verify_no_event(void)static void test_open_symlink (char *file) {/* Since mark is on a symlink, no event should be generated by opening a file */ -DO_OPEN (file,0 ); +do_open (file,0 );verify_no_event (); }
testcases/kernel/syscalls/fanotify/fanotify06.c +1 -2
@@ -237,8 +237,7 @@ static void cleanup(void) {cleanup_fanotify_groups (); -if (chdir (tst_get_tmpdir ()) <0 ) -tst_brk (TBROK ,"chdir(tmpdir) failed" ); +SAFE_CHDIR ("../" );if (mount_created &&tst_umount (MOUNT_NAME ) <0 )tst_brk (TBROK |TERRNO ,"umount failed" );
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 3/3 syscalls/fanotify08: add sanity check for FAN_CLOEXEC
In reply to Xiong Zhou--- runtest/syscalls | 1 + testcases/kernel/syscalls/fanotify/fanotify08.c | 91 +++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify08.c
runtest/syscalls +1 -0
@@ -481,6 +481,7 @@ fanotify04 fanotify04 fanotify05 fanotify05 fanotify06 fanotify06 fanotify07 fanotify07 +fanotify08 fanotify08 ioperm01 ioperm01 ioperm02 ioperm02
testcases/kernel/syscalls/fanotify/fanotify08.c new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v4 3/3 syscalls/fanotify08: add sanity check for FAN_CLOEXEC
Hi!
I've added fanotify08 into the .gitignore and pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]