[CRIU] [PATCH 7/7] zdtm/fanotify00: fix fanotify_{init, mark} calls

Dmitry Safonov dsafonov at virtuozzo.com
Mon Jan 9 09:19:12 PST 2017


O_* flags should be in event_f_flags parameter, according to
fanotify_init(2).
On x86_32 fanotify_mark() has second mask argument (as mask is 64-bit,
the higher parts of mask shouldn't be used):
> COMPAT_SYSCALL_DEFINE6(fanotify_mark,
> 				int, fanotify_fd, unsigned int, flags,
> 				__u32, mask0, __u32, mask1, int, dfd,
> 				const char  __user *, pathname)
> {
> 	return sys_fanotify_mark(fanotify_fd, flags,
> #ifdef __BIG_ENDIAN
> 				((__u64)mask0 << 32) | mask1,
> #else
> 				((__u64)mask1 << 32) | mask0,
> #endif
> 				 dfd, pathname);

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 test/zdtm/static/fanotify00.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/test/zdtm/static/fanotify00.c b/test/zdtm/static/fanotify00.c
index 1172145fef75..3084e185038b 100644
--- a/test/zdtm/static/fanotify00.c
+++ b/test/zdtm/static/fanotify00.c
@@ -75,7 +75,11 @@ static int fanotify_init(unsigned int flags, unsigned int event_f_flags)
 static int fanotify_mark(int fanotify_fd, unsigned int flags, unsigned long mask,
 			 int dfd, const char *pathname)
 {
+#ifdef __i386__
+	return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, 0, dfd, pathname);
+#else
 	return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, pathname);
+#endif
 }
 
 #define fdinfo_field(str, field)	!strncmp(str, field":", sizeof(field))
@@ -226,9 +230,8 @@ int main (int argc, char *argv[])
 		}
 	}
 
-	fa_fd = fanotify_init(FAN_NONBLOCK | O_RDONLY | O_LARGEFILE |
-			      FAN_CLASS_NOTIF | FAN_UNLIMITED_QUEUE,
-			      0);
+	fa_fd = fanotify_init(FAN_NONBLOCK | FAN_CLASS_NOTIF | FAN_UNLIMITED_QUEUE,
+			      O_RDONLY | O_LARGEFILE);
 	if (fa_fd < 0) {
 		pr_perror("fanotify_init failed");
 		exit(1);
-- 
2.11.0



More information about the CRIU mailing list