[PATCH 02/16] devpts: Set the proper fops for /dev/pts/ptmx
From: Eric W. Biederman
Date: Fri Apr 15 2016 - 11:46:59 EST
Simplify things and accelerate the open a bit by setting ptmx_fops
directly on the /dev/pts/ptmx inode.
Signed-off-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
---
drivers/tty/pty.c | 2 +-
fs/devpts/inode.c | 6 +++---
include/linux/devpts_fs.h | 2 ++
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index e16a49b507ef..c71d5b6ddbb8 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -803,7 +803,7 @@ err_file:
return retval;
}
-static struct file_operations ptmx_fops;
+struct file_operations ptmx_fops;
static void __init unix98_pty_init(void)
{
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index e8bf61cd1bf8..4fc6c49b0efd 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -232,7 +232,6 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts)
#ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES
static int mknod_ptmx(struct super_block *sb)
{
- int mode;
int rc = -ENOMEM;
struct dentry *dentry;
struct inode *inode;
@@ -274,8 +273,9 @@ static int mknod_ptmx(struct super_block *sb)
inode->i_ino = 2;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
- mode = S_IFCHR|opts->ptmxmode;
- init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2));
+ inode->i_mode = S_IFCHR|opts->ptmxmode;
+ inode->i_fop = &ptmx_fops;
+ inode->i_rdev = MKDEV(TTYAUX_MAJOR, PTMX_MINOR);
inode->i_uid = root_uid;
inode->i_gid = root_gid;
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
index db329cd3d14e..ff2b7c274435 100644
--- a/include/linux/devpts_fs.h
+++ b/include/linux/devpts_fs.h
@@ -20,6 +20,8 @@
#ifdef CONFIG_UNIX98_PTYS
+extern struct file_operations ptmx_fops;
+
int devpts_new_index(struct inode *ptmx_inode);
void devpts_kill_index(struct inode *ptmx_inode, int idx);
void devpts_add_ref(struct inode *ptmx_inode);
--
2.8.1