blob: 0f323fdcbccf63cc3d7be6f38c000b249908ccae [file] [log] [blame]
Stephen Smalleyb4eca4b2012-01-13 09:00:56 -05001#include <sys/types.h>
2
Nick Kralevich4df62f32013-02-07 14:21:34 -08003#ifndef _SYSTEM_EXTRAS_EXT4_UTILS_XATTR_H
4#define _SYSTEM_EXTRAS_EXT4_UTILS_XATTR_H 1
5
Stephen Smalleyb4eca4b2012-01-13 09:00:56 -05006#define EXT4_XATTR_MAGIC 0xEA020000
7#define EXT4_XATTR_INDEX_SECURITY 6
8
Nick Kralevich4df62f32013-02-07 14:21:34 -08009struct ext4_xattr_header {
10 __le32 h_magic;
11 __le32 h_refcount;
12 __le32 h_blocks;
13 __le32 h_hash;
14 __le32 h_checksum;
15 __u32 h_reserved[3];
16};
17
18struct ext4_xattr_ibody_header {
19 __le32 h_magic;
20};
21
Stephen Smalleyb4eca4b2012-01-13 09:00:56 -050022struct ext4_xattr_entry {
23 __u8 e_name_len;
24 __u8 e_name_index;
25 __le16 e_value_offs;
26 __le32 e_value_block;
27 __le32 e_value_size;
28 __le32 e_hash;
29 char e_name[0];
30};
31
32#define EXT4_XATTR_PAD_BITS 2
33#define EXT4_XATTR_PAD (1<<EXT4_XATTR_PAD_BITS)
34#define EXT4_XATTR_ROUND (EXT4_XATTR_PAD-1)
35#define EXT4_XATTR_LEN(name_len) \
36 (((name_len) + EXT4_XATTR_ROUND + \
37 sizeof(struct ext4_xattr_entry)) & ~EXT4_XATTR_ROUND)
Nick Kralevich4df62f32013-02-07 14:21:34 -080038#define EXT4_XATTR_NEXT(entry) \
39 ((struct ext4_xattr_entry *)( \
40 (char *)(entry) + EXT4_XATTR_LEN((entry)->e_name_len)))
Stephen Smalleyb4eca4b2012-01-13 09:00:56 -050041#define EXT4_XATTR_SIZE(size) \
42 (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND)
Colin Cross7900c772014-01-23 12:53:30 -080043#define IS_LAST_ENTRY(entry) (*(uint32_t *)(entry) == 0)
Nick Kralevich4df62f32013-02-07 14:21:34 -080044
45#endif /* !_SYSTEM_EXTRAS_EXT4_UTILS_XATTR_H */