[Toybox] Reviewing the mode parser code.

Rob Landley rob at landley.net
Sun May 13 13:42:37 PDT 2012


Sorry it took so long, finally swung around to giving this code some
proper review. (I have an infrastructure backlog so I'm focusing on
making sure that's right before trying to build more on top of it.)

You don't have to compare tmp < 0 because the & ~07777 will cover that,
and you started with isdigit() at the beginning so where would they get
a minus from anyway?

The SUSv4 spec for the chmod command actually specifies numbers for
S_ISUID and similar:

  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/chmod.html

Now they don't QUITE say "this number is this bit", they say there must
be a correspondence, but that's because Microsoft and IBM gave them lots
of money to call Windows NT and OS/360 POSIX compliant.  In _reality_,
these are the numbers Linux uses for those bits. And we can take
advantage of that to simplify the code a lot.

The gnu/dammit version of mknod errors out on "w-o", which this code
seems just fine with. The above chmod spec uses that horrible "I'm a
math major!" syntax to _try_ to specify something coherent, but fails.

Reality seems to be "zero or more who (defaulting to "a" if you don't
specify), one op, one or more perm, and then you can have a comma and
repeat that if you like"...

I'm fiddling with it.

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.

 1336941757.0


More information about the Toybox mailing list