Messages in this thread Patch in this message | | | Date | Thu, 22 Dec 2011 16:56:42 +0400 | From | Cyrill Gorcunov <> | Subject | [patch 3/4] proc: Show open file ID in /proc/pid/fdinfo/* |
| |
This patch adds "id" field in /proc/pid/fdinfo/<file> output which represent generic ID for 'struct file' being used by a task.
Based-on-patch-from: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> CC: Glauber Costa <glommer@parallels.com> CC: Andi Kleen <andi@firstfloor.org> CC: Tejun Heo <tj@kernel.org> CC: Matt Helsley <matthltc@us.ibm.com> CC: Pekka Enberg <penberg@kernel.org> CC: Eric Dumazet <eric.dumazet@gmail.com> CC: Vasiliy Kulikov <segoon@openwall.com> CC: Andrew Morton <akpm@linux-foundation.org> --- fs/proc/base.c | 34 +++++++++++++++++++++++++++++----- include/linux/mm.h | 1 + 2 files changed, 30 insertions(+), 5 deletions(-)
Index: linux-2.6.git/fs/proc/base.c =================================================================== --- linux-2.6.git.orig/fs/proc/base.c +++ linux-2.6.git/fs/proc/base.c @@ -1888,8 +1888,36 @@ out: return ~0U; } +#ifdef CONFIG_GENERIC_OBJECT_IDS + +#define PROC_FDINFO_MAX 128 + +static void proc_fd_info_fill(char *info, struct file *file, unsigned int f_flags) +{ + snprintf(info, PROC_FDINFO_MAX, + "pos:\t%lli\n" + "flags:\t0%o\n" + "id:\t%lu\n", + (long long)file->f_pos, + f_flags, + gen_obj_id(file, GEN_OBJ_ID_FILE)); +} + +#else /* CONFIG_GENERIC_OBJECT_IDS */ + #define PROC_FDINFO_MAX 64 +static void proc_fd_info_fill(char *info, struct file *file, unsigned int f_flags) +{ + snprintf(info, PROC_FDINFO_MAX, + "pos:\t%lli\n" + "flags:\t0%o\n", + (long long)file->f_pos, + f_flags); +} + +#endif + static int proc_fd_info(struct inode *inode, struct path *path, char *info) { struct task_struct *task = get_proc_task(inode); @@ -1922,11 +1950,7 @@ static int proc_fd_info(struct inode *in path_get(&file->f_path); } if (info) - snprintf(info, PROC_FDINFO_MAX, - "pos:\t%lli\n" - "flags:\t0%o\n", - (long long) file->f_pos, - f_flags); + proc_fd_info_fill(info, file, f_flags); spin_unlock(&files->file_lock); put_files_struct(files); return 0; Index: linux-2.6.git/include/linux/mm.h =================================================================== --- linux-2.6.git.orig/include/linux/mm.h +++ linux-2.6.git/include/linux/mm.h @@ -1642,6 +1642,7 @@ extern void copy_user_huge_page(struct p enum { GEN_OBJ_ID_NS, + GEN_OBJ_ID_FILE, GEN_OBJ_ID_TYPES, };
| |