2 File: linux/ext2_ext_attr.h
4 On-disk format of extended attributes for the ext2 filesystem.
6 (C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
9 #ifndef _EXT2_EXT_ATTR_H
10 #define _EXT2_EXT_ATTR_H
11 /* Magic value in attribute blocks */
12 #define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
13 #define EXT2_EXT_ATTR_MAGIC 0xEA020000
15 /* Maximum number of references to one attribute block */
16 #define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
18 #define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
19 #define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
21 struct ext2_ext_attr_header {
22 __u32 h_magic; /* magic number for identification */
23 __u32 h_refcount; /* reference count */
24 __u32 h_blocks; /* number of disk blocks used */
25 __u32 h_hash; /* hash value of all attributes */
26 __u32 h_reserved[4]; /* zero right now */
29 struct ext2_ext_attr_entry {
30 __u8 e_name_len; /* length of name */
31 __u8 e_name_index; /* attribute name index */
32 __u16 e_value_offs; /* offset in disk block of value */
33 __u32 e_value_block; /* disk block attribute is stored on (n/i) */
34 __u32 e_value_size; /* size of attribute value */
35 __u32 e_hash; /* hash value of name and value */
37 char e_name[0]; /* attribute name */
41 #define BHDR(block) ((struct ext2_ext_attr_header *)block)
42 #define IHDR(inode) ((__u32 *)((char *)inode + EXT2_GOOD_OLD_INODE_SIZE + \
43 (inode)->i_extra_isize))
44 #define ENTRY(ptr) ((struct ext2_ext_attr_entry *)(ptr))
47 #define EXT2_ATTR_INDEX_USER 1
48 #define EXT2_ATTR_INDEX_POSIX_ACL_ACCESS 2
49 #define EXT2_ATTR_INDEX_POSIX_ACL_DEFAULT 3
50 #define EXT2_ATTR_INDEX_TRUSTED 4
51 #define EXT2_ATTR_INDEX_LUSTRE 5
52 #define EXT2_ATTR_INDEX_SECURITY 6
53 #define EXT2_ATTR_INDEX_MAX 7
55 #define EXT2_ATTR_INDEX_USER_PREFIX "user."
56 #define EXT2_ATTR_INDEX_POSIX_ACL_ACCESS_PREFIX "system.posix_acl_access"
57 #define EXT2_ATTR_INDEX_POSIX_ACL_DEFAULT_PREFIX "system.posix_acl_default"
58 #define EXT2_ATTR_INDEX_TRUSTED_PREFIX "trusted."
59 #define EXT2_ATTR_INDEX_LUSTRE_PREFIX "lustre."
60 #define EXT2_ATTR_INDEX_SECURITY_PREFIX "security."
62 #define EXT2_ATTR_PREFIX(index) (index ## _PREFIX)
63 #define EXT2_ATTR_PREFIX_LEN(index) (index ## _PRE_LEN)
65 #define EXT2_EXT_ATTR_PAD_BITS 2
66 #define EXT2_EXT_ATTR_PAD ((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS)
67 #define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
68 #define EXT2_EXT_ATTR_LEN(name_len) \
69 (((name_len) + EXT2_EXT_ATTR_ROUND + \
70 sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
71 #define EXT2_EXT_ATTR_NEXT(entry) \
72 ( (struct ext2_ext_attr_entry *)( \
73 (char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
74 #define EXT2_EXT_ATTR_SIZE(size) \
75 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
76 #define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
77 #define EXT2_EXT_ATTR_NAME(entry) \
78 (((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
79 #define EXT2_XATTR_LEN(name_len) \
80 (((name_len) + EXT2_EXT_ATTR_ROUND + \
81 sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
82 #define EXT2_XATTR_SIZE(size) \
83 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
86 # ifdef CONFIG_EXT2_FS_EXT_ATTR
87 extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
88 extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
89 extern void ext2_ext_attr_free_inode(struct inode *inode);
90 extern void ext2_ext_attr_put_super(struct super_block *sb);
91 extern int ext2_ext_attr_init(void);
92 extern void ext2_ext_attr_done(void);
94 # define ext2_get_ext_attr NULL
95 # define ext2_set_ext_attr NULL
97 #endif /* __KERNEL__ */
98 #endif /* _EXT2_EXT_ATTR_H */