PERFORCE change 148364 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Mon Aug 25 09:14:00 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=148364
Change 148364 by trasz at trasz_traszkan on 2008/08/25 09:13:08
Improve acl_is_trivial_np(3) API.
Affected files ...
.. //depot/projects/soc2008/trasz_nfs4acl/bin/cp/utils.c#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/bin/ls/print.c#4 edit
.. //depot/projects/soc2008/trasz_nfs4acl/bin/mv/mv.c#5 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_is_trivial_np.3#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_strip.c#3 edit
.. //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#23 edit
Differences ...
==== //depot/projects/soc2008/trasz_nfs4acl/bin/cp/utils.c#3 (text+ko) ====
@@ -355,7 +355,7 @@
{
acl_t acl;
acl_type_t source_type, dest_type;
- int source_acl_supported = 0, dest_acl_supported = 0;
+ int source_acl_supported = 0, dest_acl_supported = 0, trivial;
if (fpathconf(source_fd, _PC_ACL_EXTENDED) == 1) {
source_acl_supported = 1;
@@ -386,7 +386,12 @@
return (1);
}
- if (acl_is_trivial_np(acl))
+ if (acl_is_trivial_np(acl, &trivial)) {
+ warn("acl_is_trivial() failed");
+ return (1);
+ }
+
+ if (trivial)
return (0);
if (source_type != dest_type) {
==== //depot/projects/soc2008/trasz_nfs4acl/bin/ls/print.c#4 (text+ko) ====
@@ -616,7 +616,7 @@
aclmode(char *buf, const FTSENT *p, int *haveacls)
{
char name[MAXPATHLEN + 1];
- int type = ACL_TYPE_ACCESS, ret;
+ int type = ACL_TYPE_ACCESS, ret, trivial;
acl_t facl;
/*
@@ -662,7 +662,12 @@
return;
if ((facl = acl_get_file(name, type)) != NULL) {
- if (!acl_is_trivial_np(facl))
+ if (acl_is_trivial_np(facl, &trivial)) {
+ warn("%s", name);
+ return;
+ }
+
+ if (!trivial)
buf[10] = '+';
acl_free(facl);
==== //depot/projects/soc2008/trasz_nfs4acl/bin/mv/mv.c#5 (text+ko) ====
@@ -440,7 +440,7 @@
{
acl_t acl;
acl_type_t source_type, dest_type;
- int source_acl_supported = 0, dest_acl_supported = 0;
+ int source_acl_supported = 0, dest_acl_supported = 0, trivial;
if (fpathconf(source_fd, _PC_ACL_EXTENDED) == 1) {
source_acl_supported = 1;
@@ -471,7 +471,12 @@
return (1);
}
- if (acl_is_trivial_np(acl))
+ if (acl_is_trivial_np(acl, &trivial)) {
+ warn("acl_is_trivial() failed");
+ return (1);
+ }
+
+ if (trivial)
return (0);
if (source_type != dest_type) {
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_is_trivial_np.3#3 (text+ko) ====
@@ -39,13 +39,18 @@
.In sys/types.h
.In sys/acl.h
.Ft int
-.Fn acl_is_trivial_np "const acl_t acl"
+.Fn acl_is_trivial_np "const acl_t aclp" "int *trivialp"
.Sh DESCRIPTION
The
.Fn acl_is_trivial
function determines whether the ACL pointed to by the argument
.Va acl
is trivial.
+Upon successful completion, the location referred to by the argument
+.Fa trivialp
+will be set to 1, if the ACL
+.Fa aclp
+points to is trivial, or 0 if it's not.
.Pp
ACL is trivial if it can be fully expressed as a file mode without loosing
any access rules.
@@ -55,9 +60,7 @@
File having non-trivial ACL have a plus sign appended after mode bits
in "ls -al" output.
.Sh RETURN VALUES
-The
-.Fn acl_is_trivial
-function returns 0 if the ACL is not trivial, non-zero otherwise.
+.Rv -std acl_get_tag_type
.Sh SEE ALSO
.Xr acl 3 ,
.Xr posix1e 3
==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_strip.c#3 (text+ko) ====
@@ -155,15 +155,22 @@
* of the mode bits in "ls -l" output ;-)
*/
int
-acl_is_trivial_np(acl_t aclp)
+acl_is_trivial_np(const acl_t aclp, int *trivialp)
{
acl_t tmpacl;
int differs;
+ if (aclp == NULL || trivialp == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+
switch (_acl_brand(aclp)) {
case ACL_BRAND_POSIX:
if (aclp->ats_acl.acl_cnt == 3)
- return (1);
+ *trivialp = 1;
+ else
+ *trivialp = 0;
return (0);
@@ -173,21 +180,22 @@
* with the original.
*/
tmpacl = acl_strip_np(aclp, 0);
- /* XXX: This sucks. Can this happen at all? */
if (tmpacl == NULL)
- return (0);
+ return (-1);
differs = _acl_differs(aclp, tmpacl);
acl_free(tmpacl);
if (differs)
- return (0);
+ *trivialp = 0;
+ else
+ *trivialp = 1;
- return (1);
+ return (0);
default:
errno = EINVAL;
- return (0);
+ return (-1);
}
}
==== //depot/projects/soc2008/trasz_nfs4acl/sys/sys/acl.h#23 (text+ko) ====
@@ -375,7 +375,7 @@
int acl_valid_fd_np(int _fd, acl_type_t _type, acl_t _acl);
int acl_valid_file_np(const char *_path_p, acl_type_t _type, acl_t _acl);
int acl_valid_link_np(const char *_path_p, acl_type_t _type, acl_t _acl);
-int acl_is_trivial_np(const acl_t _acl);
+int acl_is_trivial_np(const acl_t _acl, int *_trivialp);
acl_t acl_strip_np(const acl_t _acl, int recalculate_mask);
__END_DECLS
More information about the p4-projects
mailing list