提交 74e2ce14 编写于 作者: Yansira's avatar Yansira

fix: toybox ls命令查询nfs挂载路径报错问题

错误场景:
OHOS: mount -t nfs 192.168.1.1:/nfs nfs (cwd: /)
OHOS: ls /nfs (成功)
OHOS: ls nfs (成功)
OHOS: cd nfs
OHOS: ls (失败)

错误路径:
1. 以相对路径mount任意文件系统
2. open挂载点获得文件描述符fd
3. 通过fstat接口获取挂载点属性则会发生错误

错误根因:
1. 内核mount接口直接将入参target(挂载点)拷贝到Vnode的filePath字段,如果target为相对路径,则filePath为相对路径;
2. 打开挂载点时,Vnode的filePath直接赋值给文件接口提file的f_path字段;
3. 通过fstat接口查询挂载点属性,内核会调用get_path_from_fd接口获取file的f_path,再调用stat接口查询属性;
4. 由于此时f_path为相对路径,如果fstat时,进程的cwd与挂载时不一致,则导致查找目录失败。
Signed-off-by: NKiita <zhanyan@huawei.com>
Change-Id: I51a2b1e5a38702555adec5bd345e27f2d3eb74e4
上级 71d16da2
......@@ -296,7 +296,7 @@ int mount(const char *source, const char *target,
}
mnt->vnodeBeCovered->flag |= VNODE_FLAG_MOUNT_ORIGIN;
mnt->vnodeCovered->flag |= VNODE_FLAG_MOUNT_NEW;
mnt->vnodeCovered->filePath = strdup(target);
mnt->vnodeCovered->filePath = strdup(mountpt_vnode->filePath);
mnt->vnodeDev = device;
mnt->ops = mops;
if (target && (strlen(target) != 0))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册