Skip to contentSkip to conversation

An update to fanotify fdinfo output

PATCH New Cyrill Gorcunov 1 participant 3 messages Dec 7, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover An update to fanotify fdinfo output

Hi Andrew, here is an update for fanotify fdinfo output.
I also update documentation to fit the current state of the output format. This should be the last bits we need for fdinfo. As always any comments are highly appreciated.

Cyrill

#1 lore raw

PATCH 1/2 fs, fanotify: Add @mflags field to fanotify output

The kernel keeps FAN_MARK_IGNORED_SURV_MODIFY bit separately from fsnotify_mark::mask|ignored_mask thus put it in @mflags (mark flags) field so the user-space reader will be able to detect if such bit were used on mark creation procedure.

 | pos:	0
 | flags:	04002
 | fanotify flags:10 event-flags:0
 | fanotify mnt_id:12 mflags:40 mask:38 ignored_mask:40000003
 | fanotify ino:4f969 sdev:800013 mflags:0 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:69f90400c275b5b4
CC Pavel Emelyanov <[email protected]>
CC Oleg Nesterov <[email protected]>
CC Andrey Vagin <[email protected]>
CC Al Viro <[email protected]>
CC Alexey Dobriyan <[email protected]>
CC Andrew Morton <[email protected]>
CC James Bottomley <[email protected]>
CC "Aneesh Kumar K.V" <[email protected]>
CC Matthew Helsley <[email protected]>
CC "J. Bruce Fields" <[email protected]>
CC Tvrtko Ursulin <[email protected]>
---
 fs/notify/fdinfo.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/notify/fdinfo.c +9 -5
Index: linux-2.6.git/fs/notify/fdinfo.c
===================================================================
@@ -111,29 +111,33 @@ int inotify_show_fdinfo(struct seq_file
 
 static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
 {
+	unsigned int mflags = 0;
 	struct inode *inode;
 	int ret = 0;
 
 	if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE))
 		return 0;
 
+	if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
+		mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
+
 	if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) {
 		inode = igrab(mark->i.inode);
 		if (!inode)
 			goto out;
 		ret = seq_printf(m, "fanotify ino:%lx sdev:%x "
-				 "mask:%x ignored_mask:%x ",
+				 "mflags:%x mask:%x ignored_mask:%x ",
 				 inode->i_ino, inode->i_sb->s_dev,
-				 mark->mask, mark->ignored_mask);
+				 mflags, mark->mask, mark->ignored_mask);
 		ret |= show_mark_fhandle(m, inode);
 		ret |= seq_putc(m, '\n');
 		iput(inode);
 	} else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) {
 		struct mount *mnt = real_mount(mark->m.mnt);
 
-		ret = seq_printf(m, "fanotify mnt_id:%x mask:%x "
-				 "ignored_mask:%x\n",
-				 mnt->mnt_id, mark->mask, mark->ignored_mask);
+		ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x "
+				 "ignored_mask:%x\n", mnt->mnt_id, mflags,
+				 mark->mask, mark->ignored_mask);
 	}
 out:
 	return ret;
#2 lore raw

PATCH 2/2 docs: Update documentation about /proc/<pid>/fdinfo/<fd> fanotify output

In reply to Cyrill Gorcunov
CC Pavel Emelyanov <[email protected]>
CC Oleg Nesterov <[email protected]>
CC Andrey Vagin <[email protected]>
CC Al Viro <[email protected]>
CC Alexey Dobriyan <[email protected]>
CC Andrew Morton <[email protected]>
CC James Bottomley <[email protected]>
CC "Aneesh Kumar K.V" <[email protected]>
CC Alexey Dobriyan <[email protected]>
CC Matthew Helsley <[email protected]>
CC "J. Bruce Fields" <[email protected]>
CC "Aneesh Kumar K.V" <[email protected]>
CC Tvrtko Ursulin <[email protected]>
---
 Documentation/filesystems/proc.txt |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
Documentation/filesystems/proc.txt +16 -10
Index: linux-2.6.git/Documentation/filesystems/proc.txt
===================================================================
@@ -1696,21 +1696,27 @@ pair provide additional information part
 	If the kernel is built without exportfs support the file handle won't be
 	printed out.
 
-	For fanotify files the format is
+	If there is no inotify mark attached yet the 'inotify' line will be omitted.
 
-	pos:	0
-	flags:	02
-	fanotify ino:2 sdev:800013 mask:1 ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:0200000000000000
-
-	or
+	For fanotify files the format is
 
 	pos:	0
 	flags:	02
-	fanotify mnt_id:13 mask:1 ignored_mask:40000000
+	fanotify flags:10 event-flags:0
+	fanotify mnt_id:12 mflags:40 mask:38 ignored_mask:40000003
+	fanotify ino:4f969 sdev:800013 mflags:0 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:69f90400c275b5b4
+
+	where fanotify 'flags' and 'event-flags' are values used in fanotify_init
+	call, 'mnt_id' is the mount point identifier, 'mflags' is the value of
+	flags associated with mark which are tracked separately from events
+	mask. 'ino', 'sdev' are target inode and device, 'mask' is the events
+	mask and 'ignored_mask' is the mask of events which are to be ignored.
+	All in hex format. Incorporation of 'mflags', 'mask' and 'ignored_mask'
+	does provide information about flags and mask used in fanotify_mark
+	call [see fsnotify manpage for details].
 
-	where 'ino', 'sdev' are target inode and device, 'mnt_id' is the mount
-	point identifier, 'mask' is the events mask used and 'ignored_mask' is
-	the mask of events which are to be ignored. All in hex format.
+	While the first three lines are mandatory and always printed, the rest is
+	optional and may be omitted if no marks created yet.
 
 
 ------------------------------------------------------------------------------