Originally from: Herbert Poetzl <herbert@xxxxxxxxxxxx> 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 <haveblue@xxxxxxxxxx> --- 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); _ - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html