Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 11: Extended Attributes and Access Control Lists


the field is not relevant right now, it will become important should an incompatible future version be
developed.

The in-memory representation of every Ext3 inode is augmented with two fields that are relevant for the
ACL implementation:

<ext3_fs_i.h>
struct ext3_inode_info {
...
#ifdef CONFIG_EXT3_FS_POSIX_ACL
struct posix_acl *i_acl;
struct posix_acl *i_default_acl;
#endif
...
}

Whilei_aclpoints to theposix_aclinstance for a regular ACL list associated with an inode,
i_default_aclpoints to the default ACL that may be associated with a directory and is inherited
by subdirectories. Since all information is storedin extended attributes on disk, no extension of the
disk-basedstruct ext3_inodeis necessary.

Note that the kernel does not automatically construct the ACL information for every inode; if the infor-
mation is not present in memory, the fields are set toEXT3_ACL_NOT_CACHED[defined as(void*)-1].

ConversionbetweenOn-Diskand In-MemoryRepresentation


Two conversion functions are available to switch between the on-disk and the in-memory representation:
ext3_acl_to_diskandext3_acl_from_disk. Both are implemented infs/ext3/acl.c.

The latter one takes the raw data as read from the information contained in the extended inode, strips off
the header, and converts the data from little endian format into a format suitable for the system’s CPU
for every entry in the list of ACLs.

The counterpartext3_acl_to_diskworks similarly: It iterates over all entries of a given instance of
posix_acland converts the contained data from the CPU-specific format to little endian numbers with
appropriate lengths.

InodeInitialization


When a new inode is created withext3_new_inode, the initialization of the ACLs is delegated to
ext3_init_acl. In addition to the transaction handle and the instance ofstruct inodefor the new
inode, the function also expects a pointer to the inode of the directory in which the new entry is created:

fs/ext3/acl.c
int
ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
{
struct posix_acl *acl = NULL;
int error = 0;

if (!S_ISLNK(inode->i_mode)) {
Free download pdf