diff options
| author | Boris Popov <bp@FreeBSD.org> | 2000-05-11 10:00:22 +0000 |
|---|---|---|
| committer | Boris Popov <bp@FreeBSD.org> | 2000-05-11 10:00:22 +0000 |
| commit | d220443d1ce11851b1823376e16086b41a30285c (patch) | |
| tree | 827919f04859207292a02e882cefd5ce7006560c | |
| parent | 36fba7e9031099441f05996cc7c38aa16e7224f5 (diff) | |
Notes
| -rw-r--r-- | usr.sbin/getextattr/getextattr.8 | 21 | ||||
| -rw-r--r-- | usr.sbin/getextattr/getextattr.c | 15 |
2 files changed, 26 insertions, 10 deletions
diff --git a/usr.sbin/getextattr/getextattr.8 b/usr.sbin/getextattr/getextattr.8 index f898ed1c1a32..069552795676 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 7a1067213d3d..07299d2ea35b 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]); |
