[Toybox] [PATCH] mode parser

Rob Landley rob at landley.net
Mon Mar 19 06:34:06 PDT 2012


Sorry this took so long to get to.  A bit buried in an avalanche
recently. :)

On 03/08/2012 02:40 AM, Daniel Walter wrote:
> Add string to mode_t parser
> 
> added new function string_to_mode(char *m_string, mode_t base) which
> parses a given string and converts it to a mode_t.
> If either + or - are part of m_string the permissions are either
> added or removed from base.
> 
> Currently support for permision copy is missing (e.g. g=u),
> but all other flags should work.

Ouch.  That's a hard one, it needs the old permission as input, which
means we either have to defer the parsing until after we've had a chance
to read input (I.E. -m _must_ take a string that gets filtered through a
parser function later, optargs can't deal wiith it before main()) or
else mode parsing would have to store some kind of copy indication...
which isn't going to fit in 32 bits on a 32-bit system and would still
require a second pass to use the copy information anyway, so that's a
bad approach.

So yeah, I don't currently see how mode parsing can fit in optargs at a
design level.  Gotta be a function that gets called by the command,
which this is...

Rob
-- 
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation.  Pick one.

 1332164046.0


More information about the Toybox mailing list