posix_acl.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. File: linux/posix_acl.h
  3. (C) 2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
  4. */
  5. #ifndef __LINUX_POSIX_ACL_H
  6. #define __LINUX_POSIX_ACL_H
  7. #include <linux/slab.h>
  8. #define ACL_UNDEFINED_ID (-1)
  9. /* a_type field in acl_user_posix_entry_t */
  10. #define ACL_TYPE_ACCESS (0x8000)
  11. #define ACL_TYPE_DEFAULT (0x4000)
  12. /* e_tag entry in struct posix_acl_entry */
  13. #define ACL_USER_OBJ (0x01)
  14. #define ACL_USER (0x02)
  15. #define ACL_GROUP_OBJ (0x04)
  16. #define ACL_GROUP (0x08)
  17. #define ACL_MASK (0x10)
  18. #define ACL_OTHER (0x20)
  19. /* permissions in the e_perm field */
  20. #define ACL_READ (0x04)
  21. #define ACL_WRITE (0x02)
  22. #define ACL_EXECUTE (0x01)
  23. //#define ACL_ADD (0x08)
  24. //#define ACL_DELETE (0x10)
  25. struct posix_acl_entry {
  26. short e_tag;
  27. unsigned short e_perm;
  28. unsigned int e_id;
  29. };
  30. struct posix_acl {
  31. atomic_t a_refcount;
  32. unsigned int a_count;
  33. struct posix_acl_entry a_entries[0];
  34. };
  35. #define FOREACH_ACL_ENTRY(pa, acl, pe) \
  36. for(pa=(acl)->a_entries, pe=pa+(acl)->a_count; pa<pe; pa++)
  37. /*
  38. * Duplicate an ACL handle.
  39. */
  40. static inline struct posix_acl *
  41. posix_acl_dup(struct posix_acl *acl)
  42. {
  43. if (acl)
  44. atomic_inc(&acl->a_refcount);
  45. return acl;
  46. }
  47. /*
  48. * Free an ACL handle.
  49. */
  50. static inline void
  51. posix_acl_release(struct posix_acl *acl)
  52. {
  53. if (acl && atomic_dec_and_test(&acl->a_refcount))
  54. kfree(acl);
  55. }
  56. /* posix_acl.c */
  57. extern struct posix_acl *posix_acl_alloc(int, gfp_t);
  58. extern struct posix_acl *posix_acl_clone(const struct posix_acl *, gfp_t);
  59. extern int posix_acl_valid(const struct posix_acl *);
  60. extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
  61. extern struct posix_acl *posix_acl_from_mode(mode_t, gfp_t);
  62. extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
  63. extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
  64. extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
  65. extern struct posix_acl *get_posix_acl(struct inode *, int);
  66. extern int set_posix_acl(struct inode *, int, struct posix_acl *);
  67. #endif /* __LINUX_POSIX_ACL_H */