]> code.delx.au - gnu-emacs/blobdiff - lib/get-permissions.c
Make ‘delete-trailing-whitespace’ delete spaces after form feed
[gnu-emacs] / lib / get-permissions.c
index ccee1f1410e1dd695bf912eb07196b68d5b0501f..bf40dad7801a0ec8d7f6aa6201d3c7c71c0706b8 100644 (file)
@@ -1,6 +1,6 @@
-/* get-permissions.c - get permissions of a file
+/* Get permissions of a file.  -*- coding: utf-8 -*-
 
-   Copyright (C) 2002-2003, 2005-2015 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2016 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@ int
 get_permissions (const char *name, int desc, mode_t mode,
                 struct permission_context *ctx)
 {
-  memset (ctx, 0, sizeof(*ctx));
+  memset (ctx, 0, sizeof *ctx);
   ctx->mode = mode;
 
 #if USE_ACL && HAVE_ACL_GET_FILE
@@ -60,6 +60,12 @@ get_permissions (const char *name, int desc, mode_t mode,
        return -1;
     }
 
+# if HAVE_ACL_TYPE_NFS4  /* FreeBSD */
+
+  /* TODO (see set_permissions). */
+
+# endif
+
 #  else /* HAVE_ACL_TYPE_EXTENDED */
   /* Mac OS X */
 
@@ -96,7 +102,7 @@ get_permissions (const char *name, int desc, mode_t mode,
      There is an API
        pathconf (name, _PC_ACL_ENABLED)
        fpathconf (desc, _PC_ACL_ENABLED)
-     that allows to determine which of the two kinds of ACLs is supported
+     that allows us to determine which of the two kinds of ACLs is supported
      for the given file.  But some file systems may implement this call
      incorrectly, so better not use it.
      When fetching the source ACL, we simply fetch both ACL types.
@@ -215,38 +221,40 @@ get_permissions (const char *name, int desc, mode_t mode,
 
 #elif USE_ACL && HAVE_GETACL /* HP-UX */
 
-  int ret;
-
-  if (desc != -1)
-    ret = fgetacl (desc, NACLENTRIES, ctx->entries);
-  else
-    ret = getacl (name, NACLENTRIES, ctx->entries);
-  if (ret < 0)
-    {
-      if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
-       ret = 0;
-      else
-        return -1;
-    }
-  else if (ret > NACLENTRIES)
-    /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
-    abort ();
-  ctx->count = ret;
+  {
+    int ret;
+
+    if (desc != -1)
+      ret = fgetacl (desc, NACLENTRIES, ctx->entries);
+    else
+      ret = getacl (name, NACLENTRIES, ctx->entries);
+    if (ret < 0)
+      {
+        if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
+          ret = 0;
+        else
+          return -1;
+      }
+    else if (ret > NACLENTRIES)
+      /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
+      abort ();
+    ctx->count = ret;
 
 # if HAVE_ACLV_H
-  ret = acl ((char *) name, ACL_GET, NACLVENTRIES, ctx->aclv_entries);
-  if (ret < 0)
-    {
-      if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
-        ret = 0;
-      else
-        return -2;
-    }
-  else if (ret > NACLVENTRIES)
-    /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation.  */
+    ret = acl ((char *) name, ACL_GET, NACLVENTRIES, ctx->aclv_entries);
+    if (ret < 0)
+      {
+        if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+          ret = 0;
+        else
+          return -2;
+      }
+    else if (ret > NACLVENTRIES)
+      /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation.  */
       abort ();
-  ctx->aclv_count = ret;
+    ctx->aclv_count = ret;
 # endif
+  }
 
 #elif USE_ACL && HAVE_ACLX_GET && ACL_AIX_WIP /* AIX */
 
@@ -254,24 +262,27 @@ get_permissions (const char *name, int desc, mode_t mode,
 
 #elif USE_ACL && HAVE_STATACL /* older AIX */
 
-  if (desc != -1)
-    ret = fstatacl (desc, STX_NORMAL, &ctx->u.a, sizeof (ctx->u));
-  else
-    ret = statacl (name, STX_NORMAL, &ctx->u.a, sizeof (ctx->u));
-  if (ret == 0)
-    ctx->have_u = true;
+  {
+    int ret;
+    if (desc != -1)
+      ret = fstatacl (desc, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+    else
+      ret = statacl ((char *) name, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+    if (ret == 0)
+      ctx->have_u = true;
+  }
 
 #elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
 
-  int ret;
-
-  ret = acl ((char *) name, ACL_GET, NACLENTRIES, ctx->entries);
-  if (ret < 0)
-    return -1;
-  else if (ret > NACLENTRIES)
-    /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
-    abort ();
-  ctx->count = ret;
+  {
+    int ret = acl ((char *) name, ACL_GET, NACLENTRIES, ctx->entries);
+    if (ret < 0)
+      return -1;
+    else if (ret > NACLENTRIES)
+      /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
+      abort ();
+    ctx->count = ret;
+  }
 
 #endif