Re: [RFC][PATCH] parser for mount options

Albert D. Cahalan (acahalan@cs.uml.edu)
Thu, 9 Aug 2001 02:20:39 -0400 (EDT)


Alexander Viro writes:

> What I wanted to get:
> * set of options accepted by fs and syntax of their arguments
> should be visible in source. Explicitly.
> * no cascades of strcmp/strncmp/peeking at individual characters
> by hands.

Yay! You still have the switch() though, and ugly enums.
Since the kernel is tied to gcc anyway, one might as well...

int foofs_parser(/* ... */){
static match_table_t tokens = {
{&&Opt_uid, "uid=%u"},
{&&Opt_gid, "gid=%u"},
{&&Opt_ownmask, "ownmask=%o"},
{&&Opt_othmask, "othmask=%o"},
{&&Opt_err, NULL}
};
/* ... */
while(( p=whatever() ){
goto *(match_token(p, tokens, args)); /* gcc's computed goto */

Opt_uid:
/* code for uid */
continue;
Opt_gid:
/* code for gid */
continue;
Opt_ownmask:
/* code for ownmask */
continue;
Opt_othmask:
/* code for othmask */
continue;
Opt_err:
/* error code */
}
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/