@@ -34,13 +34,13 @@ static DEFINE_MUTEX(allocated_ptys_lock);
3434
3535static struct vfsmount * devpts_mnt ;
3636
37- static struct {
37+ struct pts_mount_opts {
3838 int setuid ;
3939 int setgid ;
4040 uid_t uid ;
4141 gid_t gid ;
4242 umode_t mode ;
43- } config = {. mode = DEVPTS_DEFAULT_MODE } ;
43+ };
4444
4545enum {
4646 Opt_uid , Opt_gid , Opt_mode ,
@@ -56,6 +56,7 @@ static const match_table_t tokens = {
5656
5757struct pts_fs_info {
5858 struct ida allocated_ptys ;
59+ struct pts_mount_opts mount_opts ;
5960};
6061
6162static inline struct pts_fs_info * DEVPTS_SB (struct super_block * sb )
@@ -74,12 +75,14 @@ static inline struct super_block *pts_sb_from_inode(struct inode *inode)
7475static int devpts_remount (struct super_block * sb , int * flags , char * data )
7576{
7677 char * p ;
78+ struct pts_fs_info * fsi = DEVPTS_SB (sb );
79+ struct pts_mount_opts * opts = & fsi -> mount_opts ;
7780
78- config . setuid = 0 ;
79- config . setgid = 0 ;
80- config . uid = 0 ;
81- config . gid = 0 ;
82- config . mode = DEVPTS_DEFAULT_MODE ;
81+ opts -> setuid = 0 ;
82+ opts -> setgid = 0 ;
83+ opts -> uid = 0 ;
84+ opts -> gid = 0 ;
85+ opts -> mode = DEVPTS_DEFAULT_MODE ;
8386
8487 while ((p = strsep (& data , "," )) != NULL ) {
8588 substring_t args [MAX_OPT_ARGS ];
@@ -94,19 +97,19 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data)
9497 case Opt_uid :
9598 if (match_int (& args [0 ], & option ))
9699 return - EINVAL ;
97- config . uid = option ;
98- config . setuid = 1 ;
100+ opts -> uid = option ;
101+ opts -> setuid = 1 ;
99102 break ;
100103 case Opt_gid :
101104 if (match_int (& args [0 ], & option ))
102105 return - EINVAL ;
103- config . gid = option ;
104- config . setgid = 1 ;
106+ opts -> gid = option ;
107+ opts -> setgid = 1 ;
105108 break ;
106109 case Opt_mode :
107110 if (match_octal (& args [0 ], & option ))
108111 return - EINVAL ;
109- config . mode = option & S_IALLUGO ;
112+ opts -> mode = option & S_IALLUGO ;
110113 break ;
111114 default :
112115 printk (KERN_ERR "devpts: called with bogus options\n" );
@@ -119,11 +122,14 @@ static int devpts_remount(struct super_block *sb, int *flags, char *data)
119122
120123static int devpts_show_options (struct seq_file * seq , struct vfsmount * vfs )
121124{
122- if (config .setuid )
123- seq_printf (seq , ",uid=%u" , config .uid );
124- if (config .setgid )
125- seq_printf (seq , ",gid=%u" , config .gid );
126- seq_printf (seq , ",mode=%03o" , config .mode );
125+ struct pts_fs_info * fsi = DEVPTS_SB (vfs -> mnt_sb );
126+ struct pts_mount_opts * opts = & fsi -> mount_opts ;
127+
128+ if (opts -> setuid )
129+ seq_printf (seq , ",uid=%u" , opts -> uid );
130+ if (opts -> setgid )
131+ seq_printf (seq , ",gid=%u" , opts -> gid );
132+ seq_printf (seq , ",mode=%03o" , opts -> mode );
127133
128134 return 0 ;
129135}
@@ -143,6 +149,7 @@ static void *new_pts_fs_info(void)
143149 return NULL ;
144150
145151 ida_init (& fsi -> allocated_ptys );
152+ fsi -> mount_opts .mode = DEVPTS_DEFAULT_MODE ;
146153
147154 return fsi ;
148155}
@@ -262,6 +269,8 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty)
262269 struct super_block * sb = pts_sb_from_inode (ptmx_inode );
263270 struct inode * inode = new_inode (sb );
264271 struct dentry * root = sb -> s_root ;
272+ struct pts_fs_info * fsi = DEVPTS_SB (sb );
273+ struct pts_mount_opts * opts = & fsi -> mount_opts ;
265274 char s [12 ];
266275
267276 /* We're supposed to be given the slave end of a pty */
@@ -275,7 +284,7 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty)
275284 inode -> i_uid = config .setuid ? config .uid : current_fsuid ();
276285 inode -> i_gid = config .setgid ? config .gid : current_fsgid ();
277286 inode -> i_mtime = inode -> i_atime = inode -> i_ctime = CURRENT_TIME ;
278- init_special_inode (inode , S_IFCHR |config . mode , device );
287+ init_special_inode (inode , S_IFCHR |opts -> mode , device );
279288 inode -> i_private = tty ;
280289 tty -> driver_data = inode ;
281290
0 commit comments