Skip to contentSkip to conversation

syscalls/fanotify: Verify that inode ignore masks are properly reflected

PATCH In review Jan Kara 2 participants 2 messages Nov 6, 2014 – Nov 10, 2014

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 syscalls/fanotify: Verify that inode ignore masks are properly reflected

Verify that when inode has an ignore mask set, it is properly reflected when notifying a mountpoint.

---
 runtest/syscalls                                |    1 +
 testcases/kernel/syscalls/.gitignore            |    1 +
 testcases/kernel/syscalls/fanotify/fanotify06.c |  267 +
 utils/ffsb-6.0-rc2/config.h.in                  |   49 +-
 utils/ffsb-6.0-rc2/configure                    | 5937 +++++++++++------------
 5 files changed, 3069 insertions(+), 3186 deletions(-)
 create mode 100644 testcases/kernel/syscalls/fanotify/fanotify06.c
runtest/syscalls +1 -0
index 6b8de24fea82..44969f387df6 100644
@@ -449,6 +449,7 @@ fanotify02 fanotify02
 fanotify03 fanotify03
 fanotify04 fanotify04
 fanotify05 fanotify05
+fanotify06 fanotify06
 
 ioperm01 ioperm01
 ioperm02 ioperm02
testcases/kernel/syscalls/.gitignore +1 -0
index 41fec072d783..92c0bf51487b 100644
@@ -1050,5 +1050,6 @@
 /fanotify/fanotify03
 /fanotify/fanotify04
 /fanotify/fanotify05
+/fanotify/fanotify06
 /perf_event_open/perf_event_open01
 /perf_event_open/perf_event_open02
testcases/kernel/syscalls/fanotify/fanotify06.c new file +267 -0

267 lines not on this page · raw message

utils/ffsb-6.0-rc2/config.h.in +33 -16

68 lines not on this page · raw message

utils/ffsb-6.0-rc2/configure +2767 -3170

2,652 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 8 lines
1.8.1.4


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Part of the diff is not shown here. View the raw message.

#1 lore raw

Hi!

Quoted 10 lines

Verify that when inode has an ignore mask set, it is properly reflected when notifying a mountpoint.

---
 runtest/syscalls                                |    1 +
 testcases/kernel/syscalls/.gitignore            |    1 +
 testcases/kernel/syscalls/fanotify/fanotify06.c |  267 +
 utils/ffsb-6.0-rc2/config.h.in                  |   49 +-
 utils/ffsb-6.0-rc2/configure                    | 5937 +++++++++++------------

Looks like changes in generated configure file in ffsb slipped into this patch accidentally.

Quoted 56 lines
testcases/kernel/syscalls/fanotify/fanotify06.c new file +53 -0
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2014 SUSE.  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 Jan Kara <[email protected]>
+ *
+ * DESCRIPTION
+ *     Check that fanotify properly merges ignore mask of an inode and
+ *     mountpoint.
+ */
+#include "config.h"
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/syscall.h>
+#include "test.h"
+#include "usctest.h"
+#include "linux_syscall_numbers.h"
+#include "fanotify.h"
+#include "safe_macros.h"
+
+char *TCID = "fanotify06";
+
+#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)

testcases/kernel/syscalls/fanotify/fanotify06.c line 63

Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify06.c new file +10 -0
+
+static void setup(void);
+static void cleanup(void);
+
+unsigned int fanotify_prio[] = {
+	FAN_CLASS_PRE_CONTENT,
+	FAN_CLASS_CONTENT,
+	FAN_CLASS_NOTIF
+};
+#define FANOTIFY_PRIORITIES (sizeof(fanotify_prio) / sizeof(unsigned int))

We have ARRAY_SIZE() macro for this purpose.

Quoted 31 lines
testcases/kernel/syscalls/fanotify/fanotify06.c new file +31 -0
+#define GROUPS_PER_PRIO 3
+
+int TST_TOTAL = GROUPS_PER_PRIO * FANOTIFY_PRIORITIES;
+
+#define BUF_SIZE 256
+static char fname[BUF_SIZE];
+static int fd;
+static int fd_notify[FANOTIFY_PRIORITIES][GROUPS_PER_PRIO];
+
+static char event_buf[EVENT_BUF_LEN];
+
+static void create_fanotify_groups(void)
+{
+	unsigned int p, i;
+	int ret;
+
+	for (p = 0; p < FANOTIFY_PRIORITIES; p++) {
+		for (i = 0; i < GROUPS_PER_PRIO; i++) {
+			fd_notify[p][i] = fanotify_init(fanotify_prio[p] |
+							FAN_NONBLOCK,
+							O_RDONLY);
+			if (fd_notify[p][i] < 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/fanotify06.c line 105

Quoted 10 lines
testcases/kernel/syscalls/fanotify/fanotify06.c new file +10 -0
+			/* Add mount mark for each group */
+			ret = fanotify_mark(fd_notify[p][i],
+					    FAN_MARK_ADD | FAN_MARK_MOUNT,
+					    FAN_MODIFY,
+					    AT_FDCWD, ".");
+			if (ret < 0) {
+				tst_brkm(TBROK | TERRNO, cleanup,
+					 "fanotify_mark(%d, FAN_MARK_ADD | "
+					 "FAN_MARK_MOUNT, FAN_MODIFY, AT_FDCWD,"
+					 " \".\") failed", fd_notify[p][i]);

I usually use single quotes inside of C strings to avoid the need to escape them.

Otherwise it looks good to me.

Signature · 8 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list