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 CC: Alexey Dobriyan --- fs/proc/base.c | 35 ++++++++++++++++++++++++++++++----- include/linux/gen_obj_id.h | 1 + 2 files changed, 31 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 @@ -84,6 +84,7 @@ #include #include #include +#include #ifdef CONFIG_HARDWALL #include #endif @@ -1888,8 +1889,36 @@ out: return ~0U; } +#ifdef CONFIG_GENERIC_OBJECT_ID + +#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_ID */ + #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 /* CONFIG_GENERIC_OBJECT_ID */ + static int proc_fd_info(struct inode *inode, struct path *path, char *info) { struct task_struct *task = get_proc_task(inode); @@ -1922,11 +1951,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/gen_obj_id.h =================================================================== --- linux-2.6.git.orig/include/linux/gen_obj_id.h +++ linux-2.6.git/include/linux/gen_obj_id.h @@ -4,6 +4,7 @@ #ifdef __KERNEL__ enum { + GEN_OBJ_ID_FILE, GEN_OBJ_ID_NS, 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/