[Devel] Re: [PATCH 07/10] Update ptmx permissions during remount

Serge E. Hallyn serue at us.ibm.com
Wed Sep 24 11:30:59 PDT 2008


Quoting sukadev at us.ibm.com (sukadev at us.ibm.com):
> 
> >From 8c20ae3e9d5e051791a99b9060326069432d7fff Mon Sep 17 00:00:00 2001
> From: Sukadev Bhattiprolu <sukadev at linux.vnet.ibm.com>
> Date: Tue, 9 Sep 2008 18:37:55 -0700
> Subject: [PATCH 07/10] Update ptmx permissions during remount
> 
> By default, /dev/pts/ptmx node starts out with 0000 permissions.  While
> user's can chmod /dev/pts/ptmx, it maybe easier for legacy systems to
> update /etc/fstab and change the permissions using ptmxmode option.
> 
> This patch caches the dentry for ptmx node and uses it to update permissions
> of ptmx node during remount (code will be enabled in a follow-on patch).
> 
> Signed-off-by: Sukadev Bhattiprolu <sukadev at us.ibm.com>

As an alternative, you could just lookup_one_len("ptmx", sb->s_root, 4)
to avoid caching.  Not sure whether that would be considered better
though, so

Acked-by: Serge Hallyn <serue at us.ibm.com>

-serge

> ---
>  fs/devpts/inode.c |   28 +++++++++++++++++++++++++++-
>  1 files changed, 27 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> index 17e14f5..6b56255 100644
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
> @@ -68,6 +68,7 @@ static match_table_t tokens = {
>  struct pts_fs_info {
>  	struct ida allocated_ptys;
>  	struct pts_mount_opts mount_opts;
> +	struct dentry *ptmx_dentry;
>  };
> 
>  static inline struct pts_fs_info *DEVPTS_SB(struct super_block *sb)
> @@ -184,14 +185,39 @@ static int mknod_ptmx(struct super_block *sb)
> 
>  	return 0;
>  }
> +
> +static void update_ptmx_mode(struct pts_fs_info *fsi)
> +{
> +	struct inode *inode;
> +	if (fsi->ptmx_dentry) {
> +		inode = fsi->ptmx_dentry->d_inode;
> +		inode->i_mode = S_IFCHR|fsi->mount_opts.ptmxmode;
> +	}
> +}
> +#else
> +static inline void update_ptmx_mode(struct pts_fs_info *fsi)
> +{
> +	return;
> +}
>  #endif
> 
>  static int devpts_remount(struct super_block *sb, int *flags, char *data)
>  {
> +	int err;
>  	struct pts_fs_info *fsi = DEVPTS_SB(sb);
>  	struct pts_mount_opts *opts = &fsi->mount_opts;
> 
> -	return parse_mount_options(data, opts);
> +	err = parse_mount_options(data, opts);
> +
> +	/*
> +	 * parse_mount_options() restores options to default values
> +	 * before parsing and may have changed ptmxmode. So, update the
> +	 * mode in the inode too. Bogus options don't fail the remount,
> +	 * so do this even on error return.
> +	 */
> +	update_ptmx_mode(fsi);
> +
> +	return err;
>  }
> 
>  static int devpts_show_options(struct seq_file *seq, struct vfsmount *vfs)
> -- 
> 1.5.2.5
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list