PERFORCE change 142258 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Sun May 25 16:01:22 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=142258

Change 142258 by trasz at trasz_traszkan on 2008/05/25 16:01:16

	Add the ability to print NFSv4 ACLs to getfacl(1).  Again, only
	temporary, as most of the ace.c file should go into some library.

Affected files ...

.. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/Makefile#2 edit
.. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/ace.c#1 add
.. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.1#2 edit
.. //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#2 edit

Differences ...

==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/Makefile#2 (text+ko) ====

@@ -1,5 +1,6 @@
 # $FreeBSD: src/bin/getfacl/Makefile,v 1.6 2001/12/04 01:57:44 obrien Exp $
 
 PROG=	getfacl
+SRCS=	getfacl.c ace.c
 
 .include <bsd.prog.mk>

==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.1#2 (text+ko) ====

@@ -38,7 +38,7 @@
 .Nd get ACL information
 .Sh SYNOPSIS
 .Nm
-.Op Fl dhq
+.Op Fl cdhq
 .Op Ar
 .Sh DESCRIPTION
 The
@@ -56,6 +56,8 @@
 .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.

==== //depot/projects/soc2008/trasz_nfs4acl/bin/getfacl/getfacl.c#2 (text+ko) ====

@@ -174,14 +174,33 @@
 	return(acl);
 }
 
+int load_aces(char *path, ace_t *acesp[], int *nentriesp);
+int print_aces_aligned_nicely(const ace_t *ace, int nentries, int compact);
+
+int
+print_nfsv4_acl(char *path, int compact)
+{
+	int ret, nentries = -1;
+	ace_t *aces;
+
+	ret = load_aces(path, &aces, &nentries);
+	if (ret)
+		return (-1);
+
+	return (print_aces_aligned_nicely(aces, nentries, compact));
+}
+
 static int
-print_acl(char *path, acl_type_t type, int hflag, int qflag)
+print_acl(char *path, acl_type_t type, int hflag, int qflag, int cflag)
 {
 	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
@@ -234,7 +253,7 @@
 }
 
 static int
-print_acl_from_stdin(acl_type_t type, int hflag, int qflag)
+print_acl_from_stdin(acl_type_t type, int hflag, int qflag, int cflag)
 {
 	char	*p, pathname[PATH_MAX];
 	int	carried_error = 0;
@@ -242,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) == -1) {
+		if (print_acl(pathname, type, hflag, qflag, cflag) == -1) {
 			carried_error = -1;
 		}
 	}
@@ -256,12 +275,16 @@
 	acl_type_t	type = ACL_TYPE_ACCESS;
 	int	carried_error = 0;
 	int	ch, error, i;
-	int	hflag, qflag;
+	int	hflag, qflag, cflag;
 
 	hflag = 0;
 	qflag = 0;
-	while ((ch = getopt(argc, argv, "dhq")) != -1)
+	cflag = 0;
+	while ((ch = getopt(argc, argv, "cdhq")) != -1)
 		switch(ch) {
+		case 'c':
+			cflag = 1;
+			break;
 		case 'd':
 			type = ACL_TYPE_DEFAULT;
 			break;
@@ -279,17 +302,17 @@
 	argv += optind;
 
 	if (argc == 0) {
-		error = print_acl_from_stdin(type, hflag, qflag);
+		error = print_acl_from_stdin(type, hflag, qflag, cflag);
 		return(error ? 1 : 0);
 	}
 
 	for (i = 0; i < argc; i++) {
 		if (!strcmp(argv[i], "-")) {
-			error = print_acl_from_stdin(type, hflag, qflag);
+			error = print_acl_from_stdin(type, hflag, qflag, cflag);
 			if (error == -1)
 				carried_error = -1;
 		} else {
-			error = print_acl(argv[i], type, hflag, qflag);
+			error = print_acl(argv[i], type, hflag, qflag, cflag);
 			if (error == -1)
 				carried_error = -1;
 		}


More information about the p4-projects mailing list