Commit 59e55e6cf86eb472e8373831c4234252916c53ef
Committed by
Linus Torvalds
1 parent
300a6204b4
Exists in
master
and in
4 other branches
Remove devpts_root global
Remove the 'devpts_root' global variable and find the root dentry using the super_block. The super-block can be found from the device inode, using the new wrapper, pts_sb_from_inode(). Changelog: This patch is based on an earlier patchset from Serge Hallyn and Matt Helsley. Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 20 additions and 9 deletions Side-by-side Diff
fs/devpts/inode.c
... | ... | @@ -34,7 +34,6 @@ |
34 | 34 | static DEFINE_MUTEX(allocated_ptys_lock); |
35 | 35 | |
36 | 36 | static struct vfsmount *devpts_mnt; |
37 | -static struct dentry *devpts_root; | |
38 | 37 | |
39 | 38 | static struct { |
40 | 39 | int setuid; |
... | ... | @@ -56,6 +55,14 @@ |
56 | 55 | {Opt_err, NULL} |
57 | 56 | }; |
58 | 57 | |
58 | +static inline struct super_block *pts_sb_from_inode(struct inode *inode) | |
59 | +{ | |
60 | + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) | |
61 | + return inode->i_sb; | |
62 | + | |
63 | + return devpts_mnt->mnt_sb; | |
64 | +} | |
65 | + | |
59 | 66 | static int devpts_remount(struct super_block *sb, int *flags, char *data) |
60 | 67 | { |
61 | 68 | char *p; |
... | ... | @@ -142,7 +149,7 @@ |
142 | 149 | inode->i_fop = &simple_dir_operations; |
143 | 150 | inode->i_nlink = 2; |
144 | 151 | |
145 | - devpts_root = s->s_root = d_alloc_root(inode); | |
152 | + s->s_root = d_alloc_root(inode); | |
146 | 153 | if (s->s_root) |
147 | 154 | return 0; |
148 | 155 | |
... | ... | @@ -211,7 +218,9 @@ |
211 | 218 | struct tty_driver *driver = tty->driver; |
212 | 219 | dev_t device = MKDEV(driver->major, driver->minor_start+number); |
213 | 220 | struct dentry *dentry; |
214 | - struct inode *inode = new_inode(devpts_mnt->mnt_sb); | |
221 | + struct super_block *sb = pts_sb_from_inode(ptmx_inode); | |
222 | + struct inode *inode = new_inode(sb); | |
223 | + struct dentry *root = sb->s_root; | |
215 | 224 | char s[12]; |
216 | 225 | |
217 | 226 | /* We're supposed to be given the slave end of a pty */ |
218 | 227 | |
219 | 228 | |
220 | 229 | |
... | ... | @@ -231,15 +240,15 @@ |
231 | 240 | |
232 | 241 | sprintf(s, "%d", number); |
233 | 242 | |
234 | - mutex_lock(&devpts_root->d_inode->i_mutex); | |
243 | + mutex_lock(&root->d_inode->i_mutex); | |
235 | 244 | |
236 | - dentry = d_alloc_name(devpts_root, s); | |
245 | + dentry = d_alloc_name(root, s); | |
237 | 246 | if (!IS_ERR(dentry)) { |
238 | 247 | d_add(dentry, inode); |
239 | - fsnotify_create(devpts_root->d_inode, dentry); | |
248 | + fsnotify_create(root->d_inode, dentry); | |
240 | 249 | } |
241 | 250 | |
242 | - mutex_unlock(&devpts_root->d_inode->i_mutex); | |
251 | + mutex_unlock(&root->d_inode->i_mutex); | |
243 | 252 | |
244 | 253 | return 0; |
245 | 254 | } |
246 | 255 | |
... | ... | @@ -256,11 +265,13 @@ |
256 | 265 | void devpts_pty_kill(struct tty_struct *tty) |
257 | 266 | { |
258 | 267 | struct inode *inode = tty->driver_data; |
268 | + struct super_block *sb = pts_sb_from_inode(inode); | |
269 | + struct dentry *root = sb->s_root; | |
259 | 270 | struct dentry *dentry; |
260 | 271 | |
261 | 272 | BUG_ON(inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)); |
262 | 273 | |
263 | - mutex_lock(&devpts_root->d_inode->i_mutex); | |
274 | + mutex_lock(&root->d_inode->i_mutex); | |
264 | 275 | |
265 | 276 | dentry = d_find_alias(inode); |
266 | 277 | if (dentry && !IS_ERR(dentry)) { |
... | ... | @@ -269,7 +280,7 @@ |
269 | 280 | dput(dentry); |
270 | 281 | } |
271 | 282 | |
272 | - mutex_unlock(&devpts_root->d_inode->i_mutex); | |
283 | + mutex_unlock(&root->d_inode->i_mutex); | |
273 | 284 | } |
274 | 285 | |
275 | 286 | static int __init init_devpts_fs(void) |