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
F105952923: D6090.diff
Mon, Dec 23, 1:20 AM
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
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 Passed
Unit
No Test Coverage
Build Status
Buildable 3439
Build 3478: arc lint + arc unit

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

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

As is, it appears that -i is mandatory.

110

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

usr.sbin/extattr/rmextattr.8
65

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

110

will do.

asomers edited edge metadata.

Apply wblock's advice

usr.sbin/extattr/rmextattr.8
65

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 ↗(On Diff #15903)

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

121–122 ↗(On Diff #15903)

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 ↗(On Diff #15903)

Why'd you remove the newline here?

301–302 ↗(On Diff #15903)

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 ↗(On Diff #15903)

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 ↗(On Diff #15903)

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 ↗(On Diff #15903)

Because I print it on line 302 instead.

301–302 ↗(On Diff #15903)

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 ↗(On Diff #15903)

Please clarify this in the manpage. Thanks :)!