xattr.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1))
  24. #define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len)
  25. #define GFS2_EA2DATAPTRS(ea) \
  26. ((__be64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
  27. #define GFS2_EA2NEXT(ea) \
  28. ((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea)))
  29. #define GFS2_EA_BH2FIRST(bh) \
  30. ((struct gfs2_ea_header *)((bh)->b_data + sizeof(struct gfs2_meta_header)))
  31. struct gfs2_ea_request {
  32. const char *er_name;
  33. char *er_data;
  34. unsigned int er_name_len;
  35. unsigned int er_data_len;
  36. unsigned int er_type; /* GFS2_EATYPE_... */
  37. };
  38. struct gfs2_ea_location {
  39. struct buffer_head *el_bh;
  40. struct gfs2_ea_header *el_ea;
  41. struct gfs2_ea_header *el_prev;
  42. };
  43. extern int __gfs2_xattr_set(struct inode *inode, const char *name,
  44. const void *value, size_t size,
  45. int flags, int type);
  46. extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size);
  47. extern int gfs2_ea_dealloc(struct gfs2_inode *ip);
  48. /* Exported to acl.c */
  49. extern int gfs2_xattr_acl_get(struct gfs2_inode *ip, const char *name, char **data);
  50. extern int gfs2_xattr_acl_chmod(struct gfs2_inode *ip, struct iattr *attr, char *data);
  51. #endif /* __EATTR_DOT_H__ */