[sheepdog] [PATCH 4/6] use sd_getopt instead of getopt_long

Liu Yuan namei.unix at gmail.com
Tue Nov 6 08:39:31 CET 2012


On 11/06/2012 03:30 PM, MORITA Kazutaka wrote:
> The handler is something like {object,disk}_cache_set in sheep.c?
> 

Yes.

> I'm not sure whether I understand your suggestion correctly, but IIUC,
> it means that we create sd_opt_param (including a user-defined handler
> to parse a key-value string) for each prefix (not <prefix,key> pair).
> Is it correct?  Then, we cannot auto-generate a help message of
> key-value pairs, no?
> 

> Or you mean that the user should define sd_opt_param for each
> <prefix,key> pair, and define the handler outside of sd_opt_param for
> each prefix?

Ah, I wasn't noticing the structure is <prefix, key> pair.

maybe handler for each <prefix, key> is okay? like following:

static struct sd_opt_param write_cache_options[] = {
        {"object", "size", "<size>",
         "specify a cache size for object cache", A},
        {"object", "directio", "<on|off>",
         "avoid using gateway page cache", B},
        ....
};

Then sd-opt user is freed to use the same handler for handler A and B or
use dedicated handlers for A and B. In either case, users don't need to
write prefix parser.

Thanks,
Yuan



More information about the sheepdog mailing list