[Toybox] [CLEANUP] stat: Some cleanup

Rob Landley rob at landley.net
Sat Apr 20 22:09:30 PDT 2013


On 04/19/2013 05:28:27 PM, Felix Janda wrote:
> Hello,
> 
> attached are two patches cleaning up stat a bit. The first changes  
> from
> 4 to 2 space indentation, the second is more interesting.
> 
> First of all it extends stat to correctly handle format strings.
> (Previously it considered only the second char of the format string.)
> This made it possible to remove duplication between  
> print_stat_format()
> and stat_main(). The option processing now uses the toybox  
> infrastructure
> better and by sorting the options in an appropriate way stat_main()
> could be simplified greatly. get_access_str() is now no longer broken.
> Apart from this there are various other small changes.

Cool, and applied.

> The functionality of get_access_str() is also implemented in the ls  
> toy
> (likely much better). Should something like it be in the library?

Once code can be shared by a second command, putting it in lib makes  
sense.

> Actually since stat and ls are both frontends to the stat system call
> more is duplicated.

If you can come up with a clean way to share the code, go for it.

I note that I have a pending todo item in ls: ls -l /dev/null doesn't  
show the major/minor numbers. (Oops. Needs another output mode for  
device nodes. If I did one, it's not triggering right...)

> I also wonder whether toybox will ever have SELinux support... My  
> local
> man page does even not document the -Z option to stat.

I'm leaning against it. If you saw my toybox talk at ELC (it's on  
youtube) I talked about security approaches and containers vs selinux.

> Felix

Rob
 1366520970.0


More information about the Toybox mailing list