jffs2-user.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * $Id: jffs2-user.h,v 1.1 2004/05/05 11:57:54 dwmw2 Exp $
  3. *
  4. * JFFS2 definitions for use in user space only
  5. */
  6. #ifndef __JFFS2_USER_H__
  7. #define __JFFS2_USER_H__
  8. /* This file is blessed for inclusion by userspace */
  9. #include <linux/jffs2.h>
  10. #include <endian.h>
  11. #include <byteswap.h>
  12. #undef cpu_to_je16
  13. #undef cpu_to_je32
  14. #undef cpu_to_jemode
  15. #undef je16_to_cpu
  16. #undef je32_to_cpu
  17. #undef jemode_to_cpu
  18. extern int target_endian;
  19. #define t16(x) ({ uint16_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); })
  20. #define t32(x) ({ uint32_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); })
  21. #define cpu_to_je16(x) ((jint16_t){t16(x)})
  22. #define cpu_to_je32(x) ((jint32_t){t32(x)})
  23. #define cpu_to_jemode(x) ((jmode_t){t32(x)})
  24. #define je16_to_cpu(x) (t16((x).v16))
  25. #define je32_to_cpu(x) (t32((x).v32))
  26. #define jemode_to_cpu(x) (t32((x).m))
  27. #define le16_to_cpu(x) (__BYTE_ORDER==__LITTLE_ENDIAN ? (x) : bswap_16(x))
  28. #define le32_to_cpu(x) (__BYTE_ORDER==__LITTLE_ENDIAN ? (x) : bswap_32(x))
  29. #define cpu_to_le16(x) (__BYTE_ORDER==__LITTLE_ENDIAN ? (x) : bswap_16(x))
  30. #define cpu_to_le32(x) (__BYTE_ORDER==__LITTLE_ENDIAN ? (x) : bswap_32(x))
  31. /* XATTR/POSIX-ACL related definition */
  32. /* Namespaces copied from xattr.h and posix_acl_xattr.h */
  33. #define XATTR_USER_PREFIX "user."
  34. #define XATTR_USER_PREFIX_LEN (sizeof (XATTR_USER_PREFIX) - 1)
  35. #define XATTR_SECURITY_PREFIX "security."
  36. #define XATTR_SECURITY_PREFIX_LEN (sizeof (XATTR_SECURITY_PREFIX) - 1)
  37. #define POSIX_ACL_XATTR_ACCESS "system.posix_acl_access"
  38. #define POSIX_ACL_XATTR_ACCESS_LEN (sizeof (POSIX_ACL_XATTR_ACCESS) - 1)
  39. #define POSIX_ACL_XATTR_DEFAULT "system.posix_acl_default"
  40. #define POSIX_ACL_XATTR_DEFAULT_LEN (sizeof (POSIX_ACL_XATTR_DEFAULT) - 1)
  41. #define XATTR_TRUSTED_PREFIX "trusted."
  42. #define XATTR_TRUSTED_PREFIX_LEN (sizeof (XATTR_TRUSTED_PREFIX) - 1)
  43. struct jffs2_acl_entry {
  44. jint16_t e_tag;
  45. jint16_t e_perm;
  46. jint32_t e_id;
  47. };
  48. struct jffs2_acl_entry_short {
  49. jint16_t e_tag;
  50. jint16_t e_perm;
  51. };
  52. struct jffs2_acl_header {
  53. jint32_t a_version;
  54. };
  55. /* copied from include/linux/posix_acl_xattr.h */
  56. #define POSIX_ACL_XATTR_VERSION 0x0002
  57. struct posix_acl_xattr_entry {
  58. uint16_t e_tag;
  59. uint16_t e_perm;
  60. uint32_t e_id;
  61. };
  62. struct posix_acl_xattr_header {
  63. uint32_t a_version;
  64. struct posix_acl_xattr_entry a_entries[0];
  65. };
  66. #endif /* __JFFS2_USER_H__ */