PERFORCE change 142320 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Mon May 26 20:56:07 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=142320
Change 142320 by trasz at trasz_traszkan on 2008/05/26 20:55:21
Default to printing getfacl output in compact form. Make "-q" flag
actually work.
Affected files ...
.. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.1#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#3 edit
Differences ...
==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.1#3 (text+ko) ====
@@ -38,7 +38,7 @@
.Nd get ACL information
.Sh SYNOPSIS
.Nm
-.Op Fl cdhq
+.Op Fl dhqv
.Op Ar
.Sh DESCRIPTION
The
@@ -56,8 +56,6 @@
.Pp
The following option is available:
.Bl -tag -width indent
-.It Fl c
-For the NFSv4 ACLs, return the ACL in compact form.
.It Fl d
The operation applies to the default ACL of a directory instead of the
access ACL.
@@ -70,6 +68,8 @@
Do not write commented information about file name and ownership.
This is
useful when dealing with filenames with unprintable characters.
+.It Fl v
+For the NFSv4 ACLs, return the ACL in verbose form.
.El
.Pp
The following operand is available:
==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#3 (text+ko) ====
@@ -54,7 +54,7 @@
usage(void)
{
- fprintf(stderr, "getfacl [-dhq] [file ...]\n");
+ fprintf(stderr, "getfacl [-dhqv] [file ...]\n");
}
static char *
@@ -178,7 +178,7 @@
int print_aces_aligned_nicely(const ace_t *ace, int nentries, int compact);
int
-print_nfsv4_acl(char *path, int compact)
+print_nfsv4_acl(char *path, int verbose)
{
int ret, nentries = -1;
ace_t *aces;
@@ -187,20 +187,17 @@
if (ret)
return (-1);
- return (print_aces_aligned_nicely(aces, nentries, compact));
+ return (print_aces_aligned_nicely(aces, nentries, !verbose));
}
static int
-print_acl(char *path, acl_type_t type, int hflag, int qflag, int cflag)
+print_acl(char *path, acl_type_t type, int hflag, int qflag, int vflag)
{
struct stat sb;
acl_t acl;
char *acl_text;
int error;
- if (pathconf(path, _ACL_ACE_ENABLED))
- return (print_nfsv4_acl(path, cflag));
-
if (hflag)
error = lstat(path, &sb);
else
@@ -219,6 +216,9 @@
printf("# file: %s\n# owner: %s\n# group: %s\n", path,
getuname(sb.st_uid), getgname(sb.st_gid));
+ if (pathconf(path, _ACL_ACE_ENABLED))
+ return (print_nfsv4_acl(path, vflag));
+
if (hflag)
acl = acl_get_link_np(path, type);
else
@@ -253,7 +253,7 @@
}
static int
-print_acl_from_stdin(acl_type_t type, int hflag, int qflag, int cflag)
+print_acl_from_stdin(acl_type_t type, int hflag, int qflag, int vflag)
{
char *p, pathname[PATH_MAX];
int carried_error = 0;
@@ -261,7 +261,7 @@
while (fgets(pathname, (int)sizeof(pathname), stdin)) {
if ((p = strchr(pathname, '\n')) != NULL)
*p = '\0';
- if (print_acl(pathname, type, hflag, qflag, cflag) == -1) {
+ if (print_acl(pathname, type, hflag, qflag, vflag) == -1) {
carried_error = -1;
}
}
@@ -275,16 +275,13 @@
acl_type_t type = ACL_TYPE_ACCESS;
int carried_error = 0;
int ch, error, i;
- int hflag, qflag, cflag;
+ int hflag, qflag, vflag;
hflag = 0;
qflag = 0;
- cflag = 0;
- while ((ch = getopt(argc, argv, "cdhq")) != -1)
+ vflag = 0;
+ while ((ch = getopt(argc, argv, "dhqv")) != -1)
switch(ch) {
- case 'c':
- cflag = 1;
- break;
case 'd':
type = ACL_TYPE_DEFAULT;
break;
@@ -294,6 +291,9 @@
case 'q':
qflag = 1;
break;
+ case 'v':
+ vflag = 1;
+ break;
default:
usage();
return(-1);
@@ -302,17 +302,17 @@
argv += optind;
if (argc == 0) {
- error = print_acl_from_stdin(type, hflag, qflag, cflag);
+ error = print_acl_from_stdin(type, hflag, qflag, vflag);
return(error ? 1 : 0);
}
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-")) {
- error = print_acl_from_stdin(type, hflag, qflag, cflag);
+ error = print_acl_from_stdin(type, hflag, qflag, vflag);
if (error == -1)
carried_error = -1;
} else {
- error = print_acl(argv[i], type, hflag, qflag, cflag);
+ error = print_acl(argv[i], type, hflag, qflag, vflag);
if (error == -1)
carried_error = -1;
}
More information about the p4-projects
mailing list