Re: [patch 7/7] fs, notify: Add procfs fdinfo helper v6

From: Andrew Morton
Date: Fri Nov 16 2012 - 18:55:56 EST


On Wed, 14 Nov 2012 19:19:44 +0400
Cyrill Gorcunov <gorcunov@xxxxxxxxxx> wrote:

> This allow us to print out fsnotify details such as
> watchee inode, device, mask and optionally a file handle.
>
> For inotify objects if kernel compiled with exportfs support
> the output will be
>
> | pos: 0
> | flags: 02000000
> | inotify wd: 3 ino: 9e7e sdev: 800013 mask: 800afce ignored_mask: 0 fhandle-bytes: 8 fhandle-type: 1 f_handle: 7e9e0000640d1b6d
> | inotify wd: 2 ino: a111 sdev: 800013 mask: 800afce ignored_mask: 0 fhandle-bytes: 8 fhandle-type: 1 f_handle: 11a1000020542153
> | inotify wd: 1 ino: 6b149 sdev: 800013 mask: 800afce ignored_mask: 0 fhandle-bytes: 8 fhandle-type: 1 f_handle: 49b1060023552153

This is a lousy output format. It's sort-of like a sensible set of
name-value tuples: "name:value name:value name:value" but

a) it has lots of random pointless whitespace after the colons and

b) several of the labels have spaces in them, just to make life
harder for parsing code and

c) inotify-wd is secretly printed in decimal while everything else
is in hex.


What happens if we do something like the below (which will require a
changelog update)?

--- a/fs/notify/fdinfo.c~fs-notify-add-procfs-fdinfo-helper-v6-fix
+++ a/fs/notify/fdinfo.c
@@ -50,7 +50,7 @@ static int show_mark_fhandle(struct seq_
f.handle.handle_bytes = sizeof(f.pad);
size = f.handle.handle_bytes >> 2;

- ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
+ ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0);
if ((ret == 255) || (ret == -ENOSPC)) {
WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret);
return 0;
@@ -59,7 +59,7 @@ static int show_mark_fhandle(struct seq_
f.handle.handle_type = ret;
f.handle.handle_bytes = size * sizeof(u32);

- ret = seq_printf(m, "fhandle-bytes: %8x fhandle-type: %8x f_handle: ",
+ ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:",
f.handle.handle_bytes, f.handle.handle_type);

for (i = 0; i < f.handle.handle_bytes; i++)
@@ -86,8 +86,8 @@ static int inotify_fdinfo(struct seq_fil
inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
inode = igrab(mark->i.inode);
if (inode) {
- ret = seq_printf(m, "inotify wd: %8d ino: %16lx sdev: %8x "
- "mask: %8x ignored_mask: %8x ",
+ ret = seq_printf(m, "inotify-wd:%x ino:%lx sdev:%x "
+ "mask:%x ignored_mask:%x ",
inode_mark->wd, inode->i_ino,
inode->i_sb->s_dev,
mark->mask, mark->ignored_mask);
@@ -120,15 +120,16 @@ static int fanotify_fdinfo(struct seq_fi
inode = igrab(mark->i.inode);
if (!inode)
goto out;
- ret = seq_printf(m, "fanotify ino: %16lx sdev: %8x "
- "mask: %8x ignored_mask: %8x\n",
+ ret = seq_printf(m, "fanotify-ino:%x sdev:%x "
+ "mask:%x ignored_mask:%x\n",
inode->i_ino, inode->i_sb->s_dev,
mark->mask, mark->ignored_mask);
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: %8x mask: %8x ignored_mask: %8x\n",
+ ret = seq_printf(m, "fanotify-mnt_id:%x mask:%x "
+ "ignored_mask:%x\n",
mnt->mnt_id, mark->mask, mark->ignored_mask);
}
out:
_

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/