[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4E486268.60205@parallels.com>
Date: Sun, 14 Aug 2011 17:03:52 -0700
From: Glauber Costa <glommer@...allels.com>
To: Vasiliy Kulikov <segoon@...nwall.com>
CC: <linux-kernel@...r.kernel.org>,
Andrea Arcangeli <aarcange@...hat.com>,
Rik van Riel <riel@...hat.com>,
Nick Piggin <npiggin@...nel.dk>,
Eric Dumazet <eric.dumazet@...il.com>,
Pavel Emelyanov <xemul@...allels.com>,
David Chinner <david@...morbit.com>,
<containers@...ts.linux-foundation.org>,
Hugh Dickins <hughd@...gle.com>,
James Bottomley <JBottomley@...allels.com>,
Dave Hansen <dave@...ux.vnet.ibm.com>,
Al Viro <viro@...iv.linux.org.uk>,
<linux-fsdevel@...r.kernel.org>
Subject: Re: [PATCH v3 4/4] parse options in the vfs level
On 08/14/2011 08:39 AM, Vasiliy Kulikov wrote:
> Hi Glauber,
>
> On Sun, Aug 14, 2011 at 19:13 +0400, Glauber Costa wrote:
>> +/**
>> + * Generic option parsing for the VFS.
>> + *
>> + * Since most of the filesystems already do their own option parsing, and with
>> + * very few code shared between them, this function strips out any options that
>> + * we succeed in parsing ourselves. Passing them forward would just give the
>> + * underlying fs an option it does not expect, leading it to fail.
>> + *
>> + * We don't yet have a pointer to the super block as well, since this is
>> + * pre-mount. We accumulate in struct vfs_options whatever data we collected,
>> + * and act on it later.
>> + */
>> +static int vfs_parse_options(char *options, struct vfs_options *ops)
>> +{
>> + substring_t args[MAX_OPT_ARGS];
>> + int option;
>> + char *p;
>> + char *opt;
>> + char *start = NULL;
>> + int ret;
>> +
>> + if (!options)
>> + return 0;
>> +
>> + opt = kstrdup(options, GFP_KERNEL);
>> + if (!opt)
>> + return 1;
>> +
>> + ret = 1;
>> +
>> + start = opt;
>> + while ((p = strsep(&opt, ",")) != NULL) {
>> + int token;
>> + if (!*p)
>> + continue;
>> +
>> + /*
>> + * Initialize args struct so we know whether arg was
>> + * found; some options take optional arguments.
>> + */
>> + args[0].to = args[0].from = 0;
>> + token = match_token(p, tokens, args);
>> + switch (token) {
>> + case 1:
>> + if (!args[0].from)
>> + break;
>> +
>> + if (match_int(&args[0],&option))
>> + break;
>
> What if there are 2 passed options and the second fails?
>
> mount -o vfs_dcache_size=XXX,vfs_dcache_size=CRAP<dev> <mntpoint>
>
> In this case you leave the second option and pass it to the fs option
> parser (as you already set ret=0), which is wrong. I think you should
> explicitly return 1 where you know the option is related to VFS, but you
> failed to parse it. It would look even simplier than current code.
Good point, thank you. I agree.
> (Yes, this is a rare situation, but I can imagine some program that
> automatically adds mount options to the existing list and passes it to
> mount.)
>
Absolutely.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists