o Add a 'showattr' function the extattrctl, allowing a backing file to

be inspected to show the maximum attribute size and file.
This commit is contained in:
Robert Watson 2001-12-31 18:21:24 +00:00
parent 9c4d63da6d
commit 566726db95
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=88740
2 changed files with 50 additions and 0 deletions

View File

@ -50,6 +50,9 @@
.Ar attrsize
.Ar attrfile
.Nm
.Cm showattr
.Ar attrfile
.Nm
.Cm enable
.Ar path
.Ar attrnamespace
@ -109,6 +112,9 @@ from denying attribute service.
.Pp
This file should not exist before running
.Cm initattr .
.It Cm showattr Ar attrfile
Show the attribute header values in the attribute file named by
.Ar attrfile .
.It Cm enable Ar path attrnamespace attrname attrfile
Enable an attribute named
.Ar attrname

View File

@ -49,6 +49,7 @@
#include <unistd.h>
int initattr(int argc, char *argv[]);
int showattr(int argc, char *argv[]);
long num_inodes_by_path(char *path);
void usage(void);
@ -61,6 +62,7 @@ usage()
" extattrctl start [path]\n"
" extattrctl stop [path]\n"
" extattrctl initattr [-f] [-p path] [attrsize] [attrfile]\n"
" extattrctl showattr [attrfile]\n"
" extattrctl enable [path] [attrnamespace] [attrname] [attrfile]\n"
" extattrctl disable [path] [attrnamespace] [attrname]\n");
exit(-1);
@ -160,6 +162,42 @@ initattr(int argc, char *argv[])
return (0);
}
int
showattr(int argc, char *argv[])
{
struct ufs_extattr_fileheader uef;
int i, fd;
if (argc != 1)
usage();
fd = open(argv[0], O_RDONLY);
if (fd == -1) {
perror(argv[0]);
return (-1);
}
i = read(fd, &uef, sizeof(uef));
if (i == -1) {
perror(argv[0]);
return (-1);
}
if (i != sizeof(uef)) {
fprintf(stderr, "%s: invalid file header\n", argv[0]);
return (-1);
}
if (uef.uef_magic != UFS_EXTATTR_MAGIC) {
fprintf(stderr, "%s: bad magic\n", argv[0]);
return (-1);
}
printf("%s: version %d, size %d\n", argv[0], uef.uef_version,
uef.uef_size);
return (0);
}
int
main(int argc, char *argv[])
{
@ -220,6 +258,12 @@ main(int argc, char *argv[])
error = initattr(argc, argv);
if (error)
return (-1);
} else if (!strcmp(argv[1], "showattr")) {
argc -= 2;
argv += 2;
error = showattr(argc, argv);
if (error)
return (-1);
} else
usage();