Mike Frysinger | 1fd98e0 | 2005-05-09 22:10:42 +0000 | [diff] [blame^] | 1 | /* |
| 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 | |
| 16 | struct 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 | |
| 24 | struct 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 */ |
| 31 | #if 0 |
| 32 | char e_name[0]; /* attribute name */ |
| 33 | #endif |
| 34 | }; |
| 35 | |
| 36 | #define EXT2_EXT_ATTR_PAD_BITS 2 |
| 37 | #define EXT2_EXT_ATTR_PAD (1<<EXT2_EXT_ATTR_PAD_BITS) |
| 38 | #define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1) |
| 39 | #define EXT2_EXT_ATTR_LEN(name_len) \ |
| 40 | (((name_len) + EXT2_EXT_ATTR_ROUND + \ |
| 41 | sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND) |
| 42 | #define EXT2_EXT_ATTR_NEXT(entry) \ |
| 43 | ( (struct ext2_ext_attr_entry *)( \ |
| 44 | (char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) ) |
| 45 | #define EXT2_EXT_ATTR_SIZE(size) \ |
| 46 | (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND) |
| 47 | #define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL) |
| 48 | #define EXT2_EXT_ATTR_NAME(entry) \ |
| 49 | (((char *) (entry)) + sizeof(struct ext2_ext_attr_entry)) |
| 50 | #define EXT2_XATTR_LEN(name_len) \ |
| 51 | (((name_len) + EXT2_EXT_ATTR_ROUND + \ |
| 52 | sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND) |
| 53 | #define EXT2_XATTR_SIZE(size) \ |
| 54 | (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND) |
| 55 | |
| 56 | #ifdef __KERNEL__ |
| 57 | # ifdef CONFIG_EXT2_FS_EXT_ATTR |
| 58 | extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int); |
| 59 | extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int); |
| 60 | extern void ext2_ext_attr_free_inode(struct inode *inode); |
| 61 | extern void ext2_ext_attr_put_super(struct super_block *sb); |
| 62 | extern int ext2_ext_attr_init(void); |
| 63 | extern void ext2_ext_attr_done(void); |
| 64 | # else |
| 65 | # define ext2_get_ext_attr NULL |
| 66 | # define ext2_set_ext_attr NULL |
| 67 | # endif |
| 68 | #endif /* __KERNEL__ */ |
| 69 | |