diff --git a/usr.sbin/extattrctl/Makefile b/usr.sbin/extattrctl/Makefile index 01a7297f2eba..b7b90dfb6882 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 187b3dc5d931..113ff7073a35 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 c05ec956b9e2..240c22c03cdc 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 +#include #include +#include #include #include #include @@ -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 != 6) + usage(); + 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 != 5) usage(); - error = extattrctl(argv[2], UFS_EXTATTR_CMD_ENABLE, argv[3], - argv[4]); - if (error) - perror("extattrctl enable"); - } else if (!strcmp(argv[1], "disable")) { - if (argc != 4) - 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); }