diff options
author | rwatson <rwatson@FreeBSD.org> | 2001-12-31 18:21:24 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2001-12-31 18:21:24 +0000 |
commit | 65c137db8e32df880beb38795b27baf339afb662 (patch) | |
tree | 63bbf49d6ab66a9d606da451849ac00c1834ec75 /usr.sbin/extattrctl | |
parent | 5eea21cccab61c0a7e31c0025f3f57feeb99870a (diff) | |
download | FreeBSD-src-65c137db8e32df880beb38795b27baf339afb662.zip FreeBSD-src-65c137db8e32df880beb38795b27baf339afb662.tar.gz |
o Add a 'showattr' function the extattrctl, allowing a backing file to
be inspected to show the maximum attribute size and file.
Diffstat (limited to 'usr.sbin/extattrctl')
-rw-r--r-- | usr.sbin/extattrctl/extattrctl.8 | 6 | ||||
-rw-r--r-- | usr.sbin/extattrctl/extattrctl.c | 44 |
2 files changed, 50 insertions, 0 deletions
diff --git a/usr.sbin/extattrctl/extattrctl.8 b/usr.sbin/extattrctl/extattrctl.8 index 888adde..2da0ff2 100644 --- a/usr.sbin/extattrctl/extattrctl.8 +++ b/usr.sbin/extattrctl/extattrctl.8 @@ -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 diff --git a/usr.sbin/extattrctl/extattrctl.c b/usr.sbin/extattrctl/extattrctl.c index 0a422eb..98e1d35 100644 --- a/usr.sbin/extattrctl/extattrctl.c +++ b/usr.sbin/extattrctl/extattrctl.c @@ -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); @@ -161,6 +163,42 @@ initattr(int argc, char *argv[]) } 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[]) { int error = 0, attrnamespace; @@ -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(); |