Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
15c4de23
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
大约 1 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
15c4de23
编写于
9月 19, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1251 codex
Merge pull request !1251 from cheng_jinsong/codex
上级
4751c44a
91ae408d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
36 addition
and
32 deletion
+36
-32
scripts/param_cfg_to_code.py
scripts/param_cfg_to_code.py
+24
-17
services/begetctl/sandbox.cpp
services/begetctl/sandbox.cpp
+1
-1
services/init/standard/switch_root.c
services/init/standard/switch_root.c
+2
-8
services/modules/seccomp/seccomp_policy.c
services/modules/seccomp/seccomp_policy.c
+4
-2
test/exec_test/fd_holder_test.c
test/exec_test/fd_holder_test.c
+3
-2
ueventd/standard/ueventd_parameter.c
ueventd/standard/ueventd_parameter.c
+1
-1
ueventd/ueventd.c
ueventd/ueventd.c
+1
-1
未找到文件。
scripts/param_cfg_to_code.py
浏览文件 @
15c4de23
...
...
@@ -20,6 +20,7 @@ import argparse
import
os
import
sys
def
decode_cfg_line
(
data
):
data
.
replace
(
'
\n
'
,
''
).
replace
(
'
\r
'
,
''
)
data
=
data
.
strip
()
...
...
@@ -30,17 +31,19 @@ def decode_cfg_line(data):
return
""
,
""
return
strs
[
0
].
strip
(),
strs
[
1
].
strip
()
def
get_param_from_cfg
(
cfg_name
):
dict
=
{}
d
ata_d
ict
=
{}
with
open
(
cfg_name
)
as
afile
:
data
=
afile
.
readline
()
while
data
:
name
,
value
=
decode_cfg_line
(
data
)
if
len
(
name
)
!=
0
and
len
(
value
)
!=
0
:
dict
[
name
]
=
value
print
(
"sample file name={%s %s}"
%
(
name
,
value
))
d
ata_d
ict
[
name
]
=
value
print
(
"sample file name={%s %s}"
%
(
name
,
value
))
data
=
afile
.
readline
()
return
dict
return
data_dict
def
decode_code_line
(
data
):
data
.
replace
(
'
\n
'
,
''
).
replace
(
'
\r
'
,
''
)
...
...
@@ -53,21 +56,23 @@ def decode_code_line(data):
strs
=
data
.
split
(
','
)
if
len
(
strs
)
<=
1
:
return
""
,
""
return
strs
[
0
].
strip
(),
data
[
len
(
strs
[
0
])
+
1
:
].
strip
()
return
strs
[
0
].
strip
(),
data
[
len
(
strs
[
0
])
+
1
:].
strip
()
def
get_param_from_c_code
(
code_name
):
dict
=
{}
d
ata_d
ict
=
{}
with
open
(
code_name
,
"r+"
)
as
afile
:
data
=
afile
.
readline
()
while
data
:
name
,
value
=
decode_code_line
(
data
)
if
len
(
name
)
!=
0
and
len
(
value
)
!=
0
:
dict
[
name
]
=
value
d
ata_d
ict
[
name
]
=
value
data
=
afile
.
readline
()
afile
.
truncate
(
0
)
return
dict
return
d
ata_d
ict
def
write_map_to_code
(
code_name
,
dict
):
def
write_map_to_code
(
code_name
,
data_dict
):
try
:
with
open
(
code_name
,
"w"
)
as
f
:
# start with 0
...
...
@@ -91,13 +96,13 @@ def write_map_to_code(code_name, dict):
f
.
write
(
os
.
linesep
+
os
.
linesep
)
# write data
f
.
write
(
'static Node g_paramDefCfgNodes[] = {'
+
os
.
linesep
)
for
name
,
value
in
dict
.
items
():
for
name
,
value
in
d
ata_d
ict
.
items
():
if
(
value
.
startswith
(
"
\"
"
)):
str
=
" PARAM_MAP({0}, {1})"
.
format
(
name
,
value
)
f
.
write
(
str
+
os
.
linesep
)
tmp_
str
=
" PARAM_MAP({0}, {1})"
.
format
(
name
,
value
)
f
.
write
(
tmp_
str
+
os
.
linesep
)
else
:
str
=
" PARAM_MAP({0},
\"
{1}
\"
)"
.
format
(
name
,
value
)
f
.
write
(
str
+
os
.
linesep
)
tmp_
str
=
" PARAM_MAP({0},
\"
{1}
\"
)"
.
format
(
name
,
value
)
f
.
write
(
tmp_
str
+
os
.
linesep
)
f
.
write
(
'};'
+
os
.
linesep
+
os
.
linesep
)
#end
...
...
@@ -110,19 +115,21 @@ def write_map_to_code(code_name, dict):
f
.
write
(
os
.
linesep
)
f
.
truncate
()
except
IOError
:
print
(
"Error: open or write file %s fail"
%
{
code_name
})
print
(
"Error: open or write file %s fail"
%
{
code_name
})
return
0
def
add_to_code_dict
(
code_dict
,
cfg_dict
,
high
=
True
):
def
add_to_code_dict
(
code_dict
,
cfg_dict
,
high
=
True
):
for
name
,
value
in
cfg_dict
.
items
():
# check if name exit
has_key
=
name
in
code_dict
#code_dict.has_key(name)
has_key
=
name
in
code_dict
if
has_key
and
high
:
code_dict
[
name
]
=
value
elif
not
has_key
:
code_dict
[
name
]
=
value
return
code_dict
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'A common change param.para file to h.'
)
...
...
services/begetctl/sandbox.cpp
浏览文件 @
15c4de23
...
...
@@ -74,7 +74,7 @@ static void RunSandbox(const std::string &sandboxName)
static
void
EnterShell
()
{
char
*
argv
[]
=
{
const_cast
<
char
*>
(
"sh"
),
NULL
};
char
*
argv
[]
=
{
const_cast
<
char
*>
(
"sh"
),
nullptr
};
char
*
envp
[]
=
{
nullptr
};
if
(
execve
(
"/system/bin/sh"
,
argv
,
envp
)
!=
0
)
{
std
::
cout
<<
"execve sh failed! err = "
<<
errno
<<
std
::
endl
;
...
...
services/init/standard/switch_root.c
浏览文件 @
15c4de23
...
...
@@ -153,15 +153,9 @@ int SwitchRoot(const char *newRoot)
}
struct
stat
oldRootStat
=
{};
if
(
stat
(
"/"
,
&
oldRootStat
)
!=
0
)
{
INIT_LOGE
(
"Failed to get old root
\"
/
\"
stat"
);
return
-
1
;
}
INIT_ERROR_CHECK
(
stat
(
"/"
,
&
oldRootStat
)
==
0
,
return
-
1
,
"Failed to get old root
\"
/
\"
stat"
);
DIR
*
oldRoot
=
opendir
(
"/"
);
if
(
oldRoot
==
NULL
)
{
INIT_LOGE
(
"Failed to open root dir
\"
/
\"
"
);
return
-
1
;
}
INIT_ERROR_CHECK
(
oldRoot
!=
NULL
,
return
-
1
,
"Failed to open root dir
\"
/
\"
"
);
struct
stat
newRootStat
=
{};
if
(
stat
(
newRoot
,
&
newRootStat
)
!=
0
)
{
INIT_LOGE
(
"Failed to get new root
\"
%s
\"
stat"
,
newRoot
);
...
...
services/modules/seccomp/seccomp_policy.c
浏览文件 @
15c4de23
...
...
@@ -91,9 +91,11 @@ bool SetSeccompPolicyWithName(const char *filterName)
strlen
(
filterName
)
+
strlen
(
FILTER_NAME_FORMAT
)
-
strlen
(
"%s"
),
\
FILTER_NAME_FORMAT
,
filterName
);
PLUGIN_CHECK
(
rc
!=
-
1
,
return
false
,
"snprintf_s faiVribleName failed"
);
const
char
*
filterLibRealPath
=
realpath
(
filterLibPath
,
NULL
);
PLUGIN_CHECK
(
filterLibRealPath
!=
NULL
,
return
false
,
"format filter lib real path failed"
);
void
*
handler
=
dlopen
(
filterLibPath
,
RTLD_LAZY
);
PLUGIN_CHECK
(
handler
!=
NULL
,
return
false
,
"dlopen %s failed"
,
filterLibPath
);
void
*
handler
=
dlopen
(
filterLib
Real
Path
,
RTLD_LAZY
);
PLUGIN_CHECK
(
handler
!=
NULL
,
return
false
,
"dlopen %s failed"
,
filterLib
Real
Path
);
filterPtr
=
(
struct
sock_filter
*
)
dlsym
(
handler
,
filterVaribleName
);
PLUGIN_CHECK
(
filterPtr
!=
NULL
,
dlclose
(
handler
);
...
...
test/exec_test/fd_holder_test.c
浏览文件 @
15c4de23
...
...
@@ -23,6 +23,7 @@
#define BUFFER_LENGTH 5
#define FD_COUNT 2
#define SLEEP_TIME 3
#define ENV_FD_HOLD_PREFIX "OHOS_FD_HOLD_"
static
void
SaveFds
(
const
char
*
serviceName
,
int
argc
,
char
**
argv
)
...
...
@@ -70,13 +71,13 @@ int main(int argc, char **argv)
free
(
fds
);
outfdCount
=
0
;
while
(
1
)
{
sleep
(
3
);
sleep
(
SLEEP_TIME
);
}
}
char
*
files
[]
=
{
"/data/test/1"
,
"/data/test/2"
};
SaveFds
(
"fd_holder_test"
,
FD_COUNT
,
(
char
**
)
files
);
while
(
1
)
{
sleep
(
3
);
sleep
(
SLEEP_TIME
);
}
return
0
;
}
ueventd/standard/ueventd_parameter.c
浏览文件 @
15c4de23
...
...
@@ -90,7 +90,7 @@ static void *ThreadRun(void *data)
parameterCtrl
->
empty
=
0
;
const
char
*
paramValue
=
(
config
->
action
==
ACTION_ADD
)
?
"added"
:
"removed"
;
INIT_LOGI
(
"[uevent] SystemSetParameter %s act %s"
,
config
->
parameter
,
paramValue
);
size_
t
len
=
sprintf_s
(
paramName
,
sizeof
(
paramName
),
"startup.uevent.%s"
,
config
->
parameter
);
in
t
len
=
sprintf_s
(
paramName
,
sizeof
(
paramName
),
"startup.uevent.%s"
,
config
->
parameter
);
if
((
len
<=
0
)
||
(
SystemSetParameter
(
paramName
,
paramValue
)
!=
0
))
{
INIT_LOGE
(
"[uevent] SystemSetParameter %s failed"
,
config
->
parameter
);
pthread_mutex_lock
(
&
(
parameterCtrl
->
parameterLock
));
...
...
ueventd/ueventd.c
浏览文件 @
15c4de23
...
...
@@ -148,7 +148,7 @@ static void HandleRequiredDynamicDeviceNodes(const struct Uevent *uevent)
return
;
}
while
(
idx
<
sizeof
(
DYNAMIC_DEVICES
)
/
sizeof
(
DYNAMIC_DEVICES
[
0
]))
{
while
(
idx
<
sizeof
(
DYNAMIC_DEVICES
)
/
sizeof
(
DYNAMIC_DEVICES
[
0
]))
{
if
(
strcmp
(
uevent
->
deviceName
,
DYNAMIC_DEVICES
[
idx
].
dev
+
DEV_NODE_PATH_PREFIX_LEN
)
!=
0
)
{
idx
++
;
continue
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录