blob: 79f23ee9a4e6de5318f23f30d0a62fba9d1a1c1f [file] [log] [blame]
Mike Frysinger1fd98e02005-05-09 22:10:42 +00001/*
2 File: linux/ext2_ext_attr.h
3
4 On-disk format of extended attributes for the ext2 filesystem.
5
6 (C) 2000 Andreas Gruenbacher, <a.gruenbacher@computer.org>
7*/
8
9/* Magic value in attribute blocks */
10#define EXT2_EXT_ATTR_MAGIC_v1 0xEA010000
11#define EXT2_EXT_ATTR_MAGIC 0xEA020000
12
13/* Maximum number of references to one attribute block */
14#define EXT2_EXT_ATTR_REFCOUNT_MAX 1024
15
16struct ext2_ext_attr_header {
17 __u32 h_magic; /* magic number for identification */
18 __u32 h_refcount; /* reference count */
19 __u32 h_blocks; /* number of disk blocks used */
20 __u32 h_hash; /* hash value of all attributes */
21 __u32 h_reserved[4]; /* zero right now */
22};
23
24struct ext2_ext_attr_entry {
25 __u8 e_name_len; /* length of name */
26 __u8 e_name_index; /* attribute name index */
27 __u16 e_value_offs; /* offset in disk block of value */
28 __u32 e_value_block; /* disk block attribute is stored on (n/i) */
29 __u32 e_value_size; /* size of attribute value */
30 __u32 e_hash; /* hash value of name and value */
Mike Frysinger1fd98e02005-05-09 22:10:42 +000031};
32
33#define EXT2_EXT_ATTR_PAD_BITS 2
34#define EXT2_EXT_ATTR_PAD (1<<EXT2_EXT_ATTR_PAD_BITS)
35#define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
36#define EXT2_EXT_ATTR_LEN(name_len) \
37 (((name_len) + EXT2_EXT_ATTR_ROUND + \
38 sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
39#define EXT2_EXT_ATTR_NEXT(entry) \
40 ( (struct ext2_ext_attr_entry *)( \
41 (char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
42#define EXT2_EXT_ATTR_SIZE(size) \
43 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
44#define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
45#define EXT2_EXT_ATTR_NAME(entry) \
46 (((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
47#define EXT2_XATTR_LEN(name_len) \
48 (((name_len) + EXT2_EXT_ATTR_ROUND + \
49 sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
50#define EXT2_XATTR_SIZE(size) \
51 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
52