diff options
-rw-r--r-- | usr.sbin/getextattr/Makefile | 1 | ||||
-rw-r--r-- | usr.sbin/getextattr/getextattr.8 | 9 | ||||
-rw-r--r-- | usr.sbin/getextattr/getextattr.c | 23 | ||||
-rw-r--r-- | usr.sbin/setextattr/Makefile | 1 | ||||
-rw-r--r-- | usr.sbin/setextattr/setextattr.8 | 11 | ||||
-rw-r--r-- | usr.sbin/setextattr/setextattr.c | 27 |
6 files changed, 50 insertions, 22 deletions
diff --git a/usr.sbin/getextattr/Makefile b/usr.sbin/getextattr/Makefile index a9747fc..45560a9 100644 --- a/usr.sbin/getextattr/Makefile +++ b/usr.sbin/getextattr/Makefile @@ -1,6 +1,7 @@ # $FreeBSD$ PROG= getextattr SRCS= getextattr.c +LDADD= ${LIBUTIL} CFLAGS+= -Wall MAN8= getextattr.8 diff --git a/usr.sbin/getextattr/getextattr.8 b/usr.sbin/getextattr/getextattr.8 index 75881d9..306c23c 100644 --- a/usr.sbin/getextattr/getextattr.8 +++ b/usr.sbin/getextattr/getextattr.8 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2000 Robert N. M. Watson +.\" Copyright (c) 2000, 2001 Robert N. M. Watson .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -34,6 +34,7 @@ .Sh SYNOPSIS .Nm .Op Fl ls +.Ar namespace .Ar attrname .Ar filename ... .Sh DESCRIPTION @@ -41,6 +42,10 @@ is a user tool to retrieve a named extended attribute on a file or directory. The +.Ar namespace +argument should be the namespace of the attribute to retrieve: legal +values are "user" and "system". +The .Ar attrname argument should be the name of the attribute, and .Ar filename @@ -70,7 +75,7 @@ to succeed, the attribute service must be available on the file system, and the attribute must of defined for the file queried. .Sh EXAMPLES .Bd -literal -offset indent -# getextattr md5 /kernel +# getextattr system md5 /kernel /kernel: 61 61 33 62 39 39 66 65 31 35 35 32 31 62 65 32 62 36 38 36 62 31 66 39 63 64 33 39 35 36 36 31 diff --git a/usr.sbin/getextattr/getextattr.c b/usr.sbin/getextattr/getextattr.c index 07299d2..db55b31 100644 --- a/usr.sbin/getextattr/getextattr.c +++ b/usr.sbin/getextattr/getextattr.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999, 2000 Robert N. M. Watson + * Copyright (c) 1999, 2000, 2001 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD$ */ /* * TrustedBSD Project - extended attribute support @@ -32,6 +32,7 @@ #include <sys/uio.h> #include <sys/extattr.h> +#include <libutil.h> #include <stdio.h> #include <unistd.h> #include <vis.h> @@ -40,7 +41,8 @@ void usage(void) { - fprintf(stderr, "getextattr [-s] [attrname] [filename ...]\n"); + fprintf(stderr, "getextattr [-s] [namespace] [attrname] " + "[filename ...]\n"); exit(-1); } @@ -56,7 +58,7 @@ main(int argc, char *argv[]) char *attrname; char buf[BUFSIZE]; char visbuf[BUFSIZE*4]; - int error, i, arg_counter; + int error, i, arg_counter, namespace; int ch; int flag_as_string = 0; @@ -78,10 +80,15 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (argc <= 1) + if (argc < 3) usage(); - attrname = argv[0]; + error = extattr_string_to_namespace(argv[0], &namespace); + if (error) { + perror(argv[0]); + return (-1); + } + attrname = argv[1]; argc--; argv++; @@ -89,8 +96,8 @@ main(int argc, char *argv[]) iov_buf.iov_base = buf; iov_buf.iov_len = BUFSIZE; - for (arg_counter = 0; arg_counter < argc; arg_counter++) { - error = extattr_get_file(argv[arg_counter], attrname, + for (arg_counter = 1; arg_counter < argc; arg_counter++) { + error = extattr_get_file(argv[arg_counter], namespace, attrname, &iov_buf, 1); if (error == -1) diff --git a/usr.sbin/setextattr/Makefile b/usr.sbin/setextattr/Makefile index f62931b..8ba76ed 100644 --- a/usr.sbin/setextattr/Makefile +++ b/usr.sbin/setextattr/Makefile @@ -1,6 +1,7 @@ # $FreeBSD$ PROG= setextattr SRCS= setextattr.c +LDADD= ${LIBUTIL} CFLAGS+= -Wall MAN8+= setextattr.8 diff --git a/usr.sbin/setextattr/setextattr.8 b/usr.sbin/setextattr/setextattr.8 index 987d881..5d08982 100644 --- a/usr.sbin/setextattr/setextattr.8 +++ b/usr.sbin/setextattr/setextattr.8 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2000 Robert N. M. Watson +.\" Copyright (c) 2000, 2001 Robert N. M. Watson .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ +.\" $FreeBSD$ .\" .Dd March 30, 2000 .Dt SETEXTATTR 8 @@ -33,6 +33,7 @@ .Nd set a named extended attribute .Sh SYNOPSIS .Nm +.Ar namespace .Ar attrname .Ar filename .Ar attrvalue @@ -41,6 +42,10 @@ is a user tool to set a named extended attribute on a file or directory to the provided string. The +.Ar namespace +argument should be the namespace of the attribute to retrieve: legal +values are "user" and "system". +The .Ar attrname argument should be the name of the attribute, .Ar filename @@ -54,7 +59,7 @@ In order for to succeed, the attribute service must be available on the file system, and appropriate privilege may be required. .Sh EXAMPLES -.Dl # setextattr md5 /kernel `md5 -q /kernel` +.Dl # setextattr system md5 /kernel `md5 -q /kernel` .Pp Set the .Dq md5 diff --git a/usr.sbin/setextattr/setextattr.c b/usr.sbin/setextattr/setextattr.c index 219830f..92e31f2 100644 --- a/usr.sbin/setextattr/setextattr.c +++ b/usr.sbin/setextattr/setextattr.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999, 2000 Robert N. M. Watson + * Copyright (c) 1999, 2000, 2001 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD$ */ /* * TrustedBSD Project - extended attribute support for UFS-like file systems @@ -32,13 +32,16 @@ #include <sys/types.h> #include <sys/uio.h> #include <sys/extattr.h> + +#include <libutil.h> #include <stdio.h> void usage(void) { - fprintf(stderr, "setextattr [attrname] [filename] [attrvalue]\n"); + fprintf(stderr, "setextattr [namespace] [attrname] [filename] " + "[attrvalue]\n"); exit(-1); } @@ -46,17 +49,23 @@ int main(int argc, char *argv[]) { struct iovec iov_buf; - int error; + int error, namespace; - if (argc != 4) + if (argc != 5) usage(); - iov_buf.iov_base = argv[3]; - iov_buf.iov_len = strlen(argv[3]); + error = extattr_string_to_namespace(argv[1], &namespace); + if (error) { + perror(argv[1]); + return (-1); + } + + iov_buf.iov_base = argv[4]; + iov_buf.iov_len = strlen(argv[4]); - error = extattr_set_file(argv[2], argv[1], &iov_buf, 1); + error = extattr_set_file(argv[3], namespace, argv[2], &iov_buf, 1); if (error == -1) { - perror("extattr_set_file"); + perror(argv[3]); return (-1); } |