diff options
Diffstat (limited to 'fs/devpts')
-rw-r--r-- | fs/devpts/inode.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 50e885f84bb0..a70d5d0890c7 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -170,14 +170,6 @@ static struct file_system_type devpts_fs_type = { | |||
170 | * to the System V naming convention | 170 | * to the System V naming convention |
171 | */ | 171 | */ |
172 | 172 | ||
173 | static struct dentry *get_node(int num) | ||
174 | { | ||
175 | char s[12]; | ||
176 | struct dentry *root = devpts_root; | ||
177 | mutex_lock(&root->d_inode->i_mutex); | ||
178 | return lookup_one_len(s, root, sprintf(s, "%d", num)); | ||
179 | } | ||
180 | |||
181 | int devpts_new_index(struct inode *ptmx_inode) | 173 | int devpts_new_index(struct inode *ptmx_inode) |
182 | { | 174 | { |
183 | int index; | 175 | int index; |
@@ -235,6 +227,7 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
235 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 227 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
236 | init_special_inode(inode, S_IFCHR|config.mode, device); | 228 | init_special_inode(inode, S_IFCHR|config.mode, device); |
237 | inode->i_private = tty; | 229 | inode->i_private = tty; |
230 | tty->driver_data = inode; | ||
238 | 231 | ||
239 | sprintf(s, "%d", number); | 232 | sprintf(s, "%d", number); |
240 | 233 | ||
@@ -262,18 +255,20 @@ struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number) | |||
262 | 255 | ||
263 | void devpts_pty_kill(struct tty_struct *tty) | 256 | void devpts_pty_kill(struct tty_struct *tty) |
264 | { | 257 | { |
265 | int number = tty->index; | 258 | struct inode *inode = tty->driver_data; |
266 | struct dentry *dentry = get_node(number); | 259 | struct dentry *dentry; |
267 | 260 | ||
268 | if (!IS_ERR(dentry)) { | 261 | BUG_ON(inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR)); |
269 | struct inode *inode = dentry->d_inode; | 262 | |
270 | if (inode) { | 263 | mutex_lock(&devpts_root->d_inode->i_mutex); |
271 | inode->i_nlink--; | 264 | |
272 | d_delete(dentry); | 265 | dentry = d_find_alias(inode); |
273 | dput(dentry); | 266 | if (dentry && !IS_ERR(dentry)) { |
274 | } | 267 | inode->i_nlink--; |
268 | d_delete(dentry); | ||
275 | dput(dentry); | 269 | dput(dentry); |
276 | } | 270 | } |
271 | |||
277 | mutex_unlock(&devpts_root->d_inode->i_mutex); | 272 | mutex_unlock(&devpts_root->d_inode->i_mutex); |
278 | } | 273 | } |
279 | 274 | ||