xfs_acl.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2001-2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_ACL_H__
  19. #define __XFS_ACL_H__
  20. /*
  21. * Access Control Lists
  22. */
  23. typedef __uint16_t xfs_acl_perm_t;
  24. typedef __int32_t xfs_acl_type_t;
  25. typedef __int32_t xfs_acl_tag_t;
  26. typedef __int32_t xfs_acl_id_t;
  27. #define XFS_ACL_MAX_ENTRIES 25
  28. #define XFS_ACL_NOT_PRESENT (-1)
  29. typedef struct xfs_acl_entry {
  30. xfs_acl_tag_t ae_tag;
  31. xfs_acl_id_t ae_id;
  32. xfs_acl_perm_t ae_perm;
  33. } xfs_acl_entry_t;
  34. typedef struct xfs_acl {
  35. __int32_t acl_cnt;
  36. xfs_acl_entry_t acl_entry[XFS_ACL_MAX_ENTRIES];
  37. } xfs_acl_t;
  38. /* On-disk XFS extended attribute names */
  39. #define SGI_ACL_FILE "SGI_ACL_FILE"
  40. #define SGI_ACL_DEFAULT "SGI_ACL_DEFAULT"
  41. #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
  42. #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
  43. #ifdef CONFIG_XFS_POSIX_ACL
  44. struct vattr;
  45. struct bhv_vnode;
  46. struct xfs_inode;
  47. extern struct kmem_zone *xfs_acl_zone;
  48. #define xfs_acl_zone_init(zone, name) \
  49. (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name))
  50. #define xfs_acl_zone_destroy(zone) kmem_zone_destroy(zone)
  51. extern int xfs_acl_inherit(struct bhv_vnode *, struct bhv_vattr *, xfs_acl_t *);
  52. extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
  53. extern int xfs_acl_vtoacl(struct bhv_vnode *, xfs_acl_t *, xfs_acl_t *);
  54. extern int xfs_acl_vhasacl_access(struct bhv_vnode *);
  55. extern int xfs_acl_vhasacl_default(struct bhv_vnode *);
  56. extern int xfs_acl_vset(struct bhv_vnode *, void *, size_t, int);
  57. extern int xfs_acl_vget(struct bhv_vnode *, void *, size_t, int);
  58. extern int xfs_acl_vremove(struct bhv_vnode *, int);
  59. #define _ACL_TYPE_ACCESS 1
  60. #define _ACL_TYPE_DEFAULT 2
  61. #define _ACL_PERM_INVALID(perm) ((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
  62. #define _ACL_INHERIT(c,v,d) (xfs_acl_inherit(c,v,d))
  63. #define _ACL_GET_ACCESS(pv,pa) (xfs_acl_vtoacl(pv,pa,NULL) == 0)
  64. #define _ACL_GET_DEFAULT(pv,pd) (xfs_acl_vtoacl(pv,NULL,pd) == 0)
  65. #define _ACL_ACCESS_EXISTS xfs_acl_vhasacl_access
  66. #define _ACL_DEFAULT_EXISTS xfs_acl_vhasacl_default
  67. #define _ACL_XFS_IACCESS(i,m,c) (XFS_IFORK_Q(i) ? xfs_acl_iaccess(i,m,c) : -1)
  68. #define _ACL_ALLOC(a) ((a) = kmem_zone_alloc(xfs_acl_zone, KM_SLEEP))
  69. #define _ACL_FREE(a) ((a)? kmem_zone_free(xfs_acl_zone, (a)):(void)0)
  70. #else
  71. #define xfs_acl_zone_init(zone,name)
  72. #define xfs_acl_zone_destroy(zone)
  73. #define xfs_acl_vset(v,p,sz,t) (-EOPNOTSUPP)
  74. #define xfs_acl_vget(v,p,sz,t) (-EOPNOTSUPP)
  75. #define xfs_acl_vremove(v,t) (-EOPNOTSUPP)
  76. #define xfs_acl_vhasacl_access(v) (0)
  77. #define xfs_acl_vhasacl_default(v) (0)
  78. #define _ACL_ALLOC(a) (1) /* successfully allocate nothing */
  79. #define _ACL_FREE(a) ((void)0)
  80. #define _ACL_INHERIT(c,v,d) (0)
  81. #define _ACL_GET_ACCESS(pv,pa) (0)
  82. #define _ACL_GET_DEFAULT(pv,pd) (0)
  83. #define _ACL_ACCESS_EXISTS (NULL)
  84. #define _ACL_DEFAULT_EXISTS (NULL)
  85. #define _ACL_XFS_IACCESS(i,m,c) (-1)
  86. #endif
  87. #endif /* __XFS_ACL_H__ */