Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Mar 2009 19:11:14 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 160068 for review
Message-ID:  <200903311911.n2VJBENa052347@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=160068

Change 160068 by trasz@trasz_victim7 on 2009/03/31 19:10:39

	Remove more ugliness.

Affected files ...

.. //depot/projects/soc2008/trasz_nfs4acl/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/acl_compat.c#7 edit

Differences ...

==== //depot/projects/soc2008/trasz_nfs4acl/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/acl_compat.c#7 (text+ko) ====

@@ -67,11 +67,6 @@
 #include <sys/sf_buf.h>
 #include <sys/sched.h>
 
-/*
- * Pull FreeBSD sys/acl.h, not the ZFS one.
- */
-#include "../../../../../../../sys/acl.h"
-
 #include "acl_compat.h"
 
 struct artwo {
@@ -103,32 +98,38 @@
 			{ACE_FAILED_ACCESS_ACE_FLAG, ACL_ENTRY_FAILED_ACCESS},
 			{0, 0}};
 
-static void
-_bsd_from_sun(int *bsd, uint32_t sun, const struct artwo *table)
+static int
+_bsd_from_sun(uint32_t sun, const struct artwo *table)
 {
 	const struct artwo *tmp;
+	int bsd = 0;
 
 	for (tmp = table; tmp->sun != 0; tmp++) {
 		if (sun & tmp->sun)
-			*bsd |= tmp->bsd;
+			bsd |= tmp->bsd;
 	}
+
+	return (bsd);
 }
 
-static void
-_sun_from_bsd(uint32_t *sun, int bsd, const struct artwo *table)
+static uint32_t
+_sun_from_bsd(int bsd, const struct artwo *table)
 {
 	const struct artwo *tmp;
+	uint32_t sun = 0;
 
 	for (tmp = table; tmp->bsd != 0; tmp++) {
 		if (bsd & tmp->bsd)
-			*sun |= tmp->sun;
+			sun |= tmp->sun;
 	}
+
+	return (sun);
 }
 
 int
 acl_from_aces(struct acl *aclp, const ace_t *aces, int nentries)
 {
-	int i, tmpflags = 0;
+	int i;
 	struct acl_entry *entry;
 	const ace_t *ace;
 
@@ -157,9 +158,8 @@
 		else
 			entry->ae_id = ACL_UNDEFINED_ID;
 
-		_bsd_from_sun(&(entry->ae_perm), ace->a_access_mask, perms);
-		_bsd_from_sun(&tmpflags, ace->a_flags, flags);
-		entry->ae_flags = tmpflags;
+		entry->ae_perm = _bsd_from_sun(ace->a_access_mask, perms);
+		entry->ae_flags = _bsd_from_sun(ace->a_flags, flags);
 
 		switch (ace->a_type) {
 		case ACE_ACCESS_ALLOWED_ACE_TYPE:
@@ -175,8 +175,7 @@
 			entry->ae_extended = ACL_EXTENDED_ALARM;
 			break;
 		default:
-			printf("_acl_from_aces: a_type is 0x%x; panic?\n", ace->a_type);
-			return (EINVAL);
+			panic("_acl_from_aces: a_type is 0x%x", ace->a_type);
 		}
 	}
 
@@ -189,7 +188,6 @@
 	int i;
 	const struct acl_entry *entry;
 	ace_t *ace;
-	uint32_t tmpflags = 0;
 
 	bzero(aces, sizeof(*aces) * aclp->acl_cnt);
 
@@ -202,21 +200,19 @@
 		ace->a_who = entry->ae_id;
 
 		if (entry->ae_tag == ACL_USER_OBJ)
-			tmpflags = ACE_OWNER;
+			ace->a_flags = ACE_OWNER;
 		else if (entry->ae_tag == ACL_GROUP_OBJ)
-			tmpflags = (ACE_GROUP | ACE_IDENTIFIER_GROUP);
+			ace->a_flags = (ACE_GROUP | ACE_IDENTIFIER_GROUP);
 		else if (entry->ae_tag == ACL_GROUP)
-			tmpflags = ACE_IDENTIFIER_GROUP;
+			ace->a_flags = ACE_IDENTIFIER_GROUP;
 		else if (entry->ae_tag == ACL_EVERYONE)
-			tmpflags = ACE_EVERYONE;
+			ace->a_flags = ACE_EVERYONE;
 		else /* ACL_USER */
-			tmpflags = 0;
+			ace->a_flags = 0;
 
-		_sun_from_bsd(&(ace->a_access_mask), entry->ae_perm, perms);
-		_sun_from_bsd(&tmpflags, entry->ae_flags, flags);
+		ace->a_access_mask = _sun_from_bsd(entry->ae_perm, perms);
+		ace->a_flags |= _sun_from_bsd(entry->ae_flags, flags);
 
-		ace->a_flags = tmpflags;
-
 		switch (entry->ae_extended) {
 		case ACL_EXTENDED_ALLOW:
 			ace->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
@@ -231,11 +227,9 @@
 			ace->a_type = ACE_SYSTEM_AUDIT_ACE_TYPE;
 			break;
 		default:
-			printf("_aces_from_acl: ae_extended is 0x%x; panic?\n", entry->ae_extended);
-			return (EINVAL);
+			panic("_aces_from_acl: ae_extended is 0x%x", entry->ae_extended);
 		}
 	}
 
 	return (0);
 }
-



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903311911.n2VJBENa052347>