diff options
author | rwatson <rwatson@FreeBSD.org> | 2001-03-15 03:04:35 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2001-03-15 03:04:35 +0000 |
commit | 19471170ebe34962c1c5f89f38eff935ed8796e7 (patch) | |
tree | 459463dac60432dccaa85b5492099b4ec3254acf | |
parent | f843a4812be42e079fa066fe7f8e5568764902be (diff) | |
download | FreeBSD-src-19471170ebe34962c1c5f89f38eff935ed8796e7.zip FreeBSD-src-19471170ebe34962c1c5f89f38eff935ed8796e7.tar.gz |
o Update extattrctl to take into account the updated EA interface with
explicit namespaces. Modify it to use libutil for string/constant
namespace conversions. Update the documentation to take into account
the new interface.
Obtained from: TrustedBSD Project
-rw-r--r-- | usr.sbin/extattrctl/Makefile | 2 | ||||
-rw-r--r-- | usr.sbin/extattrctl/extattrctl.8 | 16 | ||||
-rw-r--r-- | usr.sbin/extattrctl/extattrctl.c | 64 |
3 files changed, 59 insertions, 23 deletions
diff --git a/usr.sbin/extattrctl/Makefile b/usr.sbin/extattrctl/Makefile index 01a7297..b7b90df 100644 --- a/usr.sbin/extattrctl/Makefile +++ b/usr.sbin/extattrctl/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ PROG= extattrctl SRCS= extattrctl.c -LDADD= +LDADD= ${LIBUTIL} CFLAGS+= -g -Wall MAN8+= extattrctl.8 diff --git a/usr.sbin/extattrctl/extattrctl.8 b/usr.sbin/extattrctl/extattrctl.8 index 187b3dc..113ff70 100644 --- a/usr.sbin/extattrctl/extattrctl.8 +++ b/usr.sbin/extattrctl/extattrctl.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 @@ -47,11 +47,13 @@ .Nm .Cm enable .Ar path +.Ar namespace .Ar attrname .Ar attrfile .Nm .Cm disable .Ar path +.Ar namespace .Ar attrname .Sh DESCRIPTION .Nm @@ -102,23 +104,29 @@ from denying attribute service. .Pp This file should not exist before running .Cm initattr . -.It Cm enable Ar path Ar attrname Ar attrfile +.It Cm enable Ar path Ar namespace Ar attrname Ar attrfile Enable an attribute named .Ar attrname +in the namespace +.Ar namespace on the file system identified using .Ar path , and backed by initialized attribute file .Ar attrfile . +Available namespaces are "user" and "system". The backing file must have been initialized using .Cm initattr before its first use. Attributes must have been started on the file system prior to the enabling of any attributes. -.It Cm disable Ar path Ar attrname +.It Cm disable Ar path Ar namespace Ar attrname Disable the attributed named .Ar attrname +in namespace +.Ar namespace on the file system identified by .Ar path . +Available namespaces are "user" and "system". The file system must have attributes started on it, and the attribute most have been enabled using .Cm enable . @@ -135,7 +143,7 @@ Create an attribute backing file in /.attribute/md5, and set the maximum size of each attribute to 17 bytes, with a sparse file used for storing the attributes. .Pp -.Dl extattrctl enable / md5 /.attribute/md5 +.Dl extattrctl enable / system md5 /.attribute/md5 .Pp Enable an attribute named md5 on the root file system, backed from the file /.attribute/md5. diff --git a/usr.sbin/extattrctl/extattrctl.c b/usr.sbin/extattrctl/extattrctl.c index c05ec95..240c22c 100644 --- a/usr.sbin/extattrctl/extattrctl.c +++ b/usr.sbin/extattrctl/extattrctl.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 @@ -37,7 +37,9 @@ #include <ufs/ufs/extattr.h> +#include <errno.h> #include <fcntl.h> +#include <libutil.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -55,8 +57,8 @@ usage(void) " extattrctl start [path]\n" " extattrctl stop [path]\n" " extattrctl initattr [-f] [-p path] [attrsize] [attrfile]\n" - " extattrctl enable [path] [attrname] [attrfile]\n" - " extattrctl disable [path] [attrname]\n"); + " extattrctl enable [path] [namespace] [attrname] [attrfile]\n" + " extattrctl disable [path] [namespace] [attrname]\n"); exit(-1); } @@ -157,7 +159,7 @@ initattr(int argc, char *argv[]) int main(int argc, char *argv[]) { - int error = 0; + int error = 0, namespace; if (argc < 2) usage(); @@ -165,34 +167,60 @@ main(int argc, char *argv[]) if (!strcmp(argv[1], "start")) { if (argc != 3) usage(); - error = extattrctl(argv[2], UFS_EXTATTR_CMD_START, 0, 0); - if (error) + error = extattrctl(argv[2], UFS_EXTATTR_CMD_START, NULL, 0, + NULL); + if (error) { perror("extattrctl start"); + return (-1); + } + return (0); } else if (!strcmp(argv[1], "stop")) { if (argc != 3) usage(); - error = extattrctl(argv[2], UFS_EXTATTR_CMD_STOP, 0, 0); - if (error) + error = extattrctl(argv[2], UFS_EXTATTR_CMD_STOP, NULL, 0, + NULL); + if (error) { perror("extattrctl stop"); + return (-1); + } + return (0); } else if (!strcmp(argv[1], "enable")) { - if (argc != 5) + if (argc != 6) usage(); - error = extattrctl(argv[2], UFS_EXTATTR_CMD_ENABLE, argv[3], - argv[4]); - if (error) + error = extattr_string_to_namespace(argv[3], &namespace); + if (error) { + perror("extattrctl enable"); + return (-1); + } + error = extattrctl(argv[2], UFS_EXTATTR_CMD_ENABLE, argv[4], + namespace, argv[5]); + if (error) { perror("extattrctl enable"); + return (-1); + } + return (0); } else if (!strcmp(argv[1], "disable")) { - if (argc != 4) + if (argc != 5) usage(); - error = extattrctl(argv[2], UFS_EXTATTR_CMD_DISABLE, argv[3], - NULL); - if (error) + error = extattr_string_to_namespace(argv[3], &namespace); + if (error) { perror("extattrctl disable"); + return (-1); + } + error = extattrctl(argv[2], UFS_EXTATTR_CMD_DISABLE, NULL, + namespace, argv[5]); + if (error) { + perror("extattrctl disable"); + return (-1); + } + return (0); } else if (!strcmp(argv[1], "initattr")) { argc -= 2; argv += 2; error = initattr(argc, argv); + if (error) + return (-1); + return (0); } else usage(); - return(error); } |