[Toybox] [PATCH] chattr: improve error messages.

enh enh at google.com
Wed Feb 5 21:10:59 PST 2020


When chattr fails in production, it helps to see what it was trying to
do. Reuse the lsattr format but without the '-'s.

Only read the flags if we have any intention of changing them:
`chattr -p 123` has no reason to read the flags.

Only write the flags back if they actually change: `chattr +a`
shouldn't do anything if that flag is already set, for example.

Switch -p and -v to perror_msg() instead of perror_exit() in case
they're used with -R.

(I suspect that the uses of DIRTREE_ABORT are mistakes given -R, but
I'll leave them until I actually hit this.)
---
 toys/other/lsattr.c | 70 ++++++++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 30 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200205/65793cac/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-chattr-improve-error-messages.patch
Type: text/x-patch
Size: 4602 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200205/65793cac/attachment-0002.bin>


More information about the Toybox mailing list