diff options
author | Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> | 2009-01-02 08:41:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-02 13:19:35 -0500 |
commit | 59e55e6cf86eb472e8373831c4234252916c53ef (patch) | |
tree | 6d904c0490ea787b2ac65d7f0a37819ec37e8b3b /fs/devpts | |
parent | 300a6204b4d45dc70359b24384ad04ae899179c3 (diff) |
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>
Diffstat (limited to 'fs/devpts')
-rw-r--r-- | fs/devpts/inode.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 5d61b7c06e13..f96e10a109fe 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -34,7 +34,6 @@ static DEFINE_IDA(allocated_ptys); | |||
34 | static DEFINE_MUTEX(allocated_ptys_lock); | 34 | static DEFINE_MUTEX(allocated_ptys_lock); |
35 | 35 | ||
36 | static struct vfsmount *devpts_mnt; | 36 | static struct vfsmount *devpts_mnt; |
37 | static struct dentry *devpts_root; | ||
38 | 37 | ||
39 | static struct { | 38 | static struct { |
40 | int setuid; | 39 | int setuid; |
@@ -56,6 +55,14 @@ static const match_table_t tokens = { | |||
56 | {Opt_err, NULL} | 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 | static int devpts_remount(struct super_block *sb, int *flags, char *data) | 66 | static int devpts_remount(struct super_block *sb, int *flags, char *data) |
60 | { | 67 | { |
61 | char *p; | 68 | char *p; |
@@ -142,7 +149,7 @@ devpts_fill_super(struct super_block *s, void *data, int silent) | |||
142 | inode->i_fop = &simple_dir_operations; | 149 | inode->i_fop = &simple_dir_operations; |
143 | inode->i_nlink = 2; | 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 | if (s->s_root) | 153 | if (s->s_root) |
147 | return 0; | 154 | return 0; |
148 | 155 | ||
@@ -211,7 +218,9 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
211 | struct tty_driver *driver = tty->driver; | 218 | struct tty_driver *driver = tty->driver; |
212 | dev_t device = MKDEV(driver->major, driver->minor_start+number); | 219 | dev_t device = MKDEV(driver->major, driver->minor_start+number); |
213 | struct dentry *dentry; | 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 | char s[12]; | 224 | char s[12]; |
216 | 225 | ||
217 | /* We're supposed to be given the slave end of a pty */ | 226 | /* We're supposed to be given the slave end of a pty */ |
@@ -231,15 +240,15 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
231 | 240 | ||
232 | sprintf(s, "%d", number); | 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 | if (!IS_ERR(dentry)) { | 246 | if (!IS_ERR(dentry)) { |
238 | d_add(dentry, inode); | 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 | return 0; | 253 | return 0; |
245 | } | 254 | } |
@@ -256,11 +265,13 @@ struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) | |||
256 | void devpts_pty_kill(struct tty_struct *tty) | 265 | void devpts_pty_kill(struct tty_struct *tty) |
257 | { | 266 | { |
258 | struct inode *inode = tty->driver_data; | 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 | struct dentry *dentry; | 270 | struct dentry *dentry; |
260 | 271 | ||
261 | BUG_ON(inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)); | 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 | dentry = d_find_alias(inode); | 276 | dentry = d_find_alias(inode); |
266 | if (dentry && !IS_ERR(dentry)) { | 277 | if (dentry && !IS_ERR(dentry)) { |
@@ -269,7 +280,7 @@ void devpts_pty_kill(struct tty_struct *tty) | |||
269 | dput(dentry); | 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 | static int __init init_devpts_fs(void) | 286 | static int __init init_devpts_fs(void) |