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
This commit is contained in:
parent
1bc2362e07
commit
bf6afea751
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74275
@ -1,7 +1,7 @@
|
||||
# $FreeBSD$
|
||||
PROG= extattrctl
|
||||
SRCS= extattrctl.c
|
||||
LDADD=
|
||||
LDADD= ${LIBUTIL}
|
||||
CFLAGS+= -g -Wall
|
||||
MAN8+= 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.
|
||||
|
@ -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
|
||||
@ -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 != 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user