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

From: Albert D. Cahalan (acahalan@cs.uml.edu)
Date: Thu Aug 09 2001 - 01:20:39 EST


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/



This archive was generated by hypermail 2b29 : Wed Aug 15 2001 - 21:00:23 EST