diff options
Diffstat (limited to 'fs/notify/fdinfo.c')
-rw-r--r-- | fs/notify/fdinfo.c | 78 |
1 files changed, 32 insertions, 46 deletions
diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c index 9d7e2b9659cb..6ffd220eb14d 100644 --- a/fs/notify/fdinfo.c +++ b/fs/notify/fdinfo.c | |||
@@ -20,25 +20,24 @@ | |||
20 | 20 | ||
21 | #if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY) | 21 | #if defined(CONFIG_INOTIFY_USER) || defined(CONFIG_FANOTIFY) |
22 | 22 | ||
23 | static int show_fdinfo(struct seq_file *m, struct file *f, | 23 | static void show_fdinfo(struct seq_file *m, struct file *f, |
24 | int (*show)(struct seq_file *m, struct fsnotify_mark *mark)) | 24 | void (*show)(struct seq_file *m, |
25 | struct fsnotify_mark *mark)) | ||
25 | { | 26 | { |
26 | struct fsnotify_group *group = f->private_data; | 27 | struct fsnotify_group *group = f->private_data; |
27 | struct fsnotify_mark *mark; | 28 | struct fsnotify_mark *mark; |
28 | int ret = 0; | ||
29 | 29 | ||
30 | mutex_lock(&group->mark_mutex); | 30 | mutex_lock(&group->mark_mutex); |
31 | list_for_each_entry(mark, &group->marks_list, g_list) { | 31 | list_for_each_entry(mark, &group->marks_list, g_list) { |
32 | ret = show(m, mark); | 32 | show(m, mark); |
33 | if (ret) | 33 | if (seq_has_overflowed(m)) |
34 | break; | 34 | break; |
35 | } | 35 | } |
36 | mutex_unlock(&group->mark_mutex); | 36 | mutex_unlock(&group->mark_mutex); |
37 | return ret; | ||
38 | } | 37 | } |
39 | 38 | ||
40 | #if defined(CONFIG_EXPORTFS) | 39 | #if defined(CONFIG_EXPORTFS) |
41 | static int show_mark_fhandle(struct seq_file *m, struct inode *inode) | 40 | static void show_mark_fhandle(struct seq_file *m, struct inode *inode) |
42 | { | 41 | { |
43 | struct { | 42 | struct { |
44 | struct file_handle handle; | 43 | struct file_handle handle; |
@@ -52,71 +51,62 @@ static int show_mark_fhandle(struct seq_file *m, struct inode *inode) | |||
52 | ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); | 51 | ret = exportfs_encode_inode_fh(inode, (struct fid *)f.handle.f_handle, &size, 0); |
53 | if ((ret == FILEID_INVALID) || (ret < 0)) { | 52 | if ((ret == FILEID_INVALID) || (ret < 0)) { |
54 | WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); | 53 | WARN_ONCE(1, "Can't encode file handler for inotify: %d\n", ret); |
55 | return 0; | 54 | return; |
56 | } | 55 | } |
57 | 56 | ||
58 | f.handle.handle_type = ret; | 57 | f.handle.handle_type = ret; |
59 | f.handle.handle_bytes = size * sizeof(u32); | 58 | f.handle.handle_bytes = size * sizeof(u32); |
60 | 59 | ||
61 | ret = seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", | 60 | seq_printf(m, "fhandle-bytes:%x fhandle-type:%x f_handle:", |
62 | f.handle.handle_bytes, f.handle.handle_type); | 61 | f.handle.handle_bytes, f.handle.handle_type); |
63 | 62 | ||
64 | for (i = 0; i < f.handle.handle_bytes; i++) | 63 | for (i = 0; i < f.handle.handle_bytes; i++) |
65 | ret |= seq_printf(m, "%02x", (int)f.handle.f_handle[i]); | 64 | seq_printf(m, "%02x", (int)f.handle.f_handle[i]); |
66 | |||
67 | return ret; | ||
68 | } | 65 | } |
69 | #else | 66 | #else |
70 | static int show_mark_fhandle(struct seq_file *m, struct inode *inode) | 67 | static void show_mark_fhandle(struct seq_file *m, struct inode *inode) |
71 | { | 68 | { |
72 | return 0; | ||
73 | } | 69 | } |
74 | #endif | 70 | #endif |
75 | 71 | ||
76 | #ifdef CONFIG_INOTIFY_USER | 72 | #ifdef CONFIG_INOTIFY_USER |
77 | 73 | ||
78 | static int inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) | 74 | static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) |
79 | { | 75 | { |
80 | struct inotify_inode_mark *inode_mark; | 76 | struct inotify_inode_mark *inode_mark; |
81 | struct inode *inode; | 77 | struct inode *inode; |
82 | int ret = 0; | ||
83 | 78 | ||
84 | if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) | 79 | if (!(mark->flags & (FSNOTIFY_MARK_FLAG_ALIVE | FSNOTIFY_MARK_FLAG_INODE))) |
85 | return 0; | 80 | return; |
86 | 81 | ||
87 | inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); | 82 | inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark); |
88 | inode = igrab(mark->i.inode); | 83 | inode = igrab(mark->i.inode); |
89 | if (inode) { | 84 | if (inode) { |
90 | ret = seq_printf(m, "inotify wd:%x ino:%lx sdev:%x " | 85 | seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ", |
91 | "mask:%x ignored_mask:%x ", | 86 | inode_mark->wd, inode->i_ino, inode->i_sb->s_dev, |
92 | inode_mark->wd, inode->i_ino, | 87 | mark->mask, mark->ignored_mask); |
93 | inode->i_sb->s_dev, | 88 | show_mark_fhandle(m, inode); |
94 | mark->mask, mark->ignored_mask); | 89 | seq_putc(m, '\n'); |
95 | ret |= show_mark_fhandle(m, inode); | ||
96 | ret |= seq_putc(m, '\n'); | ||
97 | iput(inode); | 90 | iput(inode); |
98 | } | 91 | } |
99 | |||
100 | return ret; | ||
101 | } | 92 | } |
102 | 93 | ||
103 | int inotify_show_fdinfo(struct seq_file *m, struct file *f) | 94 | void inotify_show_fdinfo(struct seq_file *m, struct file *f) |
104 | { | 95 | { |
105 | return show_fdinfo(m, f, inotify_fdinfo); | 96 | show_fdinfo(m, f, inotify_fdinfo); |
106 | } | 97 | } |
107 | 98 | ||
108 | #endif /* CONFIG_INOTIFY_USER */ | 99 | #endif /* CONFIG_INOTIFY_USER */ |
109 | 100 | ||
110 | #ifdef CONFIG_FANOTIFY | 101 | #ifdef CONFIG_FANOTIFY |
111 | 102 | ||
112 | static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) | 103 | static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) |
113 | { | 104 | { |
114 | unsigned int mflags = 0; | 105 | unsigned int mflags = 0; |
115 | struct inode *inode; | 106 | struct inode *inode; |
116 | int ret = 0; | ||
117 | 107 | ||
118 | if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) | 108 | if (!(mark->flags & FSNOTIFY_MARK_FLAG_ALIVE)) |
119 | return 0; | 109 | return; |
120 | 110 | ||
121 | if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) | 111 | if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) |
122 | mflags |= FAN_MARK_IGNORED_SURV_MODIFY; | 112 | mflags |= FAN_MARK_IGNORED_SURV_MODIFY; |
@@ -124,26 +114,22 @@ static int fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark) | |||
124 | if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { | 114 | if (mark->flags & FSNOTIFY_MARK_FLAG_INODE) { |
125 | inode = igrab(mark->i.inode); | 115 | inode = igrab(mark->i.inode); |
126 | if (!inode) | 116 | if (!inode) |
127 | goto out; | 117 | return; |
128 | ret = seq_printf(m, "fanotify ino:%lx sdev:%x " | 118 | seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x ignored_mask:%x ", |
129 | "mflags:%x mask:%x ignored_mask:%x ", | 119 | inode->i_ino, inode->i_sb->s_dev, |
130 | inode->i_ino, inode->i_sb->s_dev, | 120 | mflags, mark->mask, mark->ignored_mask); |
131 | mflags, mark->mask, mark->ignored_mask); | 121 | show_mark_fhandle(m, inode); |
132 | ret |= show_mark_fhandle(m, inode); | 122 | seq_putc(m, '\n'); |
133 | ret |= seq_putc(m, '\n'); | ||
134 | iput(inode); | 123 | iput(inode); |
135 | } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { | 124 | } else if (mark->flags & FSNOTIFY_MARK_FLAG_VFSMOUNT) { |
136 | struct mount *mnt = real_mount(mark->m.mnt); | 125 | struct mount *mnt = real_mount(mark->m.mnt); |
137 | 126 | ||
138 | ret = seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x " | 127 | seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n", |
139 | "ignored_mask:%x\n", mnt->mnt_id, mflags, | 128 | mnt->mnt_id, mflags, mark->mask, mark->ignored_mask); |
140 | mark->mask, mark->ignored_mask); | ||
141 | } | 129 | } |
142 | out: | ||
143 | return ret; | ||
144 | } | 130 | } |
145 | 131 | ||
146 | int fanotify_show_fdinfo(struct seq_file *m, struct file *f) | 132 | void fanotify_show_fdinfo(struct seq_file *m, struct file *f) |
147 | { | 133 | { |
148 | struct fsnotify_group *group = f->private_data; | 134 | struct fsnotify_group *group = f->private_data; |
149 | unsigned int flags = 0; | 135 | unsigned int flags = 0; |
@@ -169,7 +155,7 @@ int fanotify_show_fdinfo(struct seq_file *m, struct file *f) | |||
169 | seq_printf(m, "fanotify flags:%x event-flags:%x\n", | 155 | seq_printf(m, "fanotify flags:%x event-flags:%x\n", |
170 | flags, group->fanotify_data.f_flags); | 156 | flags, group->fanotify_data.f_flags); |
171 | 157 | ||
172 | return show_fdinfo(m, f, fanotify_fdinfo); | 158 | show_fdinfo(m, f, fanotify_fdinfo); |
173 | } | 159 | } |
174 | 160 | ||
175 | #endif /* CONFIG_FANOTIFY */ | 161 | #endif /* CONFIG_FANOTIFY */ |