Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
1e5d0136
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
大约 1 年 前同步成功
通知
455
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1e5d0136
编写于
7月 31, 2021
作者:
O
openharmony_ci
提交者:
Gitee
7月 31, 2021
浏览文件
操作
浏览文件
下载
差异文件
!394 fix apis: setrlimit,gethostname,gethostid
Merge pull request !394 from wcc/misc
上级
a7a25bb0
09d5bcc2
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
144 addition
and
6 deletion
+144
-6
compat/posix/src/misc.c
compat/posix/src/misc.c
+46
-0
kernel/base/include/los_process_pri.h
kernel/base/include/los_process_pri.h
+2
-0
security/cap/capability_type.h
security/cap/capability_type.h
+1
-1
syscall/los_syscall.h
syscall/los_syscall.h
+3
-0
syscall/misc_syscall.c
syscall/misc_syscall.c
+51
-0
syscall/syscall_lookup.h
syscall/syscall_lookup.h
+3
-0
testsuites/unittest/misc/BUILD.gn
testsuites/unittest/misc/BUILD.gn
+3
-3
testsuites/unittest/misc/full/misc_test_008.cpp
testsuites/unittest/misc/full/misc_test_008.cpp
+0
-0
testsuites/unittest/misc/full/misc_test_009.cpp
testsuites/unittest/misc/full/misc_test_009.cpp
+0
-0
testsuites/unittest/misc/misc_test.cpp
testsuites/unittest/misc/misc_test.cpp
+35
-2
未找到文件。
compat/posix/src/misc.c
浏览文件 @
1e5d0136
...
...
@@ -30,12 +30,14 @@
*/
#include "sys/types.h"
#include "sys/resource.h"
#include "unistd.h"
#include "stdio.h"
#include "pthread.h"
#include "sys/utsname.h"
#include "mqueue.h"
#include "semaphore.h"
#include "los_process_pri.h"
#include "los_hw.h"
/*
...
...
@@ -150,3 +152,47 @@ pid_t getpid(void)
return
((
LosTaskCB
*
)(
OsCurrTaskGet
()))
->
taskID
;
}
int
getrlimit
(
int
resource
,
struct
rlimit
*
rlim
)
{
LosProcessCB
*
pcb
=
OsCurrProcessGet
();
switch
(
resource
)
{
case
RLIMIT_NOFILE
:
case
RLIMIT_FSIZE
:
break
;
default:
return
-
EINVAL
;
}
rlim
->
rlim_cur
=
pcb
->
pl_rlimit
[
resource
].
rlim_cur
;
rlim
->
rlim_max
=
pcb
->
pl_rlimit
[
resource
].
rlim_max
;
return
0
;
}
#define FSIZE_RLIMIT 0XFFFFFFFF
int
setrlimit
(
int
resource
,
const
struct
rlimit
*
rlim
)
{
LosProcessCB
*
pcb
=
OsCurrProcessGet
();
if
(
rlim
->
rlim_cur
>
rlim
->
rlim_max
)
{
return
-
EINVAL
;
}
switch
(
resource
)
{
case
RLIMIT_NOFILE
:
if
(
rlim
->
rlim_max
>
NR_OPEN_DEFAULT
)
{
return
-
EPERM
;
}
break
;
case
RLIMIT_FSIZE
:
if
(
rlim
->
rlim_max
>
FSIZE_RLIMIT
)
{
return
-
EPERM
;
}
break
;
default:
return
-
EINVAL
;
}
pcb
->
pl_rlimit
[
resource
].
rlim_cur
=
rlim
->
rlim_cur
;
pcb
->
pl_rlimit
[
resource
].
rlim_max
=
rlim
->
rlim_max
;
return
0
;
}
\ No newline at end of file
kernel/base/include/los_process_pri.h
浏览文件 @
1e5d0136
...
...
@@ -45,6 +45,7 @@
#ifdef LOSCFG_SECURITY_VID
#include "vid_type.h"
#endif
#include "sys/resource.h"
#ifdef __cplusplus
#if __cplusplus
...
...
@@ -126,6 +127,7 @@ typedef struct ProcessCB {
#ifdef LOSCFG_KERNEL_CPUP
OsCpupBase
processCpup
;
/**< Process cpu usage */
#endif
struct
rlimit
pl_rlimit
[
RLIM_NLIMITS
];
}
LosProcessCB
;
#define CLONE_VM 0x00000100
...
...
security/cap/capability_type.h
浏览文件 @
1e5d0136
...
...
@@ -66,4 +66,4 @@
#define CAP_REBOOT 18
// self deined privileged syscalls
#define CAP_SHELL_EXEC 19
#endif
\ No newline at end of file
#endif
syscall/los_syscall.h
浏览文件 @
1e5d0136
...
...
@@ -296,5 +296,8 @@ extern int SysUmask(int mask);
extern
int
SysShellExec
(
const
char
*
msgName
,
const
char
*
cmdString
);
extern
int
SysReboot
(
int
magic
,
int
magic2
,
int
type
);
extern
int
SysGetrusage
(
int
what
,
struct
rusage
*
ru
);
extern
long
SysSysconf
(
int
name
);
extern
int
SysUgetrlimit
(
int
resource
,
unsigned
long
long
k_rlim
[
2
]);
extern
int
SysSetrlimit
(
int
resource
,
unsigned
long
long
k_rlim
[
2
]);
#endif
#endif
/* _LOS_SYSCALL_H */
syscall/misc_syscall.c
浏览文件 @
1e5d0136
...
...
@@ -44,6 +44,10 @@
#include "shmsg.h"
#endif
#include "user_copy.h"
#include "los_strncpy_from_user.h"
#include "capability_type.h"
#include "capability_api.h"
#include "unistd.h"
int
SysUname
(
struct
utsname
*
name
)
...
...
@@ -192,3 +196,50 @@ int SysGetrusage(int what, struct rusage *ru)
return
0
;
}
long
SysSysconf
(
int
name
)
{
long
ret
;
ret
=
sysconf
(
name
);
if
(
ret
==
-
1
)
{
return
-
get_errno
();
}
return
ret
;
}
int
SysUgetrlimit
(
int
resource
,
unsigned
long
long
k_rlim
[
2
])
{
int
ret
;
struct
rlimit
lim
;
ret
=
getrlimit
(
resource
,
&
lim
);
if
(
ret
<
0
)
{
return
ret
;
}
ret
=
LOS_ArchCopyToUser
(
k_rlim
,
&
lim
,
sizeof
(
struct
rlimit
));
if
(
ret
!=
0
)
{
return
-
EFAULT
;
}
return
ret
;
}
int
SysSetrlimit
(
int
resource
,
unsigned
long
long
k_rlim
[
2
])
{
int
ret
;
struct
rlimit
lim
;
if
(
!
IsCapPermit
(
CAP_CAPSET
))
{
return
-
EPERM
;
}
ret
=
LOS_ArchCopyFromUser
(
&
lim
,
k_rlim
,
sizeof
(
struct
rlimit
));
if
(
ret
!=
0
)
{
return
-
EFAULT
;
}
ret
=
setrlimit
(
resource
,
&
lim
);
return
ret
;
}
syscall/syscall_lookup.h
浏览文件 @
1e5d0136
...
...
@@ -253,3 +253,6 @@ SYSCALL_HAND_DEF(__NR_pthread_join, SysThreadJoin, int, ARG_NUM_1)
SYSCALL_HAND_DEF
(
__NR_pthread_deatch
,
SysUserThreadDetach
,
int
,
ARG_NUM_1
)
SYSCALL_HAND_DEF
(
__NR_creat_user_thread
,
SysCreateUserThread
,
unsigned
int
,
ARG_NUM_3
)
SYSCALL_HAND_DEF
(
__NR_getrusage
,
SysGetrusage
,
int
,
ARG_NUM_2
)
SYSCALL_HAND_DEF
(
__NR_sysconf
,
SysSysconf
,
long
,
ARG_NUM_1
)
SYSCALL_HAND_DEF
(
__NR_ugetrlimit
,
SysUgetrlimit
,
int
,
ARG_NUM_2
)
SYSCALL_HAND_DEF
(
__NR_setrlimit
,
SysSetrlimit
,
int
,
ARG_NUM_2
)
\ No newline at end of file
testsuites/unittest/misc/BUILD.gn
浏览文件 @
1e5d0136
...
...
@@ -44,6 +44,8 @@ sources_entry = [
sources_full = [
"full/misc_test_006.cpp",
"full/misc_test_007.cpp",
"full/misc_test_008.cpp",
"full/misc_test_009.cpp",
"full/misc_test_010.cpp",
"full/misc_test_011.cpp",
"full/misc_test_012.cpp",
...
...
@@ -56,8 +58,6 @@ sources_smoke = [
"smoke/misc_test_003.cpp",
"smoke/misc_test_004.cpp",
"smoke/misc_test_005.cpp",
"smoke/misc_test_008.cpp",
"smoke/misc_test_009.cpp",
"smoke/misc_test_014.cpp",
]
...
...
@@ -86,4 +86,4 @@ if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
configs = [ "..:public_config_for_all" ]
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
}
}
\ No newline at end of file
}
testsuites/unittest/misc/
smoke
/misc_test_008.cpp
→
testsuites/unittest/misc/
full
/misc_test_008.cpp
浏览文件 @
1e5d0136
文件已移动
testsuites/unittest/misc/
smoke
/misc_test_009.cpp
→
testsuites/unittest/misc/
full
/misc_test_009.cpp
浏览文件 @
1e5d0136
文件已移动
testsuites/unittest/misc/misc_test.cpp
浏览文件 @
1e5d0136
...
...
@@ -128,10 +128,32 @@ HWTEST_F(MiscTest, ItTestMisc006, TestSize.Level0)
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
/*
HWTEST_F(MiscTest, ItTestMisc007, TestSize.Level0)
HWTEST_F
(
MiscTest
,
ItTestMisc007
,
TestSize
.
Level0
)
{
ItTestMisc007
();
}*/
}
/* *
* @tc.name: IT_TEST_MISC_008
* @tc.desc: function for MiscTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
MiscTest
,
ItTestMisc008
,
TestSize
.
Level0
)
{
ItTestMisc008
();
}
/* *
* @tc.name: IT_TEST_MISC_009
* @tc.desc: function for MiscTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
MiscTest
,
ItTestMisc009
,
TestSize
.
Level0
)
{
ItTestMisc009
();
}
/* *
* @tc.name: IT_TEST_MISC_010
...
...
@@ -155,6 +177,17 @@ HWTEST_F(MiscTest, ItTestMisc006, TestSize.Level0)
ItTestMisc011();
}*/
/* *
* @tc.name: IT_TEST_MISC_012
* @tc.desc: function for MiscTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
MiscTest
,
ItTestMisc012
,
TestSize
.
Level0
)
{
ItTestMisc012
();
}
/* *
* @tc.name: IT_TEST_MISC_013
* @tc.desc: function for MiscTest
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录