eattr.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
  4. *
  5. * This copyrighted material is made available to anyone wishing to use,
  6. * modify, copy, or redistribute it subject to the terms and conditions
  7. * of the GNU General Public License version 2.
  8. */
  9. #ifndef __EATTR_DOT_H__
  10. #define __EATTR_DOT_H__
  11. struct gfs2_inode;
  12. struct iattr;
  13. #define GFS2_EA_REC_LEN(ea) be32_to_cpu((ea)->ea_rec_len)
  14. #define GFS2_EA_DATA_LEN(ea) be32_to_cpu((ea)->ea_data_len)
  15. #define GFS2_EA_SIZE(ea) \
  16. ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \
  17. ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \
  18. (sizeof(__be64) * (ea)->ea_num_ptrs)), 8)
  19. #define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs)
  20. #define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST)
  21. #define GFS2_EAREQ_SIZE_STUFFED(er) \
  22. ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8)
  23. #define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \
  24. ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \
  25. sizeof(__be64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)
  26. #define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1))
  27. #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len)
  28. #define GFS2_EA2DATAPTRS(ea) \
  29. ((__be64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
  30. #define GFS2_EA2NEXT(ea) \
  31. ((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea)))
  32. #define GFS2_EA_BH2FIRST(bh) \
  33. ((struct gfs2_ea_header *)((bh)->b_data + sizeof(struct gfs2_meta_header)))
  34. #define GFS2_ERF_MODE 0x80000000
  35. struct gfs2_ea_request {
  36. const char *er_name;
  37. char *er_data;
  38. unsigned int er_name_len;
  39. unsigned int er_data_len;
  40. unsigned int er_type; /* GFS2_EATYPE_... */
  41. int er_flags;
  42. mode_t er_mode;
  43. };
  44. struct gfs2_ea_location {
  45. struct buffer_head *el_bh;
  46. struct gfs2_ea_header *el_ea;
  47. struct gfs2_ea_header *el_prev;
  48. };
  49. int gfs2_ea_get_i(struct gfs2_inode *ip, struct gfs2_ea_request *er);
  50. int gfs2_ea_set_i(struct gfs2_inode *ip, struct gfs2_ea_request *er);
  51. int gfs2_ea_remove_i(struct gfs2_inode *ip, struct gfs2_ea_request *er);
  52. int gfs2_ea_list(struct gfs2_inode *ip, struct gfs2_ea_request *er);
  53. int gfs2_ea_get(struct gfs2_inode *ip, struct gfs2_ea_request *er);
  54. int gfs2_ea_set(struct gfs2_inode *ip, struct gfs2_ea_request *er);
  55. int gfs2_ea_remove(struct gfs2_inode *ip, struct gfs2_ea_request *er);
  56. int gfs2_ea_dealloc(struct gfs2_inode *ip);
  57. /* Exported to acl.c */
  58. int gfs2_ea_find(struct gfs2_inode *ip,
  59. struct gfs2_ea_request *er,
  60. struct gfs2_ea_location *el);
  61. int gfs2_ea_get_copy(struct gfs2_inode *ip,
  62. struct gfs2_ea_location *el,
  63. char *data);
  64. int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el,
  65. struct iattr *attr, char *data);
  66. static inline unsigned int gfs2_ea_strlen(struct gfs2_ea_header *ea)
  67. {
  68. switch (ea->ea_type) {
  69. case GFS2_EATYPE_USR:
  70. return 5 + ea->ea_name_len + 1;
  71. case GFS2_EATYPE_SYS:
  72. return 7 + ea->ea_name_len + 1;
  73. case GFS2_EATYPE_SECURITY:
  74. return 9 + ea->ea_name_len + 1;
  75. default:
  76. return 0;
  77. }
  78. }
  79. #endif /* __EATTR_DOT_H__ */