linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Poetzl <herbert@13thfloor.at>
To: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
	Christoph Hellwig <hch@infradead.org>,
	Al Viro <viro@ftp.linux.org.uk>,
	Linux Kernel ML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/6] vfs: add missing MNT_RDONLY and macro to check
Date: Sat, 21 Jan 2006 09:40:17 +0100	[thread overview]
Message-ID: <20060121084016.GB10044@MAIL.13thfloor.at> (raw)
In-Reply-To: <20060121083843.GA10044@MAIL.13thfloor.at>


;
; Bind Mount Extensions
;
; Copyright (C) 2003-2006 Herbert Pötzl <herbert@13thfloor.at>
;
; the missing MNT_RDONLY mount flag is added together with
; a macro MNT_IS_RDONLY(m) to check it on a vfsmount
;
; the separate flag to string structures in show_vfsmnt are
; combined and adjusted to honor the new flag, which is set
; at do_mount time
;
;
; Changelog:
;
;   0.01  - broken out part from bme0.05
;   0.02  - moved the loopback mounts into separate patch
;

Signed-off-by: Herbert Pötzl <herbert@13thfloor.at>

diff -NurpP --minimal linux-2.6.16-rc1/fs/namespace.c linux-2.6.16-rc1-bme0.06.2-bm0.02/fs/namespace.c
--- linux-2.6.16-rc1/fs/namespace.c	2006-01-18 06:08:30 +0100
+++ linux-2.6.16-rc1-bme0.06.2-bm0.02/fs/namespace.c	2006-01-21 09:08:20 +0100
@@ -354,37 +354,40 @@ static int show_vfsmnt(struct seq_file *
 	struct vfsmount *mnt = v;
 	int err = 0;
 	static struct proc_fs_info {
-		int flag;
-		char *str;
+		int s_flag;
+		int mnt_flag;
+		char *set_str;
+		char *unset_str;
 	} fs_info[] = {
-		{ MS_SYNCHRONOUS, ",sync" },
-		{ MS_DIRSYNC, ",dirsync" },
-		{ MS_MANDLOCK, ",mand" },
-		{ 0, NULL }
-	};
-	static struct proc_fs_info mnt_info[] = {
-		{ MNT_NOSUID, ",nosuid" },
-		{ MNT_NODEV, ",nodev" },
-		{ MNT_NOEXEC, ",noexec" },
-		{ MNT_NOATIME, ",noatime" },
-		{ MNT_NODIRATIME, ",nodiratime" },
-		{ 0, NULL }
+		{ MS_RDONLY, MNT_RDONLY, "ro", "rw" },
+		{ MS_SYNCHRONOUS, 0, ",sync", NULL },
+		{ MS_DIRSYNC, 0, ",dirsync", NULL },
+		{ MS_MANDLOCK, 0, ",mand", NULL },
+		{ MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
+		{ MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
+		{ 0, MNT_NOSUID, ",nosuid", NULL },
+		{ 0, MNT_NODEV, ",nodev", NULL },
+		{ 0, MNT_NOEXEC, ",noexec", NULL },
+		{ 0, 0, NULL, NULL }
 	};
-	struct proc_fs_info *fs_infop;
+	struct proc_fs_info *p;
+	unsigned long s_flags = mnt->mnt_sb->s_flags;
+	int mnt_flags = mnt->mnt_flags;
 
 	mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
 	seq_putc(m, ' ');
 	seq_path(m, mnt, mnt->mnt_root, " \t\n\\");
 	seq_putc(m, ' ');
 	mangle(m, mnt->mnt_sb->s_type->name);
-	seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
-	for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
-		if (mnt->mnt_sb->s_flags & fs_infop->flag)
-			seq_puts(m, fs_infop->str);
-	}
-	for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
-		if (mnt->mnt_flags & fs_infop->flag)
-			seq_puts(m, fs_infop->str);
+	seq_putc(m, ' ');
+	for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
+		if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
+			if (p->set_str)
+				seq_puts(m, p->set_str);
+		} else {
+			if (p->unset_str)
+				seq_puts(m, p->unset_str);
+		}
 	}
 	if (mnt->mnt_sb->s_op->show_options)
 		err = mnt->mnt_sb->s_op->show_options(m, mnt);
@@ -1285,6 +1288,8 @@ long do_mount(char *dev_name, char *dir_
 		((char *)data_page)[PAGE_SIZE - 1] = 0;
 
 	/* Separate the per-mountpoint flags */
+	if (flags & MS_RDONLY)
+		mnt_flags |= MNT_RDONLY;
 	if (flags & MS_NOSUID)
 		mnt_flags |= MNT_NOSUID;
 	if (flags & MS_NODEV)
diff -NurpP --minimal linux-2.6.16-rc1/include/linux/fs.h linux-2.6.16-rc1-bme0.06.2-bm0.02/include/linux/fs.h
--- linux-2.6.16-rc1/include/linux/fs.h	2006-01-18 06:08:43 +0100
+++ linux-2.6.16-rc1-bme0.06.2-bm0.02/include/linux/fs.h	2006-01-21 09:08:20 +0100
@@ -150,7 +150,7 @@ extern int dir_notify_enable;
  */
 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
 
-#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
+#define IS_RDONLY(inode)	__IS_FLG(inode, MS_RDONLY)
 #define IS_SYNC(inode)		(__IS_FLG(inode, MS_SYNCHRONOUS) || \
 					((inode)->i_flags & S_SYNC))
 #define IS_DIRSYNC(inode)	(__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
diff -NurpP --minimal linux-2.6.16-rc1/include/linux/mount.h linux-2.6.16-rc1-bme0.06.2-bm0.02/include/linux/mount.h
--- linux-2.6.16-rc1/include/linux/mount.h	2006-01-18 06:08:43 +0100
+++ linux-2.6.16-rc1-bme0.06.2-bm0.02/include/linux/mount.h	2006-01-21 09:08:20 +0100
@@ -22,6 +22,9 @@
 #define MNT_NOEXEC	0x04
 #define MNT_NOATIME	0x08
 #define MNT_NODIRATIME	0x10
+#define MNT_RDONLY	0x20
+
+#define MNT_IS_RDONLY(m)	((m) && ((m)->mnt_flags & MNT_RDONLY))
 
 #define MNT_SHARED	0x1000	/* if the vfsmount is a shared mount */
 #define MNT_UNBINDABLE	0x2000	/* if the vfsmount is a unbindable mount */


  reply	other threads:[~2006-01-21  8:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-21  8:38 [PATCH 0/6] vfs: extend loopback (bind) mounts by mnt_flags Herbert Poetzl
2006-01-21  8:40 ` Herbert Poetzl [this message]
2006-01-21  8:40 ` [PATCH 2/6] vfs: propagate mnt_flags into do_loopback/vfsmount Herbert Poetzl
2006-01-22 10:06   ` Suleiman Souhlal
2006-01-22 10:59     ` Suleiman Souhlal
2006-01-24 19:02   ` Christoph Hellwig
2006-01-26 21:04     ` Herbert Poetzl
2006-01-27 20:03     ` Herbert Poetzl
2006-04-01 17:02       ` Christoph Hellwig
2006-01-21  8:41 ` [PATCH 3/6] vfs: propagate vfsmount into chown_common() Herbert Poetzl
2006-01-21  8:42 ` [PATCH 4/6] vfs: propagate the nameidata into the relevant vfs_*() Herbert Poetzl
2006-01-21  8:43 ` [PATCH 5/6] vfs: propagate the vfsmount into *xattr() Herbert Poetzl
2006-01-21  8:43 ` [PATCH 6/6] vfs: extend IS_RDONLY() checks to MNT_IS_RDONLY() Herbert Poetzl
2006-01-24 19:06 ` [PATCH 0/6] vfs: extend loopback (bind) mounts by mnt_flags Christoph Hellwig
2006-01-26 21:08   ` Herbert Poetzl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060121084016.GB10044@MAIL.13thfloor.at \
    --to=herbert@13thfloor.at \
    --cc=akpm@osdl.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).