[PATCH 07/10] Update ptmx permissions during remount

Sukadev Bhattiprolu sukadev at linux.vnet.ibm.com
Tue Sep 9 18:37:55 PDT 2008


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>
---
 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



More information about the Containers mailing list