Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
6638b7de
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,发现更多精彩内容 >>
提交
6638b7de
编写于
12月 15, 2021
作者:
O
openharmony_ci
提交者:
Gitee
12月 15, 2021
浏览文件
操作
浏览文件
下载
差异文件
!190 dayu200 add cmd (reboot loader)
Merge pull request !190 from yang_hongliang/master
上级
f7e72f9c
bac663dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
33 deletion
+61
-33
services/BUILD.gn
services/BUILD.gn
+4
-0
services/begetctl/BUILD.gn
services/begetctl/BUILD.gn
+16
-12
services/begetctl/init_cmd_reboot.c
services/begetctl/init_cmd_reboot.c
+12
-1
services/init/standard/init_reboot.c
services/init/standard/init_reboot.c
+29
-20
未找到文件。
services/BUILD.gn
浏览文件 @
6638b7de
...
...
@@ -155,6 +155,10 @@ if (defined(ohos_lite)) {
defines = [ "DISABLE_INIT_TWO_STAGES" ]
}
if (defined(product_name) && product_name == "rk3568") {
defines += [ "PRODUCT_RK" ]
}
install_images = [
"system",
"updater",
...
...
services/begetctl/BUILD.gn
浏览文件 @
6638b7de
...
...
@@ -15,15 +15,19 @@ import("//build/ohos.gni")
ohos_executable("begetctl") {
sources = [
"init_cmd_reboot.c",
"main.c",
"misc_daemon.cpp",
"
init_cmd_reboot
.c",
"
param_cmd
.c",
"service_control.c",
"param_cmd.c"
]
defines = [ "INIT_AGENT" ]
if (defined(product_name) && product_name == "rk3568") {
defines += [ "PRODUCT_RK" ]
}
include_dirs = [
"//base/startup/init_lite/services/include",
"//base/startup/init_lite/services/log",
...
...
@@ -37,25 +41,25 @@ ohos_executable("begetctl") {
]
deps = [
"//base/startup/init_lite/interfaces/innerkits/fs_manager:libfsmanager_shared",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
"//base/startup/init_lite/interfaces/innerkits/reboot:libreboot_static",
"//base/startup/init_lite/services/log:agent_log",
"//base/startup/init_lite/services/param:param_client",
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
"//third_party/bounds_checking_function:libsec_static",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
symlink_target_name = [
"misc_daemon",
"reboot",
"devctl",
"service",
"service_control",
"start_service",
"stop_service",
"service",
"param"
"misc_daemon",
"reboot",
"devctl",
"service",
"service_control",
"start_service",
"stop_service",
"service",
"param",
]
install_images = [ "system" ]
...
...
services/begetctl/init_cmd_reboot.c
浏览文件 @
6638b7de
...
...
@@ -20,6 +20,7 @@
#include "begetctl.h"
#define REBOOT_CMD_NUMBER 2
#ifdef PRODUCT_RK
#define USAGE_INFO "usage: reboot shutdown\n"\
" reboot updater\n"\
" reboot updater[:options]\n" \
...
...
@@ -27,6 +28,14 @@
" reboot flashd[:options]\n" \
" reboot loader\n" \
" reboot\n"
#else
#define USAGE_INFO "usage: reboot shutdown\n"\
" reboot updater\n"\
" reboot updater[:options]\n" \
" reboot flashd\n" \
" reboot flashd[:options]\n" \
" reboot\n"
#endif
static
int
main_cmd
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -38,7 +47,9 @@ static int main_cmd(int argc, char* argv[])
if
(
argc
==
REBOOT_CMD_NUMBER
&&
strcmp
(
argv
[
1
],
"shutdown"
)
!=
0
&&
strcmp
(
argv
[
1
],
"updater"
)
!=
0
&&
strcmp
(
argv
[
1
],
"flashd"
)
!=
0
&&
strcmp
(
argv
[
1
],
"loader"
)
!=
0
&&
#ifdef PRODUCT_RK
strcmp
(
argv
[
1
],
"loader"
)
!=
0
&&
#endif
strncmp
(
argv
[
1
],
"updater:"
,
strlen
(
"updater:"
))
!=
0
&&
strncmp
(
argv
[
1
],
"flashd:"
,
strlen
(
"flashd:"
))
!=
0
)
{
printf
(
"%s"
,
USAGE_INFO
);
...
...
services/init/standard/init_reboot.c
浏览文件 @
6638b7de
...
...
@@ -25,6 +25,14 @@
#include "init_utils.h"
#include "securec.h"
#ifdef PRODUCT_RK
#include <sys/syscall.h>
#define REBOOT_MAGIC1 0xfee1dead
#define REBOOT_MAGIC2 672274793
#define REBOOT_CMD_RESTART2 0xA1B2C3D4
#endif
#define MAX_VALUE_LENGTH 500
#define MAX_COMMAND_SIZE 20
#define MAX_UPDATE_SIZE 100
...
...
@@ -139,43 +147,44 @@ void ExecReboot(const char *value)
return
;
}
INIT_ERROR_CHECK
(
CheckRebootParam
(
valueData
)
==
0
,
return
,
"Invalid arg %s for reboot."
,
value
);
char
*
fstabFile
=
GetFstabFile
();
INIT_ERROR_CHECK
(
fstabFile
!=
NULL
,
return
,
"Failed get fstab file"
);
Fstab
*
fstab
=
NULL
;
INIT_ERROR_CHECK
((
fstab
=
ReadFstabFromFile
(
fstabFile
,
false
))
!=
NULL
,
free
(
fstabFile
);
return
,
"Failed get fstab from %s"
,
fstabFile
);
free
(
fstabFile
);
char
miscDevice
[
PATH_MAX
]
=
{
0
};
int
ret
=
GetBlockDeviceByMountPoint
(
"/misc"
,
fstab
,
miscDevice
,
PATH_MAX
);
ReleaseFstab
(
fstab
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
,
"Failed to get misc device name."
);
char
*
fstabFile
=
GetFstabFile
();
if
(
fstabFile
!=
NULL
)
{
Fstab
*
fstab
=
ReadFstabFromFile
(
fstabFile
,
false
);
free
(
fstabFile
);
if
(
fstab
!=
NULL
)
{
INIT_CHECK_ONLY_ELOG
(
GetBlockDeviceByMountPoint
(
"/misc"
,
fstab
,
miscDevice
,
PATH_MAX
)
==
0
,
"Failed to get misc device name."
);
ReleaseFstab
(
fstab
);
}
}
StopAllServices
(
SERVICE_ATTR_INVALID
);
sync
();
INIT_CHECK_ONLY_ELOG
(
GetMountStatusForMountPoint
(
"/vendor"
)
==
0
||
umount
(
"/vendor"
)
==
0
,
"Failed to umount vendor. errno = %d."
,
errno
);
if
(
GetMountStatusForMountPoint
(
"/data"
)
!=
0
)
{
if
(
umount
(
"/data"
)
!=
0
&&
umount2
(
"/data"
,
MNT_FORCE
)
!=
0
)
{
INIT_LOGE
(
"Failed umount data. errno = %d."
,
errno
);
}
}
else
{
INIT_LOGE
(
"Failed to get mount point
\"
/data
\"
"
);
}
ret
=
0
;
INIT_CHECK_ONLY_ELOG
(
GetMountStatusForMountPoint
(
"/data"
)
==
0
||
umount
(
"/data"
)
==
0
||
umount2
(
"/data"
,
MNT_FORCE
)
==
0
,
"Failed umount data. errno = %d."
,
errno
);
int
ret
=
0
;
if
(
valueData
==
NULL
)
{
#ifndef PRODUCT_RK
ret
=
CheckAndRebootToUpdater
(
NULL
,
"reboot"
,
NULL
,
NULL
,
miscDevice
);
#else
reboot
(
RB_AUTOBOOT
);
#endif
}
else
if
(
strcmp
(
valueData
,
"shutdown"
)
==
0
)
{
#ifndef STARTUP_INIT_TEST
ret
=
reboot
(
RB_POWER_OFF
);
#endif
}
else
if
(
strcmp
(
valueData
,
"bootloader"
)
==
0
)
{
#ifndef STARTUP_INIT_TEST
ret
=
reboot
(
RB_POWER_OFF
);
#endif
}
else
if
(
strncmp
(
valueData
,
"updater"
,
strlen
(
"updater"
))
==
0
)
{
ret
=
CheckAndRebootToUpdater
(
valueData
,
"updater"
,
"updater:"
,
"boot_updater"
,
miscDevice
);
}
else
if
(
strncmp
(
valueData
,
"flash"
,
strlen
(
"flash"
))
==
0
)
{
ret
=
CheckAndRebootToUpdater
(
valueData
,
"flash"
,
"flash:"
,
"boot_flash"
,
miscDevice
);
#ifdef PRODUCT_RK
}
else
if
(
strncmp
(
valueData
,
"loader"
,
strlen
(
"loader"
))
==
0
)
{
syscall
(
__NR_reboot
,
REBOOT_MAGIC1
,
REBOOT_MAGIC2
,
REBOOT_CMD_RESTART2
,
"loader"
);
#endif
}
INIT_LOGI
(
"Reboot %s %s."
,
value
,
(
ret
==
0
)
?
"success"
:
"fail"
);
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录