更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
vfs_chattr.c 文件参考

浏览源代码.

函数

int chattr (const char *pathname, struct IATTR *attr)
 

函数说明

◆ chattr()

int chattr ( const char *  pathname,
struct IATTR attr 
)

在文件 vfs_chattr.c58 行定义.

59{
60 struct Vnode *vnode = NULL;
61 int ret;
62
63 if (pathname == NULL || attr == NULL) {
64 set_errno(EINVAL);
65 return VFS_ERROR;
66 }
67
68 VnodeHold();
69 ret = VnodeLookup(pathname, &vnode, 0);
70 if (ret != LOS_OK) {
71 goto errout_with_lock;
72 }
73
74 if ((vnode->originMount) && (vnode->originMount->mountFlags & MS_RDONLY)) {
75 ret = -EROFS;
76 goto errout_with_lock;
77 }
78
79 /* The way we handle the stat depends on the type of vnode that we
80 * are dealing with.
81 */
82
83 if (vnode->vop != NULL && vnode->vop->Chattr != NULL) {
84 ret = vnode->vop->Chattr(vnode, attr);
85 } else {
86 ret = -ENOSYS;
87 }
88 VnodeDrop();
89
90 if (ret < 0) {
91 goto errout;
92 }
93
94 return OK;
95
96 /* Failure conditions always set the errno appropriately */
97
98errout_with_lock:
99 VnodeDrop();
100errout:
101 set_errno(-ret);
102 return VFS_ERROR;
103}
unsigned long mountFlags
Definition: mount.h:80
vnode并不包含文件名,因为 vnode和文件名是 1:N 的关系
Definition: vnode.h:164
struct VnodeOps * vop
Definition: vnode.h:174
struct Mount * originMount
Definition: vnode.h:180
int(* Chattr)(struct Vnode *vnode, struct IATTR *attr)
改变节点属性(change attr)
Definition: vnode.h:214
int VnodeDrop(void)
归还锁
Definition: vnode.c:292
int VnodeHold(void)
拿锁,封装互斥量
Definition: vnode.c:283
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags)
通过路径查询vnode节点
Definition: vnode.c:491
函数调用图:
这是这个函数的调用关系图: