On 12/30/25 17:45, Peter B. wrote:
I'll also checkout Morgan's find-patch:
I'd really love to see xattr-support in the basic "most likely to be
present-on-any-box" tools.
The technical coding under the hood for reading xattr from the file system
is there in Morgan's patch for quite a while, indeed.
But before adding, I feel we need to discuss once again the interface
to the find(1) user:
- Do we only want to provide an option to search for files having xattrs?
find -xattr
- Do we want a test option to search for a file having an xattr key matching
a certain string (or eventually pattern)?
find -xattr 'mykey' # xattr key equals string
find -xattr '*mykey*' # xattr key matches pattern
Or better explicitly mention in the option that we match for the xattr keys?
find -xattr-key 'mykey'
find -xattr-key '*mykey*'
- Do we want a test option to search for a file having an xattr value matching
a certain string (or eventually pattern)?
find -xattr-value 'myval' # files with xattr value equals string
find -xattr-value '*myval*' # ... or pattern
- Or search for files with xattr having a certain mixture of 'key=val'?
find -xattr-match 'mykey=myval' # search by key+val as strings
find -xattr-match 'mykey=*someval*' # search for key matching a val pattern
- Do we need support for -printf formats to print xattr keys and/or values?
How? The % 1-character directives are almost all used, maybe begin with
the reserved ones? (%{ %[ %(
How to output several xattr keys or values?
How to select which xattr value to print?
find -xattr -printf '%p %{xattr-keys=hello*} %{xattr-valuekey=hello}
There's a lot of possibilities, and I don't want to introduce something
which contradicts the typical use cases, or is not extensible or not
maintainable.
The complexity - especially when it comes to -printf - is that files can have
several xattr while all other attributes (name, timestamps, permissions, size,
etc.) only exists once.
I think I asked this kind of questions already some years ago, but there was
no input yet.
I personally don't have a use case to search for xattrs, so the usual pattern
with '-exec getfattr ...' works for me.
Anyone?
P.S. Finally, I wouldn't want to introduce too much and complex code for
0.25% use cases. Eventually, the simple test to search for files having
xattrs is enough, and the application logic then extracts them with another
tool.
Have a nice day,
Berny