Commit graph

17 commits

Author SHA1 Message Date
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Elyes Haouas a5aa07dd85 extattr: Remove useless return at the end of void function
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/656
2023-03-02 07:59:13 -07:00
Alan Somers 1137d1a7e5 setextattr: Increase stdin buffer size to 4096
Extended attribute values can potentially be quite large. One test for ZFS
is supposed to set a 200MB xattr. However, the buffer size for reading
values from stdin with setextattr -i is so small that the test times out
waiting for tiny chunks of data to be buffered and appended to an sbuf.

Increasing the buffer size should help alleviate some of the burden of
reallocating larger sbufs when writing large extended attributes.

Submitted by:	Ryan Moeller <ryan@freqlabs.com>
MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D23211
2020-01-16 21:31:56 +00:00
Pedro F. Giffuni 1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Alan Somers 79e29f957a Fix "getextattr -x" with non-ascii attribute values
extattr/rmextattr.c
	When printing hex output, treat all attribute values as unsigned
	char arrays instead of sign extending them to 32 bit values.

extattr/tests/extattr_test.sh
	Add a regression test

PR:		209039
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
2016-05-04 21:07:30 +00:00
Alan Somers c29930cfd6 Allow setextattr(8) to take attribute values from stdin
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 and/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.

Reviewed by:	wblock (manpage)
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6090
2016-05-04 20:20:55 +00:00
Matthew D Fleming e324bf91e8 Fix return type of extattr_set_* and fix rmextattr(8) utility.
extattr_set_{fd,file,link} is logically a write(2)-like operation and
should return ssize_t, just like extattr_get_*.  Also, the user-space
utility was using an int for the return value of extattr_get_* and
extattr_list_*, both of which return an ssize_t.

MFC after:	1 week
2013-04-02 05:30:41 +00:00
Pawel Jakub Dawidek 081b42f93c Don't print an empty line for files with no attributes when -q is given for
lsextattr(8).
2013-02-22 20:49:50 +00:00
Zachary Loafman 07c1991012 extattr: Fix a signed/unsigned issue
Submitted by:       Matthew Fleming <matthew.fleming@isilon.com>
Reviewed by:        zml, dfr
2010-05-12 21:25:05 +00:00
Nathan Whitehorn deccdf0e17 Fix a bug when printing attributes from multiple files: buflen could be
longer than the length of the current attribute if the buffer were reused
and previously longer, so bits of the previous, longer attribute would be
written. Fix this by using the actual attribute length.
2010-01-21 03:49:18 +00:00
Robert Watson b689e6a8a3 Invoke err() with a format string rather than directly with a passed
command line argument.

Submitted by:	Alfredo Ortega <alfredo at coresecurity dot com>
Thanks to:	Core Security Technologies
MFC after:	3 days
2008-07-15 16:07:34 +00:00
Robert Watson 52271f82d6 Update lsextattr(8) to use the new extattr_list_*() APIs, rather than
using the somewhat more hackish variant on extattr_get_*() to retrieve
the attribute list on an object.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2003-06-05 04:30:00 +00:00
Brian Feldman cb0187a0da Add an -n option to write the trailing nul byte to the extattr when
using setextattr(8) to write a string.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2002-10-10 17:16:00 +00:00
Brian Feldman 878382facb Correct argc verification (don't crash).
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2002-10-10 17:11:20 +00:00
Robert Watson 6c3fb1121a Add -h flags to each of the *extattr(8) commands, indicating that
the command should not follow the symlink if the target file is a
symlink.  Invoke the extattr_*_link(2) version of the system call
in that situation, instead of extattr_*_file(2).  This is
consistent with other attribute management tools in the system.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2002-10-10 16:47:21 +00:00
Robert Watson 7522ecb37f Use basename(3) to derive the name of the binary from argv[0].
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
Submitted by:	green
2002-10-10 16:37:12 +00:00
Poul-Henning Kamp a068c194df Add the new userland tool for manipulating extended attributes.
This will replace the existing getextattr(8) and setextattr(8) with
a single binary responding to the names getextattr, setextattr,
rmextattr and lsextattr.

This program is not yet connected to the build.

Sponsored by: DARPA and NAI Labs.
2002-08-30 08:53:03 +00:00