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