Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
9304a683
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
468
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9304a683
编写于
7月 08, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 08, 2021
浏览文件
操作
浏览文件
下载
差异文件
!397 修复内核access chmod chown接口
Merge pull request !397 from JING/kernel
上级
78906f4a
56a95b9e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
49 deletion
+55
-49
fs/vfs/operation/fs_other.c
fs/vfs/operation/fs_other.c
+51
-9
syscall/fs_syscall.c
syscall/fs_syscall.c
+4
-40
未找到文件。
fs/vfs/operation/fs_other.c
浏览文件 @
9304a683
...
...
@@ -35,7 +35,9 @@
#include "dirent.h"
#include "unistd.h"
#include "sys/select.h"
#include "sys/mount.h"
#include "sys/stat.h"
#include "sys/statfs.h"
#include "sys/prctl.h"
#include "fs/fd_table.h"
#include "fs/file.h"
...
...
@@ -256,30 +258,70 @@ char *getcwd(char *buf, size_t n)
int
chmod
(
const
char
*
path
,
mode_t
mode
)
{
int
result
;
struct
stat
buf
;
struct
IATTR
attr
=
{
0
};
attr
.
attr_chg_mode
=
mode
;
attr
.
attr_chg_valid
=
CHG_MODE
;
/* change mode */
int
ret
;
result
=
stat
(
path
,
&
buf
);
if
(
result
!=
ENOERR
)
{
ret
=
chattr
(
path
,
&
attr
);
if
(
ret
<
0
)
{
return
VFS_ERROR
;
}
return
OK
;
}
int
chown
(
const
char
*
pathname
,
uid_t
owner
,
gid_t
group
)
{
struct
IATTR
attr
=
{
0
};
attr
.
attr_chg_valid
=
0
;
int
ret
;
if
(
owner
!=
(
uid_t
)
-
1
)
{
attr
.
attr_chg_uid
=
owner
;
attr
.
attr_chg_valid
|=
CHG_UID
;
}
if
(
group
!=
(
gid_t
)
-
1
)
{
attr
.
attr_chg_gid
=
group
;
attr
.
attr_chg_valid
|=
CHG_GID
;
}
ret
=
chattr
(
pathname
,
&
attr
);
if
(
ret
<
0
)
{
return
VFS_ERROR
;
}
/* no access/permission control for files now, just return OK if stat is okay*/
return
OK
;
}
int
access
(
const
char
*
path
,
int
amode
)
{
int
re
sul
t
;
int
ret
;
struct
stat
buf
;
struct
statfs
fsBuf
;
result
=
stat
(
path
,
&
buf
);
ret
=
statfs
(
path
,
&
fsBuf
);
if
(
ret
!=
0
)
{
if
(
get_errno
()
!=
ENOSYS
)
{
return
VFS_ERROR
;
}
/* dev has no statfs ops, need devfs to handle this in feature */
}
if
(
result
!=
ENOERR
)
{
if
((
fsBuf
.
f_flags
&
MS_RDONLY
)
&&
((
unsigned
int
)
amode
&
W_OK
))
{
set_errno
(
EROFS
);
return
VFS_ERROR
;
}
ret
=
stat
(
path
,
&
buf
);
if
(
ret
!=
0
)
{
return
VFS_ERROR
;
}
if
(
VfsPermissionCheck
(
buf
.
st_uid
,
buf
.
st_gid
,
buf
.
st_mode
,
amode
))
{
set_errno
(
EACCES
);
return
VFS_ERROR
;
}
/* no access/permission control for files now, just return OK if stat is okay*/
return
OK
;
}
...
...
syscall/fs_syscall.c
浏览文件 @
9304a683
...
...
@@ -703,8 +703,6 @@ OUT:
int
SysAccess
(
const
char
*
path
,
int
amode
)
{
int
ret
;
struct
stat
buf
;
struct
statfs
fsBuf
;
char
*
pathRet
=
NULL
;
if
(
path
!=
NULL
)
{
...
...
@@ -714,30 +712,9 @@ int SysAccess(const char *path, int amode)
}
}
ret
=
statfs
((
path
?
pathRet
:
NULL
),
&
fsBuf
);
if
(
ret
!=
0
)
{
ret
=
-
get_errno
();
if
(
ret
!=
-
ENOSYS
)
{
goto
OUT
;
}
else
{
/* dev has no statfs ops, need devfs to handle this in feature */
ret
=
LOS_OK
;
}
}
if
((
fsBuf
.
f_flags
&
MS_RDONLY
)
&&
((
unsigned
int
)
amode
&
W_OK
))
{
ret
=
-
EROFS
;
goto
OUT
;
}
ret
=
stat
((
path
?
pathRet
:
NULL
),
&
buf
);
if
(
ret
!=
0
)
{
ret
=
access
(
pathRet
,
amode
);
if
(
ret
<
0
)
{
ret
=
-
get_errno
();
goto
OUT
;
}
if
(
VfsPermissionCheck
(
buf
.
st_uid
,
buf
.
st_gid
,
buf
.
st_mode
,
amode
))
{
ret
=
-
EACCES
;
}
OUT:
...
...
@@ -2149,9 +2126,6 @@ OUT:
int
SysChmod
(
const
char
*
pathname
,
mode_t
mode
)
{
struct
IATTR
attr
=
{
0
};
attr
.
attr_chg_mode
=
mode
;
attr
.
attr_chg_valid
=
CHG_MODE
;
/* change mode */
int
ret
;
char
*
pathRet
=
NULL
;
...
...
@@ -2162,7 +2136,7 @@ int SysChmod(const char *pathname, mode_t mode)
}
}
ret
=
ch
attr
((
pathname
?
pathRet
:
NULL
),
&
attr
);
ret
=
ch
mod
(
pathRet
,
mode
);
if
(
ret
<
0
)
{
ret
=
-
get_errno
();
}
...
...
@@ -2176,8 +2150,6 @@ OUT:
int
SysChown
(
const
char
*
pathname
,
uid_t
owner
,
gid_t
group
)
{
struct
IATTR
attr
=
{
0
};
attr
.
attr_chg_valid
=
0
;
int
ret
;
char
*
pathRet
=
NULL
;
...
...
@@ -2188,15 +2160,7 @@ int SysChown(const char *pathname, uid_t owner, gid_t group)
}
}
if
(
owner
!=
(
uid_t
)
-
1
)
{
attr
.
attr_chg_uid
=
owner
;
attr
.
attr_chg_valid
|=
CHG_UID
;
}
if
(
group
!=
(
gid_t
)
-
1
)
{
attr
.
attr_chg_gid
=
group
;
attr
.
attr_chg_valid
|=
CHG_GID
;
}
ret
=
chattr
((
pathname
?
pathRet
:
NULL
),
&
attr
);
ret
=
chown
(
pathRet
,
owner
,
group
);
if
(
ret
<
0
)
{
ret
=
-
get_errno
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录