xfs_acl.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2001-2004 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #ifndef __XFS_ACL_H__
  33. #define __XFS_ACL_H__
  34. /*
  35. * Access Control Lists
  36. */
  37. typedef __uint16_t xfs_acl_perm_t;
  38. typedef __int32_t xfs_acl_type_t;
  39. typedef __int32_t xfs_acl_tag_t;
  40. typedef __int32_t xfs_acl_id_t;
  41. #define XFS_ACL_MAX_ENTRIES 25
  42. #define XFS_ACL_NOT_PRESENT (-1)
  43. typedef struct xfs_acl_entry {
  44. xfs_acl_tag_t ae_tag;
  45. xfs_acl_id_t ae_id;
  46. xfs_acl_perm_t ae_perm;
  47. } xfs_acl_entry_t;
  48. typedef struct xfs_acl {
  49. __int32_t acl_cnt;
  50. xfs_acl_entry_t acl_entry[XFS_ACL_MAX_ENTRIES];
  51. } xfs_acl_t;
  52. /* On-disk XFS extended attribute names */
  53. #define SGI_ACL_FILE "SGI_ACL_FILE"
  54. #define SGI_ACL_DEFAULT "SGI_ACL_DEFAULT"
  55. #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
  56. #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
  57. #ifdef CONFIG_XFS_POSIX_ACL
  58. struct vattr;
  59. struct vnode;
  60. struct xfs_inode;
  61. extern struct kmem_zone *xfs_acl_zone;
  62. #define xfs_acl_zone_init(zone, name) \
  63. (zone) = kmem_zone_init(sizeof(xfs_acl_t), name)
  64. #define xfs_acl_zone_destroy(zone) kmem_cache_destroy(zone)
  65. extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *);
  66. extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
  67. extern int xfs_acl_vtoacl(struct vnode *, xfs_acl_t *, xfs_acl_t *);
  68. extern int xfs_acl_vhasacl_access(struct vnode *);
  69. extern int xfs_acl_vhasacl_default(struct vnode *);
  70. extern int xfs_acl_vset(struct vnode *, void *, size_t, int);
  71. extern int xfs_acl_vget(struct vnode *, void *, size_t, int);
  72. extern int xfs_acl_vremove(struct vnode *vp, int);
  73. #define _ACL_TYPE_ACCESS 1
  74. #define _ACL_TYPE_DEFAULT 2
  75. #define _ACL_PERM_INVALID(perm) ((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
  76. #define _ACL_INHERIT(c,v,d) (xfs_acl_inherit(c,v,d))
  77. #define _ACL_GET_ACCESS(pv,pa) (xfs_acl_vtoacl(pv,pa,NULL) == 0)
  78. #define _ACL_GET_DEFAULT(pv,pd) (xfs_acl_vtoacl(pv,NULL,pd) == 0)
  79. #define _ACL_ACCESS_EXISTS xfs_acl_vhasacl_access
  80. #define _ACL_DEFAULT_EXISTS xfs_acl_vhasacl_default
  81. #define _ACL_XFS_IACCESS(i,m,c) (XFS_IFORK_Q(i) ? xfs_acl_iaccess(i,m,c) : -1)
  82. #define _ACL_ALLOC(a) ((a) = kmem_zone_alloc(xfs_acl_zone, KM_SLEEP))
  83. #define _ACL_FREE(a) ((a)? kmem_zone_free(xfs_acl_zone, (a)):(void)0)
  84. #else
  85. #define xfs_acl_zone_init(zone,name)
  86. #define xfs_acl_zone_destroy(zone)
  87. #define xfs_acl_vset(v,p,sz,t) (-EOPNOTSUPP)
  88. #define xfs_acl_vget(v,p,sz,t) (-EOPNOTSUPP)
  89. #define xfs_acl_vremove(v,t) (-EOPNOTSUPP)
  90. #define xfs_acl_vhasacl_access(v) (0)
  91. #define xfs_acl_vhasacl_default(v) (0)
  92. #define _ACL_ALLOC(a) (1) /* successfully allocate nothing */
  93. #define _ACL_FREE(a) ((void)0)
  94. #define _ACL_INHERIT(c,v,d) (0)
  95. #define _ACL_GET_ACCESS(pv,pa) (0)
  96. #define _ACL_GET_DEFAULT(pv,pd) (0)
  97. #define _ACL_ACCESS_EXISTS (NULL)
  98. #define _ACL_DEFAULT_EXISTS (NULL)
  99. #define _ACL_XFS_IACCESS(i,m,c) (-1)
  100. #endif
  101. #endif /* __XFS_ACL_H__ */