Skip to content

Commit 55985dd

Browse files
Cyrill Gorcunovtorvalds
authored andcommitted
procfs: add ability to plug in auxiliary fdinfo providers
This patch brings ability to print out auxiliary data associated with file in procfs interface /proc/pid/fdinfo/fd. In particular further patches make eventfd, evenpoll, signalfd and fsnotify to print additional information complete enough to restore these objects after checkpoint. To simplify the code we add show_fdinfo callback inside struct file_operations (as Al and Pavel are proposing). Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Pavel Emelyanov <xemul@parallels.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andrey Vagin <avagin@openvz.org> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: James Bottomley <jbottomley@parallels.com> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Matthew Helsley <matt.helsley@gmail.com> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@onelan.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 2bf1cbf commit 55985dd

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎fs/proc/fd.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ static int seq_show(struct seq_file *m, void *v)
5050
if (!ret) {
5151
seq_printf(m, "pos:\t%lli\nflags:\t0%o\n",
5252
(long long)file->f_pos, f_flags);
53+
if (file->f_op->show_fdinfo)
54+
ret = file->f_op->show_fdinfo(m, file);
5355
fput(file);
5456
}
5557

‎include/linux/fs.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct vm_area_struct;
4444
struct vfsmount;
4545
struct cred;
4646
struct swap_info_struct;
47+
struct seq_file;
4748

4849
extern void __init inode_init(void);
4950
extern void __init inode_init_early(void);
@@ -1543,6 +1544,7 @@ struct file_operations {
15431544
int (*setlease)(struct file *, long, struct file_lock **);
15441545
long (*fallocate)(struct file *file, int mode, loff_t offset,
15451546
loff_t len);
1547+
int (*show_fdinfo)(struct seq_file *m, struct file *f);
15461548
};
15471549

15481550
struct inode_operations {
@@ -1578,8 +1580,6 @@ struct inode_operations {
15781580
umode_t create_mode, int *opened);
15791581
} ____cacheline_aligned;
15801582

1581-
struct seq_file;
1582-
15831583
ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
15841584
unsigned long nr_segs, unsigned long fast_segs,
15851585
struct iovec *fast_pointer,

0 commit comments

Comments
 (0)