Add an instance parameter devpts interfaces

Pass-in 'inode' or 'tty' parameter to devpts interfaces.  With multiple
devpts instances, these parameters will be used in subsequent patches
to identify the instance of devpts mounted. The parameters also help
simplify devpts implementation.

Changelog[v3]:
	- minor changes due to merge with ttydev updates
	- rename parameters to emphasize they are ptmx or pts inodes
	- pass-in tty_struct * to devpts_pty_kill() (this will help
	  cleanup the get_node() call in a subsequent patch)

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>
This commit is contained in:
Sukadev Bhattiprolu
2008-10-13 10:42:59 +01:00
committed by Linus Torvalds
parent 4a2b5fddd5
commit 15f1a6338d
5 changed files with 47 additions and 30 deletions

View File

@@ -177,7 +177,7 @@ static struct dentry *get_node(int num)
return lookup_one_len(s, root, sprintf(s, "%d", num));
}
int devpts_new_index(void)
int devpts_new_index(struct inode *ptmx_inode)
{
int index;
int ida_ret;
@@ -205,14 +205,14 @@ retry:
return index;
}
void devpts_kill_index(int idx)
void devpts_kill_index(struct inode *ptmx_inode, int idx)
{
mutex_lock(&allocated_ptys_lock);
ida_remove(&allocated_ptys, idx);
mutex_unlock(&allocated_ptys_lock);
}
int devpts_pty_new(struct tty_struct *tty)
int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty)
{
int number = tty->index; /* tty layer puts index from devpts_new_index() in here */
struct tty_driver *driver = tty->driver;
@@ -245,7 +245,7 @@ int devpts_pty_new(struct tty_struct *tty)
return 0;
}
struct tty_struct *devpts_get_tty(int number)
struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number)
{
struct dentry *dentry = get_node(number);
struct tty_struct *tty;
@@ -262,8 +262,9 @@ struct tty_struct *devpts_get_tty(int number)
return tty;
}
void devpts_pty_kill(int number)
void devpts_pty_kill(struct tty_struct *tty)
{
int number = tty->index;
struct dentry *dentry = get_node(number);
if (!IS_ERR(dentry)) {