Re: [PATCH] ramfs: ignore tmpfs options when we emulate it

From: Wu Fengguang
Date: Sun Jun 14 2009 - 07:14:59 EST


On Sun, Jun 14, 2009 at 06:46:24PM +0800, Mike Frysinger wrote:
> On Sun, Jun 14, 2009 at 06:42, Wu Fengguang wrote:
> > On Sun, Jun 14, 2009 at 06:01:10PM +0800, Wu Fengguang wrote:
> > Sorry I take back the previous patch. It makes sense to not break
> > existing user space tools, but a warning message looks OK to remind
> > people of possibly unexpected behavior.
> >
> > default:
> > printk(KERN_ERR "ramfs: bad mount option: %s\n", p);
> > - return -EINVAL;
> > + break;
>
> hmm, if the warning was wrapped in #ifdef CONFIG_SHMEM, i'd be ok with
> this. otherwise we end up with warnings that can (should) be ignored
> when tmpfs is being emulated with ramfs.

We may change the "ramfs:" accordingly. But *silently* ignoring
options is bad anyway?

Does this message look better?

+ printk(KERN_WARNING "%s: ignoring mount option: %s\n",
+ sb->s_id, p);

Thanks,
Fengguang

---
[PATCH] ramfs: ignore unknown mount options

From: Mike Frysinger <vapier@xxxxxxxxxx>

On systems where CONFIG_SHMEM is disabled, mounting tmpfs filesystems can
fail when tmpfs options are used. This is because tmpfs creates a small
wrapper around ramfs which rejects unknown options, and ramfs itself only
supports a tiny subset of what tmpfs supports. This makes it pretty hard
to use the same userspace systems across different configuration systems.
As such, ramfs should ignore the tmpfs options when tmpfs is merely a
wrapper around ramfs.

This used to work before commit c3b1b1cbf0 as previously, ramfs would
ignore all options. But now, we get:
ramfs: bad mount option: size=10M
mount: mounting mdev on /dev failed: Invalid argument

Another option might be to restore the previous behavior, where ramfs
simply ignored all unknown mount options ... which is what Hugh prefers.

Acked-by: Matt Mackall <mpm@xxxxxxxxxxx>
Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx>
Signed-off-by: Hugh Dickins <hugh.dickins@xxxxxxxxxxxxx>
Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx>
Cc: stable@xxxxxxxxxx
---

fs/ramfs/inode.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

--- linux.orig/fs/ramfs/inode.c
+++ linux/fs/ramfs/inode.c
@@ -182,8 +182,9 @@ struct ramfs_fs_info {
struct ramfs_mount_opts mount_opts;
};

-static int ramfs_parse_options(char *data, struct ramfs_mount_opts *opts)
+static int ramfs_parse_options(struct super_block *sb, char *data)
{
+ struct ramfs_mount_opts *opts = sb->s_fs_info;
substring_t args[MAX_OPT_ARGS];
int option;
int token;
@@ -202,9 +203,15 @@ static int ramfs_parse_options(char *dat
return -EINVAL;
opts->mode = option & S_IALLUGO;
break;
+ /*
+ * Traditionally ramfs has ignored all mount options,
+ * and as it is used as a !CONFIG_SHMEM simple substitute
+ * for tmpfs, ignore other mount options with a warning.
+ */
default:
- printk(KERN_ERR "ramfs: bad mount option: %s\n", p);
- return -EINVAL;
+ printk(KERN_WARNING "%s: ignoring mount option: %s\n",
+ sb->s_id, p);
+ break;
}
}

@@ -227,7 +234,7 @@ static int ramfs_fill_super(struct super
goto fail;
}

- err = ramfs_parse_options(data, &fsi->mount_opts);
+ err = ramfs_parse_options(sb, data);
if (err)
goto fail;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/