Commit 89a52e109e2e2fe8bbd4e316cdb910774519c029

Authored by Sukadev Bhattiprolu
Committed by Linus Torvalds
1 parent 527b3e4773

Simplify devpts_pty_new()

devpts_pty_new() is called when setting up a new pty and would not
will not have an existing dentry or inode for the pty. So don't bother
looking for an existing dentry - just create a new one.

Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 8 additions and 3 deletions Side-by-side Diff

... ... @@ -220,6 +220,7 @@
220 220 dev_t device = MKDEV(driver->major, driver->minor_start+number);
221 221 struct dentry *dentry;
222 222 struct inode *inode = new_inode(devpts_mnt->mnt_sb);
  223 + char s[12];
223 224  
224 225 /* We're supposed to be given the slave end of a pty */
225 226 BUG_ON(driver->type != TTY_DRIVER_TYPE_PTY);
... ... @@ -235,9 +236,13 @@
235 236 init_special_inode(inode, S_IFCHR|config.mode, device);
236 237 inode->i_private = tty;
237 238  
238   - dentry = get_node(number);
239   - if (!IS_ERR(dentry) && !dentry->d_inode) {
240   - d_instantiate(dentry, inode);
  239 + sprintf(s, "%d", number);
  240 +
  241 + mutex_lock(&devpts_root->d_inode->i_mutex);
  242 +
  243 + dentry = d_alloc_name(devpts_root, s);
  244 + if (!IS_ERR(dentry)) {
  245 + d_add(dentry, inode);
241 246 fsnotify_create(devpts_root->d_inode, dentry);
242 247 }
243 248