diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-10-18 16:26:28 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-10-22 19:50:12 -0400 |
commit | 162b97cfa21f816f39ede1944f2a4220e3cf8969 (patch) | |
tree | 6cd663b2b17c3013285148efd43a145d6dea9a5e /fs/devpts | |
parent | 8fcbaa2b7f5b70dba9ed1c7f91d0a270ce752e2c (diff) |
TTY: devpts, return created inode from devpts_pty_new
The goal is to stop setting and using tty->driver_data in devpts code.
It should be used solely by the driver's code, pty in this case.
For the cleanup of layering, we will need the inode created in
devpts_pty_new to be stored into slave's driver_data. So we convert
devpts_pty_new to return the inode or an ERR_PTR-encoded error in case
of failure.
The move of 'inode = new_inode(sb);' from declarators to the code is
only cosmetical, but it makes the code easier to read.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/devpts')
-rw-r--r-- | fs/devpts/inode.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 47965807884d..ec3bab716c05 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -545,7 +545,7 @@ void devpts_kill_index(struct inode *ptmx_inode, int idx) | |||
545 | mutex_unlock(&allocated_ptys_lock); | 545 | mutex_unlock(&allocated_ptys_lock); |
546 | } | 546 | } |
547 | 547 | ||
548 | int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | 548 | struct inode *devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) |
549 | { | 549 | { |
550 | /* tty layer puts index from devpts_new_index() in here */ | 550 | /* tty layer puts index from devpts_new_index() in here */ |
551 | int number = tty->index; | 551 | int number = tty->index; |
@@ -553,19 +553,19 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
553 | dev_t device = MKDEV(driver->major, driver->minor_start+number); | 553 | dev_t device = MKDEV(driver->major, driver->minor_start+number); |
554 | struct dentry *dentry; | 554 | struct dentry *dentry; |
555 | struct super_block *sb = pts_sb_from_inode(ptmx_inode); | 555 | struct super_block *sb = pts_sb_from_inode(ptmx_inode); |
556 | struct inode *inode = new_inode(sb); | 556 | struct inode *inode; |
557 | struct dentry *root = sb->s_root; | 557 | struct dentry *root = sb->s_root; |
558 | struct pts_fs_info *fsi = DEVPTS_SB(sb); | 558 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
559 | struct pts_mount_opts *opts = &fsi->mount_opts; | 559 | struct pts_mount_opts *opts = &fsi->mount_opts; |
560 | int ret = 0; | ||
561 | char s[12]; | 560 | char s[12]; |
562 | 561 | ||
563 | /* We're supposed to be given the slave end of a pty */ | 562 | /* We're supposed to be given the slave end of a pty */ |
564 | BUG_ON(driver->type != TTY_DRIVER_TYPE_PTY); | 563 | BUG_ON(driver->type != TTY_DRIVER_TYPE_PTY); |
565 | BUG_ON(driver->subtype != PTY_TYPE_SLAVE); | 564 | BUG_ON(driver->subtype != PTY_TYPE_SLAVE); |
566 | 565 | ||
566 | inode = new_inode(sb); | ||
567 | if (!inode) | 567 | if (!inode) |
568 | return -ENOMEM; | 568 | return ERR_PTR(-ENOMEM); |
569 | 569 | ||
570 | inode->i_ino = number + 3; | 570 | inode->i_ino = number + 3; |
571 | inode->i_uid = opts->setuid ? opts->uid : current_fsuid(); | 571 | inode->i_uid = opts->setuid ? opts->uid : current_fsuid(); |
@@ -585,12 +585,12 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty) | |||
585 | fsnotify_create(root->d_inode, dentry); | 585 | fsnotify_create(root->d_inode, dentry); |
586 | } else { | 586 | } else { |
587 | iput(inode); | 587 | iput(inode); |
588 | ret = -ENOMEM; | 588 | inode = ERR_PTR(-ENOMEM); |
589 | } | 589 | } |
590 | 590 | ||
591 | mutex_unlock(&root->d_inode->i_mutex); | 591 | mutex_unlock(&root->d_inode->i_mutex); |
592 | 592 | ||
593 | return ret; | 593 | return inode; |
594 | } | 594 | } |
595 | 595 | ||
596 | void *devpts_get_priv(struct inode *pts_inode) | 596 | void *devpts_get_priv(struct inode *pts_inode) |