This patch adds "id" field in /proc/pid/fdinfo/ output which represent generic ID for 'struct file' being used by a task. Based-on-patch-from: Pavel Emelyanov Signed-off-by: Cyrill Gorcunov CC: Glauber Costa CC: Andi Kleen CC: Tejun Heo CC: Matt Helsley CC: Pekka Enberg CC: Eric Dumazet CC: Vasiliy Kulikov CC: Andrew Morton --- 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, }; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/