From 65c137db8e32df880beb38795b27baf339afb662 Mon Sep 17 00:00:00 2001 From: rwatson Date: Mon, 31 Dec 2001 18:21:24 +0000 Subject: [PATCH] o Add a 'showattr' function the extattrctl, allowing a backing file to be inspected to show the maximum attribute size and file. --- usr.sbin/extattrctl/extattrctl.8 | 6 +++++ usr.sbin/extattrctl/extattrctl.c | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/usr.sbin/extattrctl/extattrctl.8 b/usr.sbin/extattrctl/extattrctl.8 index 888adde9700e..2da0ff271e26 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 0a422eba5d71..98e1d35edd94 100644 --- a/usr.sbin/extattrctl/extattrctl.c +++ b/usr.sbin/extattrctl/extattrctl.c @@ -49,6 +49,7 @@ #include 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();