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 (at) computer.org> 7 */ 8 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 14 15 /* Maximum number of references to one attribute block */ 16 #define EXT2_EXT_ATTR_REFCOUNT_MAX 1024 17 18 struct ext2_ext_attr_header { 19 __u32 h_magic; /* magic number for identification */ 20 __u32 h_refcount; /* reference count */ 21 __u32 h_blocks; /* number of disk blocks used */ 22 __u32 h_hash; /* hash value of all attributes */ 23 __u32 h_reserved[4]; /* zero right now */ 24 }; 25 26 struct ext2_ext_attr_entry { 27 __u8 e_name_len; /* length of name */ 28 __u8 e_name_index; /* attribute name index */ 29 __u16 e_value_offs; /* offset in disk block of value */ 30 __u32 e_value_block; /* disk block attribute is stored on (n/i) */ 31 __u32 e_value_size; /* size of attribute value */ 32 __u32 e_hash; /* hash value of name and value */ 33 #if 0 34 char e_name[0]; /* attribute name */ 35 #endif 36 }; 37 38 #define EXT2_EXT_ATTR_PAD_BITS 2 39 #define EXT2_EXT_ATTR_PAD ((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS) 40 #define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1) 41 #define EXT2_EXT_ATTR_LEN(name_len) \ 42 (((name_len) + EXT2_EXT_ATTR_ROUND + \ 43 sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND) 44 #define EXT2_EXT_ATTR_NEXT(entry) \ 45 ( (struct ext2_ext_attr_entry *)( \ 46 (char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) ) 47 #define EXT2_EXT_ATTR_SIZE(size) \ 48 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND) 49 #define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL) 50 #define EXT2_EXT_ATTR_NAME(entry) \ 51 (((char *) (entry)) + sizeof(struct ext2_ext_attr_entry)) 52 #define EXT2_XATTR_LEN(name_len) \ 53 (((name_len) + EXT2_EXT_ATTR_ROUND + \ 54 sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND) 55 #define EXT2_XATTR_SIZE(size) \ 56 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND) 57 58 #ifdef __KERNEL__ 59 # ifdef CONFIG_EXT2_FS_EXT_ATTR 60 extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int); 61 extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int); 62 extern void ext2_ext_attr_free_inode(struct inode *inode); 63 extern void ext2_ext_attr_put_super(struct super_block *sb); 64 extern int ext2_ext_attr_init(void); 65 extern void ext2_ext_attr_done(void); 66 # else 67 # define ext2_get_ext_attr NULL 68 # define ext2_set_ext_attr NULL 69 # endif 70 #endif /* __KERNEL__ */ 71 #endif /* _EXT2_EXT_ATTR_H */ 72