Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 11: Extended Attributes and Access Control Lists


Figure 11-4 presents an overview of the on-disk layout of Ext3 extended attributes.


ext3_xattr_entry

struct ext3_xattr_entry
e_value_offs

He Attribute value
a
d
e
r

Figure 11-4: Overview of the on-disk format for extended attributes in the Ext3 filesystem.

The space consumed by the extended attributes startswith a short identification header followed by a list
of entry elements. Each holds the attribute name and a pointer to the region where the associated value
is stored. The list grows downward when new extended attributes are added to the file.


The values are stored at the end of the extended attribute data space; the value table grows in the opposite
direction of the attribute name table. The values will, in general, not be sorted in the same order as the
names, but can be in any arbitrary order.


A structure of this kind can be found in two places:


❑ The unused space at the end of the inode.
❑ A separate data block somewhere on the disk.

The first alternative is only possible if the new filesystem format with dynamic inode sizes is used (i.e.,
EXT3_DYNAMIC_REV);theamountoffreespaceisstoredinext3_inode_info->i_extra_isize.Bothalter-
natives can be used together, but the total size of all extended attribute headers and values is still limited
to the sum of the space of a single block and the free space in the inode. It is not possible to use more than
one additional block to store extended attributes. In practice, the space required will usually be much less
than a complete disk block.


Note that it is possible for two files with identical sets of extended attributes to share the on-disk repre-
sentation; this helps to save some disk space.


How do the data structures that implement this layout look? The header is defined as follows:


fs/ext3/xattr.h
struct ext3_xattr_header {
__le32 h_magic; /* magic number for identification */
__le32 h_refcount; /* reference count */
__le32 h_blocks; /* number of disk blocks used */
__le32 h_hash; /* hash value of all attributes */
__u32 h_reserved[4]; /* zero right now */
};
Free download pdf