Page MenuHomeFreeBSD

Allow setextattr(8) to take attribute values from stdin
ClosedPublic

Authored by asomers on Apr 25 2016, 4:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 2, 12:50 PM
Unknown Object (File)
Mon, Dec 2, 12:50 PM
Unknown Object (File)
Mon, Dec 2, 12:50 PM
Unknown Object (File)
Mon, Dec 2, 12:50 PM
Unknown Object (File)
Mon, Dec 2, 12:50 PM
Unknown Object (File)
Mon, Dec 2, 12:50 PM
Unknown Object (File)
Mon, Dec 2, 12:34 PM
Unknown Object (File)
Fri, Nov 29, 12:10 AM
Subscribers

Details

Summary

Add the -i option to setextattr. This option allow extended attribute data
to be provided via stdin. Add a -qq option to getextattr, which omits the
trailing newline. Together these options can be used to work with extended
attributes whose values are large or binary.

usr.sbin/extattr/Makefile:
Link against libsbuf which is used for processing stdin data.

usr.sbin/extattr/rmextattr.8:
Document setextattr's -i option, getextattr's -qq option, and remove
the BUG about setextattr only being useful for strings.

usr.sbin/extattr/rmextattr.c:
For setextattr operations, buffer attribute data in an sbuf. If -i
is specified, pull the data from stdin, otherwise from the
appropriate argurment.

Update usage text and argument validation code for setextattr's -i
option.

usr.sbin/extattr/tests/extattr_test.sh
Add tests for -q and -i.

Test Plan

Added ATF test case.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

asomers retitled this revision from to Allow setextattr(8) to take attribute values from stdin.
asomers updated this object.
asomers edited the test plan for this revision. (Show Details)
asomers added reviewers: ngie, rwatson.
wblock added inline comments.
usr.sbin/extattr/rmextattr.8
65 ↗(On Diff #15582)

It appears this should just be added to the other flags:
.Op Fl fhinq

As is, it appears that -i is mandatory.

110 ↗(On Diff #15582)

Start new sentence on a new line.
Also, probably better said as "When given twice, ..."

usr.sbin/extattr/rmextattr.8
65 ↗(On Diff #15582)

-i is mandatory if and only if the attrvalue is omitted. That's why I added a separate usage line for it.

110 ↗(On Diff #15582)

will do.

asomers edited edge metadata.

Apply wblock's advice

usr.sbin/extattr/rmextattr.8
65 ↗(On Diff #15582)

Ah, I see. It still should be

.Fl i
asomers edited edge metadata.

s/.Cm/.Fl at wblock's request

s/.Cm/.Fl at wblock's request

Please also bump .Dd and run igor -R and mandoc -Tlint on it before commit.

Thanks!

asomers edited edge metadata.

Update man page datestamp at wblock's request

This revision was automatically updated to reflect the committed changes.
head/usr.sbin/extattr/rmextattr.8
111

A trailing newline where? The intent is a bit ambiguous.

121–122

These should really have explanations for the examples provided... Also, the new -i method will mask errors with md5 -q .

head/usr.sbin/extattr/rmextattr.c
294

Why'd you remove the newline here?

301–302

Why'd you choose to omit the newline if count_quiet < 2? This is the only spot in the new code that requires count_quiet be something other than a boolean.

head/usr.sbin/extattr/rmextattr.8
111

At the end of the command. Almost every command's output includes a trailing newline. For example, whoami prints "asomers\n", not just "asomers". But that is both unnecessary and confusing for commands that send binary info for stdout, as getextattr will if the attribute's value is binary.

121–122

This is just an example. A real application will of course need to pay attention to md5's exit status.

head/usr.sbin/extattr/rmextattr.c
294

Because I print it on line 302 instead.

301–302

Because the new usage allows you to specify "-q" more than once, just like how ssh accepts "-v" up to three times or zdb accepts "-d" up to 6 times. So "-q" is no longer a boolean flag.

head/usr.sbin/extattr/rmextattr.8
111

Please clarify this in the manpage. Thanks :)!