mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-19 15:33:56 +00:00
Add the '-l' option which prints string attribute followed by a file name.
Reviewed by: rwatson, sheldonh
This commit is contained in:
parent
36fba7e903
commit
d220443d1c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=60372
@ -33,9 +33,9 @@
|
||||
.Nd retrieve a named extended attribute
|
||||
.Sh SYNOPSIS
|
||||
.Nm getextattr
|
||||
.Op Fl s
|
||||
.Op Fl ls
|
||||
.Ar attrname
|
||||
.Ar filename Op ...
|
||||
.Ar filename ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a user tool to retrieve a named extended attribute on a file or
|
||||
@ -45,11 +45,16 @@ The
|
||||
argument should be the name of the attribute, and
|
||||
.Ar filename
|
||||
a list of files and directories from which to retrieve attribute data.
|
||||
If the
|
||||
.Op Fl s
|
||||
flag is specified,
|
||||
.Nm
|
||||
will attempt to display the attribute data as a string, although the
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width indent
|
||||
.It Fl l
|
||||
Print attributes in the first column and file names in the second.
|
||||
Can be used only in conjunction with the
|
||||
.Fl s
|
||||
option.
|
||||
.It Fl s
|
||||
Attempt to display the attribute data as a string, although the
|
||||
results may not look pretty if the data is binary data.
|
||||
The
|
||||
.Xr strvisx 3
|
||||
@ -57,6 +62,8 @@ function is used to generate the string, so control sequences should
|
||||
be safely escaped.
|
||||
Otherwise, the attribute data will be represented as a series of two-digit
|
||||
hex numbers.
|
||||
.El
|
||||
.Sh IMPLEMENTATION NOTES
|
||||
In order for
|
||||
.Nm
|
||||
to succeed, the attribute service must be available on the file system,
|
||||
|
@ -60,9 +60,12 @@ main(int argc, char *argv[])
|
||||
int ch;
|
||||
|
||||
int flag_as_string = 0;
|
||||
int flag_reverse = 0;
|
||||
|
||||
while ((ch = getopt(argc, argv, "s")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "ls")) != -1) {
|
||||
switch (ch) {
|
||||
case 'l':
|
||||
flag_reverse = 1;
|
||||
case 's':
|
||||
flag_as_string = 1;
|
||||
break;
|
||||
@ -93,12 +96,18 @@ main(int argc, char *argv[])
|
||||
if (error == -1)
|
||||
perror(argv[arg_counter]);
|
||||
else {
|
||||
printf("%s:", argv[arg_counter]);
|
||||
if (flag_as_string) {
|
||||
strvisx(visbuf, buf, error, VIS_SAFE
|
||||
| VIS_WHITE);
|
||||
printf(" \"%s\"\n", visbuf);
|
||||
if (flag_reverse) {
|
||||
printf("%s ", visbuf);
|
||||
printf("%s\n", argv[arg_counter]);
|
||||
} else {
|
||||
printf("%s:", argv[arg_counter]);
|
||||
printf(" \"%s\"\n", visbuf);
|
||||
}
|
||||
} else {
|
||||
printf("%s:", argv[arg_counter]);
|
||||
for (i = 0; i < error; i++)
|
||||
if (i % 16 == 0)
|
||||
printf("\n %02x ", buf[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user