• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef __KERNEL__
61 # ifdef CONFIG_EXT2_FS_EXT_ATTR
62 extern int ext2_get_ext_attr(struct inode *, const char *, char *, size_t, int);
63 extern int ext2_set_ext_attr(struct inode *, const char *, char *, size_t, int);
64 extern void ext2_ext_attr_free_inode(struct inode *inode);
65 extern void ext2_ext_attr_put_super(struct super_block *sb);
66 extern int ext2_ext_attr_init(void);
67 extern void ext2_ext_attr_done(void);
68 # else
69 #  define ext2_get_ext_attr NULL
70 #  define ext2_set_ext_attr NULL
71 # endif
72 #endif  /* __KERNEL__ */
73 #endif  /* _EXT2_EXT_ATTR_H */
74