[Toybox] getfattr is insane

enh enh at google.com
Sat Aug 20 20:54:05 PDT 2016


On Sat, Aug 20, 2016 at 6:52 PM, Rob Landley <rob at landley.net> wrote:
> So setfattr doesn't accept key=value pairs, but instead -n key with
> optional -v value. Meaning you can only set one per invocation,
> because... [jazzhands]
>
> But getfattr is worse, it's like somebody read The Unix Philosophy by
> Mike Gancarz, got to the bit about output being scriptable by default,
> and said "no, I'm not going to do that":
>
>   $ touch filename
>   $ setfattr -n user.blah filename
>   $ getfattr -n user.blah filename
>   # filename
>   user.blah
>
>   $
>
> Yes, that's a gratuitous blank line after the output, and yes that's a
> comment line with the file that I gave it even though there's only one
> file. (You know how grep only prepends filename: by default when given
> more than one file? Yeah, this totally _doesn't_ do that.)
>
> I take it scripts depend on this broken non-unixy output format? How
> about if I add a -u mode with the help text:
>
>   -u    pretend this is a unix command
>
> Also, you can query more than one -n per invocation, which I should
> presumably implement.
>
> (Extended attributes make me irritable. They're just so thoroughly NOT
> throught through. The querying API puts a gap between "tell me how much
> memory to allocate" and the actual query for data, meaning the size can
> change between them so you have to LOOP with a realloc, and yet libc
> doesn't do this for you.

(arguably that's a very unix attitude. or at least BSD. SEE ALSO:
readlink(2). at least as we expose these in higher-level languages for
the younger generation we can paper over these cracks. [he says, while
filing a bug in another tab to fix getxattr in the same way we fixed
readlink in the android.system.Os API.])

> And of course the magic in-band-signaling
> prefixes so "setfattr -n walrus filename" is denied, because magic name.)
>
> Also, the f in setfattr stands for "filesystem". As opposed to...? You'd
> think it would be setxattr, but no. There isn't one. Would anyone have
> any interest if I MADE one that takes keyword=value pairs to set the
> data, prepends "user." by default if you didn't provide a prefix, lets
> you set more than one in a given call, and the get version behaves like
> a %*(#&%& unix program?
>
> No?

i hate everything about them too, right down to their stupid names.
the Mac alternative seemed more sensible from its man page
(https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/xattr.1.html)
but i've never used it, so i don't know what it's like in practice.

i did consider writing something more like that, but i assumed that
sooner or later someone would ask for setfattr/getfattr (which are the
only Linux tools i've ever come across for this), and didn't want to
start the "now we have (n+1) standards" race.

and i was wary of adding something supposed to be Mac-like, not having
a Mac and so not able to test what interoperability problems i'd be
introducing by misreading the man page/hitting gaps in the man page.
maybe something for the TODO list though.

[as for the "f" for "filesystem"... the wikipedia page doesn't even
understand the difference between POSIX extended attributes and ext2
file system attributes. confusion abounds.]

> Sigh. The hard part of cleaning this up is figuring out what "clean"
> looks like. I promoted the set command already, but this is just... ow.

(i think you're forgetting to push again.)

> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.



More information about the Toybox mailing list