summaryrefslogtreecommitdiffstats
path: root/usr.sbin/getextattr
diff options
context:
space:
mode:
authorbp <bp@FreeBSD.org>2000-05-11 10:00:22 +0000
committerbp <bp@FreeBSD.org>2000-05-11 10:00:22 +0000
commit67f6623fc7342a23cc66a332c5ae42b6f52ee3df (patch)
treeee5c6bfaa8b814fec963e03a906507d4aaef6b5f /usr.sbin/getextattr
parent283efb624e60f8afb95dfd1536bb130daa938e1e (diff)
downloadFreeBSD-src-67f6623fc7342a23cc66a332c5ae42b6f52ee3df.zip
FreeBSD-src-67f6623fc7342a23cc66a332c5ae42b6f52ee3df.tar.gz
Add the '-l' option which prints string attribute followed by a file name.
Reviewed by: rwatson, sheldonh
Diffstat (limited to 'usr.sbin/getextattr')
-rw-r--r--usr.sbin/getextattr/getextattr.821
-rw-r--r--usr.sbin/getextattr/getextattr.c15
2 files changed, 26 insertions, 10 deletions
diff --git a/usr.sbin/getextattr/getextattr.8 b/usr.sbin/getextattr/getextattr.8
index f898ed1..0695527 100644
--- a/usr.sbin/getextattr/getextattr.8
+++ b/usr.sbin/getextattr/getextattr.8
@@ -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,
diff --git a/usr.sbin/getextattr/getextattr.c b/usr.sbin/getextattr/getextattr.c
index 7a10672..07299d2 100644
--- a/usr.sbin/getextattr/getextattr.c
+++ b/usr.sbin/getextattr/getextattr.c
@@ -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]);
OpenPOWER on IntegriCloud