]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blob - lib/ext2fs/ext2_ext_attr.h
Merge remote-tracking branch 'josch/libarchive' into josch-libarchive
[thirdparty/e2fsprogs.git] / lib / ext2fs / ext2_ext_attr.h
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 #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_checksum; /* crc32c(uuid+id+xattrs) */
24 /* id = inum if refcount = 1, else blknum */
25 __u32 h_reserved[3]; /* zero right now */
26 };
27
28 struct ext2_ext_attr_entry {
29 __u8 e_name_len; /* length of name */
30 __u8 e_name_index; /* attribute name index */
31 __u16 e_value_offs; /* offset in disk block of value */
32 __u32 e_value_inum; /* inode in which the value is stored */
33 __u32 e_value_size; /* size of attribute value */
34 __u32 e_hash; /* hash value of name and value */
35 #if 0
36 char e_name[0]; /* attribute name */
37 #endif
38 };
39
40 #define EXT2_EXT_ATTR_PAD_BITS 2
41 #define EXT2_EXT_ATTR_PAD ((unsigned) 1<<EXT2_EXT_ATTR_PAD_BITS)
42 #define EXT2_EXT_ATTR_ROUND (EXT2_EXT_ATTR_PAD-1)
43 #define EXT2_EXT_ATTR_LEN(name_len) \
44 (((name_len) + EXT2_EXT_ATTR_ROUND + \
45 sizeof(struct ext2_ext_attr_entry)) & ~EXT2_EXT_ATTR_ROUND)
46 #define EXT2_EXT_ATTR_NEXT(entry) \
47 ( (struct ext2_ext_attr_entry *)( \
48 (char *)(entry) + EXT2_EXT_ATTR_LEN((entry)->e_name_len)) )
49 #define EXT2_EXT_ATTR_SIZE(size) \
50 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
51 #define EXT2_EXT_IS_LAST_ENTRY(entry) (*((__u32 *)(entry)) == 0UL)
52 #define EXT2_EXT_ATTR_NAME(entry) \
53 (((char *) (entry)) + sizeof(struct ext2_ext_attr_entry))
54 #define EXT2_XATTR_LEN(name_len) \
55 (((name_len) + EXT2_EXT_ATTR_ROUND + \
56 sizeof(struct ext2_xattr_entry)) & ~EXT2_EXT_ATTR_ROUND)
57 #define EXT2_XATTR_SIZE(size) \
58 (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
59
60 /*
61 * XATTR_SIZE_MAX is currently 64k, but for the purposes of checking
62 * for file system consistency errors, we use a somewhat bigger value.
63 * This allows XATTR_SIZE_MAX to grow in the future, but by using this
64 * instead of INT_MAX for certain consistency checks, we don't need to
65 * worry about arithmetic overflows. (Actually XATTR_SIZE_MAX is
66 * defined in include/uapi/linux/limits.h, so changing it is going
67 * not going to be trivial....)
68 */
69 #define EXT2_XATTR_SIZE_MAX (1 << 24)
70
71 #ifdef __KERNEL__
72 # ifdef CONFIG_EXT2_FS_EXT_ATTR
73 extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
74 extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
75 extern void ext2_ext_attr_free_inode(struct inode *inode);
76 extern void ext2_ext_attr_put_super(struct super_block *sb);
77 extern int ext2_ext_attr_init(void);
78 extern void ext2_ext_attr_done(void);
79 # else
80 # define ext2_get_ext_attr NULL
81 # define ext2_set_ext_attr NULL
82 # endif
83 #endif /* __KERNEL__ */
84 #endif /* _EXT2_EXT_ATTR_H */