e2999c9fcee7075f6b96fa0bfcf5595d35d6a266
[gnulib.git] / lib / acl-errno-valid.c
1 /* Test whether ACLs are well supported on this system.
2
3    Copyright 2013 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18    Written by Paul Eggert.  */
19
20 #include <config.h>
21
22 #include <acl.h>
23
24 #include <errno.h>
25
26 /* Return true if errno value ERRNUM indicates that ACLs are well
27    supported on this system.  ERRNUM should be an errno value obtained
28    after an ACL-related system call fails.  */
29 bool
30 acl_errno_valid (int errnum)
31 {
32   /* Recognize some common errors such as from an NFS mount that does
33      not support ACLs, even when local drives do.  */
34   switch (errnum)
35     {
36     case EBUSY: return false;
37     case EINVAL: return false;
38 #if defined __APPLE__ && defined __MACH__
39     case ENOENT: return false;
40 #endif
41     case ENOSYS: return false;
42 #if defined ENOTSUP && ENOTSUP != EOPNOTSUPP
43     case ENOTSUP: return false;
44 #endif
45     case EOPNOTSUPP: return false;
46     default: return true;
47     }
48 }