xfs_attr.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_ATTR_H__
  19. #define __XFS_ATTR_H__
  20. /*
  21. * xfs_attr.h
  22. *
  23. * Large attribute lists are structured around Btrees where all the data
  24. * elements are in the leaf nodes. Attribute names are hashed into an int,
  25. * then that int is used as the index into the Btree. Since the hashval
  26. * of an attribute name may not be unique, we may have duplicate keys.
  27. * The internal links in the Btree are logical block offsets into the file.
  28. *
  29. * Small attribute lists use a different format and are packed as tightly
  30. * as possible so as to fit into the literal area of the inode.
  31. */
  32. /*========================================================================
  33. * External interfaces
  34. *========================================================================*/
  35. struct cred;
  36. struct xfs_attr_list_context;
  37. typedef struct attrnames {
  38. char * attr_name;
  39. unsigned int attr_namelen;
  40. } attrnames_t;
  41. extern struct attrnames attr_user;
  42. extern struct attrnames attr_secure;
  43. extern struct attrnames attr_trusted;
  44. #define ATTR_DONTFOLLOW 0x0001 /* -- unused, from IRIX -- */
  45. #define ATTR_ROOT 0x0002 /* use attrs in root (trusted) namespace */
  46. #define ATTR_TRUST 0x0004 /* -- unused, from IRIX -- */
  47. #define ATTR_SECURE 0x0008 /* use attrs in security namespace */
  48. #define ATTR_CREATE 0x0010 /* pure create: fail if attr already exists */
  49. #define ATTR_REPLACE 0x0020 /* pure set: fail if attr does not exist */
  50. #define ATTR_KERNACCESS 0x0400 /* [kernel] iaccess, inode held io-locked */
  51. #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */
  52. #define ATTR_KERNOVAL 0x2000 /* [kernel] get attr size only, not value */
  53. #define ATTR_KERNAMELS 0x4000 /* [kernel] list attr names (simple list) */
  54. #define ATTR_KERNORMALS 0x0800 /* [kernel] normal attr list: user+secure */
  55. #define ATTR_KERNROOTLS 0x8000 /* [kernel] include root in the attr list */
  56. #define ATTR_KERNFULLS (ATTR_KERNORMALS|ATTR_KERNROOTLS)
  57. /*
  58. * The maximum size (into the kernel or returned from the kernel) of an
  59. * attribute value or the buffer used for an attr_list() call. Larger
  60. * sizes will result in an ERANGE return code.
  61. */
  62. #define ATTR_MAX_VALUELEN (64*1024) /* max length of a value */
  63. /*
  64. * Define how lists of attribute names are returned to the user from
  65. * the attr_list() call. A large, 32bit aligned, buffer is passed in
  66. * along with its size. We put an array of offsets at the top that each
  67. * reference an attrlist_ent_t and pack the attrlist_ent_t's at the bottom.
  68. */
  69. typedef struct attrlist {
  70. __s32 al_count; /* number of entries in attrlist */
  71. __s32 al_more; /* T/F: more attrs (do call again) */
  72. __s32 al_offset[1]; /* byte offsets of attrs [var-sized] */
  73. } attrlist_t;
  74. /*
  75. * Show the interesting info about one attribute. This is what the
  76. * al_offset[i] entry points to.
  77. */
  78. typedef struct attrlist_ent { /* data from attr_list() */
  79. __u32 a_valuelen; /* number bytes in value of attr */
  80. char a_name[1]; /* attr name (NULL terminated) */
  81. } attrlist_ent_t;
  82. /*
  83. * Given a pointer to the (char*) buffer containing the attr_list() result,
  84. * and an index, return a pointer to the indicated attribute in the buffer.
  85. */
  86. #define ATTR_ENTRY(buffer, index) \
  87. ((attrlist_ent_t *) \
  88. &((char *)buffer)[ ((attrlist_t *)(buffer))->al_offset[index] ])
  89. /*
  90. * Multi-attribute operation vector.
  91. */
  92. typedef struct attr_multiop {
  93. int am_opcode; /* operation to perform (ATTR_OP_GET, etc.) */
  94. int am_error; /* [out arg] result of this sub-op (an errno) */
  95. char *am_attrname; /* attribute name to work with */
  96. char *am_attrvalue; /* [in/out arg] attribute value (raw bytes) */
  97. int am_length; /* [in/out arg] length of value */
  98. int am_flags; /* bitwise OR of attr API flags defined above */
  99. } attr_multiop_t;
  100. #define ATTR_OP_GET 1 /* return the indicated attr's value */
  101. #define ATTR_OP_SET 2 /* set/create the indicated attr/value pair */
  102. #define ATTR_OP_REMOVE 3 /* remove the indicated attr */
  103. /*
  104. * Kernel-internal version of the attrlist cursor.
  105. */
  106. typedef struct attrlist_cursor_kern {
  107. __u32 hashval; /* hash value of next entry to add */
  108. __u32 blkno; /* block containing entry (suggestion) */
  109. __u32 offset; /* offset in list of equal-hashvals */
  110. __u16 pad1; /* padding to match user-level */
  111. __u8 pad2; /* padding to match user-level */
  112. __u8 initted; /* T/F: cursor has been initialized */
  113. } attrlist_cursor_kern_t;
  114. /*========================================================================
  115. * Function prototypes for the kernel.
  116. *========================================================================*/
  117. struct xfs_inode;
  118. struct attrlist_cursor_kern;
  119. struct xfs_da_args;
  120. /*
  121. * Overall external interface routines.
  122. */
  123. int xfs_attr_inactive(struct xfs_inode *dp);
  124. int xfs_attr_shortform_getvalue(struct xfs_da_args *);
  125. int xfs_attr_fetch(struct xfs_inode *, struct xfs_name *, char *, int *, int);
  126. int xfs_attr_rmtval_get(struct xfs_da_args *args);
  127. #endif /* __XFS_ATTR_H__ */