acl-errno-valid.c 1.6 KB

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