首页 存档 技术 查看内容

Linux自主访问控制机制模块之详细描述-函数实现机制(3)

2018-3-30 13:00 |来自: 互联网 378 0

摘要: ext4_xattr_ibody_set()函数定义fs/ext4/xattr.c中,函数头如下所示: static int ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,struct ext4_xattr_info*i,struct ext4_xattr_ibody_find*is) 该函 ...

ext4_xattr_ibody_set()函数定义fs/ext4/xattr.c中,函数头如下所示:


static int ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,struct ext4_xattr_info*i,struct ext4_xattr_ibody_find*is)


该函数包含4个参数:handle表示用于日志处理的原子更新操作;inode表示用于设置的目标文件;i表示要设置的扩展属性的相关信息;is表示存放在目标文件索引节点空闲空间内的扩展属性的相关信息


图2-14 ext4_xattr_ibody_set()函数调用流程图

如图2-14所示,该函数的核心操作主要是通过ext4_xattr_set_entry()函数实现的。对于ext4_xattr_set_entry()函数,它用于具体的实现属性值的设置操作,该函数只不过是对扩展属性列表的修改操作,主要针对扩展属性项数据结构ext4_xattr_entry进行,因此这里不对其进行详细分析。对于ext4_xattr_block_set()函数,其实现和ext4_xattr_ibody_set()函数相似,因此这里不再赘述。

ACL在VFS中的实现

在Linux中,ACL是根据POSIX标准实现的,其数据结构和POSIX标准规定的数据结构相同,并且定义了若干与ACL相关的操作,下面分别进行介绍

POSIX标准中的ACL

在POSIX标准中,用posix_acl结构体来表示一个文件的ACL属性,其定义在include/linux/posix_acl.h中,具体定义如下所示:


structposix_acl {

union {

atomic_t a_refcount;

struct rcu_head a_rcu;

};

unsigned int a_count;

struct posix_acl_entry a_entries[0];

};


对于该结构体,各重要字段含义如表2-3所示:


表2-3 posix_acl中重要字段的含义

类型

字段

含义

atomic_t

a_refcount

表示该ACL的引用计数

unsigned int

a_count

访问控制列表中的访问控制列表项的数量

struct posix_acl_entry

a_entries

指向具体访问控制列表项的数组


如上表所示,a_entries变量存放了ACL中的表项,在POSIX标准中,访问控制列表表项用posix_acl_entry结构体表示,具体定义如下所示:


struct posix_acl_entry{

short e_tag;

unsigned short e_perm;

unsigned int e_id;

};




声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

相关分类

返回顶部