From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Hansen Subject: [RFC][PATCH 25/27] /proc/mounts: prep for flags from sb or mnt Date: Wed, 07 Jun 2006 17:10:38 -0700 Message-ID: <20060608001038.E75328B3@localhost.localdomain> References: <20060608001013.0D041507@localhost.localdomain> Cc: herbert@13thfloor.at, viro@ftp.linux.org.uk, hch@infradead.org, trond.myklebust@fys.uio.no, Dave Hansen Return-path: Received: from e4.ny.us.ibm.com ([32.97.182.144]:51878 "EHLO e4.ny.us.ibm.com") by vger.kernel.org with ESMTP id S932501AbWFHAKq (ORCPT ); Wed, 7 Jun 2006 20:10:46 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e4.ny.us.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k580AgCu018973 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Jun 2006 20:10:43 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.6/NCO/VER7.0) with ESMTP id k580AgSQ163098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Jun 2006 20:10:42 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k580Af82005401 for ; Wed, 7 Jun 2006 20:10:42 -0400 To: linux-fsdevel@vger.kernel.org In-Reply-To: <20060608001013.0D041507@localhost.localdomain> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Originally from: Herbert Poetzl Right now, show_vfsmnt() will produce output such as "ro" or "nodev" based on sb flags or mount flags. Each output string can only come from one of these sources. This patch prepares show_vfsmnt() so that a single string can come from either source. We need this for r/o bind mounts. The for loop's terminating condition was getting a little bit long, so I used ARRAY_SIZE() instead of checking for the NULL terminator. Signed-off-by: Dave Hansen --- lxc-dave/fs/namespace.c | 46 ++++++++++++++++++++++++---------------------- 1 files changed, 24 insertions(+), 22 deletions(-) diff -puN fs/namespace.c~D6-proc-show-ro-attr fs/namespace.c --- lxc/fs/namespace.c~D6-proc-show-ro-attr 2006-06-07 16:53:27.000000000 -0700 +++ lxc-dave/fs/namespace.c 2006-06-07 16:53:27.000000000 -0700 @@ -354,24 +354,22 @@ static int show_vfsmnt(struct seq_file * { struct vfsmount *mnt = v; int err = 0; + int i; 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_SYNCHRONOUS, 0, ",sync", NULL }, + { MS_DIRSYNC, 0, ",dirsync", NULL }, + { MS_MANDLOCK, 0, ",mand", NULL }, + { 0, MNT_NOSUID, ",nosuid", NULL }, + { 0, MNT_NODEV, ",nodev", NULL }, + { 0, MNT_NOEXEC, ",noexec", NULL }, + { 0, MNT_NOATIME, ",noatime", NULL }, + { 0, MNT_NODIRATIME, ",nodiratime", NULL } }; - struct proc_fs_info *fs_infop; mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none"); seq_putc(m, ' '); @@ -379,13 +377,17 @@ static int show_vfsmnt(struct seq_file * 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); + for (i = 0; i < ARRAY_SIZE(fs_info); i++) { + struct proc_fs_info *fs_infop = &fs_info[i]; + char *str = NULL; + if ((mnt->mnt_sb->s_flags & fs_infop->s_flag) || + (mnt->mnt_flags & fs_infop->mnt_flag)) + str = fs_infop->set_str; + else + str = fs_infop->unset_str; + + if (str) + seq_puts(m, str); } if (mnt->mnt_sb->s_op->show_options) err = mnt->mnt_sb->s_op->show_options(m, mnt); _