提交 4f03dd3f 编写于 作者: C cheng_jinsong

减少不必要依赖

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
上级 f9ff0c09
......@@ -254,7 +254,7 @@ if (defined(ohos_lite)) {
external_deps = [
"c_utils:utils",
"hilog_native:libhilog_base",
"ipc:ipc_core",
"ipc:ipc_single",
"samgr:samgr_proxy",
]
public_configs = [ ":exported_header_files" ]
......
......@@ -1036,6 +1036,10 @@ void ParseAllServices(const cJSON *fileRoot)
static Service *GetServiceByExtServName(const char *fullServName)
{
INIT_ERROR_CHECK(fullServName != NULL, return NULL, "Failed get parameters");
Service *service = GetServiceByName(fullServName);
if (service != NULL) { // none parameter in fullServName
return service;
}
char *tmpServName = strdup(fullServName);
char *dstPtr[MAX_PATH_ARGS_CNT] = {NULL};
int returnCount = SplitString(tmpServName, "|", dstPtr, MAX_PATH_ARGS_CNT);
......@@ -1043,7 +1047,7 @@ static Service *GetServiceByExtServName(const char *fullServName)
free(tmpServName);
return NULL;
}
Service *service = GetServiceByName(dstPtr[0]);
service = GetServiceByName(dstPtr[0]);
if (service == NULL) {
free(tmpServName);
return NULL;
......@@ -1060,9 +1064,6 @@ static Service *GetServiceByExtServName(const char *fullServName)
for (extArgc = 0; extArgc < (returnCount - 1); extArgc++) {
service->extraArgs.argv[extArgc + argc] = strdup(dstPtr[extArgc + 1]);
}
for (int i = 0; i < service->extraArgs.count - 1; i++) {
INIT_LOGI("service->extraArgs.argv[%d] is %s", i, service->extraArgs.argv[i]);
}
service->extraArgs.argv[service->extraArgs.count] = NULL;
free(tmpServName);
return service;
......@@ -1102,7 +1103,7 @@ void StopAllServices(int flags, const char **exclude, int size,
int (*filter)(const Service *service, const char **exclude, int size))
{
Service *service = GetServiceByName("appspawn");
if (service != NULL && service->pid != -1) { // notify appspawn stop
if (service != NULL && service->pid > 0) { // notify appspawn stop
#ifndef STARTUP_INIT_TEST
kill(service->pid, SIGTERM);
waitpid(service->pid, 0, 0);
......
......@@ -89,11 +89,12 @@ int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, u
return 0;
}
static int SyncExecCommand(int argc, char * const *argv)
static void SyncExecCommand(int argc, char * const *argv)
{
INIT_CHECK(!(argc == 0 || argv == NULL || argv[0] == NULL), return -1);
INIT_CHECK(!(argc == 0 || argv == NULL || argv[0] == NULL), return);
INIT_LOGI("sync exec: %s", argv[0]);
pid_t pid = fork();
INIT_ERROR_CHECK(!(pid < 0), return -1, "Fork new process to format failed: %d", errno);
INIT_ERROR_CHECK(!(pid < 0), return, "Fork new process to format failed: %d", errno);
if (pid == 0) {
INIT_CHECK_ONLY_ELOG(execv(argv[0], argv) == 0, "execv %s failed! err %d.", argv[0], errno);
exit(-1);
......@@ -102,11 +103,10 @@ static int SyncExecCommand(int argc, char * const *argv)
pid_t ret = waitpid(pid, &status, 0);
if (ret != pid) {
INIT_LOGE("Failed to wait pid %d, errno %d", pid, errno);
return ret;
return;
}
INIT_CHECK_ONLY_ELOG(!(!WIFEXITED(status) || WEXITSTATUS(status) != 0),
"Command %s failed with status %d", argv[0], WEXITSTATUS(status));
return 0;
INIT_LOGI("sync exec: %s result %d %d", argv[0], WEXITSTATUS(status), WIFEXITED(status));
return;
}
static void DoIfup(const struct CmdArgs *ctx)
......@@ -198,8 +198,7 @@ static void DoSyncExec(const struct CmdArgs *ctx)
// format: syncexec /xxx/xxx/xxx xxx
INIT_ERROR_CHECK(ctx != NULL && ctx->argv[0] != NULL, return,
"DoSyncExec: invalid arguments to exec \"%s\"", ctx->argv[0]);
int ret = SyncExecCommand(ctx->argc, ctx->argv);
INIT_LOGI("DoSyncExec end with ret %d", ret);
SyncExecCommand(ctx->argc, ctx->argv);
return;
}
......@@ -288,7 +287,8 @@ static void DoMakeDevice(const struct CmdArgs *ctx)
static void DoMountFstabFile(const struct CmdArgs *ctx)
{
INIT_LOGI("Mount partitions from fstab file \" %s \"", ctx->argv[0]);
(void)MountAllWithFstabFile(ctx->argv[0], 0);
int ret = MountAllWithFstabFile(ctx->argv[0], 0);
INIT_LOGI("Mount partitions from fstab file \" %s \" finish ret %d", ctx->argv[0], ret);
}
static void DoUmountFstabFile(const struct CmdArgs *ctx)
......@@ -420,7 +420,6 @@ static bool InitFscryptPolicy(void)
static void DoInitGlobalKey(const struct CmdArgs *ctx)
{
INIT_LOGI("DoInitGlobalKey: start");
if (ctx == NULL || ctx->argc != 1) {
INIT_LOGE("DoInitGlobalKey: para invalid");
return;
......@@ -442,13 +441,11 @@ static void DoInitGlobalKey(const struct CmdArgs *ctx)
NULL
};
int argc = ARRAY_LENGTH(argv);
int ret = SyncExecCommand(argc, argv);
INIT_LOGI("DoInitGlobalKey: end, ret = %d", ret);
SyncExecCommand(argc, argv);
}
static void DoInitMainUser(const struct CmdArgs *ctx)
{
INIT_LOGI("DoInitMainUser: start");
if (ctx == NULL) {
INIT_LOGE("DoInitMainUser: para invalid");
return;
......@@ -461,13 +458,11 @@ static void DoInitMainUser(const struct CmdArgs *ctx)
NULL
};
int argc = ARRAY_LENGTH(argv);
int ret = SyncExecCommand(argc, argv);
INIT_LOGI("DoInitMainUser: end, ret = %d", ret);
SyncExecCommand(argc, argv);
}
static void DoMkswap(const struct CmdArgs *ctx)
{
INIT_LOGI("DoMkswap: start");
if (ctx == NULL) {
INIT_LOGE("DoMkswap: para invalid");
return;
......@@ -478,13 +473,11 @@ static void DoMkswap(const struct CmdArgs *ctx)
NULL
};
int argc = ARRAY_LENGTH(argv);
int ret = SyncExecCommand(argc, argv);
INIT_LOGI("DoMkswap: end, ret = %d", ret);
SyncExecCommand(argc, argv);
}
static void DoSwapon(const struct CmdArgs *ctx)
{
INIT_LOGI("DoSwapon: start");
if (ctx == NULL) {
INIT_LOGE("DoSwapon: para invalid");
return;
......@@ -495,8 +488,7 @@ static void DoSwapon(const struct CmdArgs *ctx)
NULL
};
int argc = ARRAY_LENGTH(argv);
int ret = SyncExecCommand(argc, argv);
INIT_LOGI("DoSwapon: end, ret = %d", ret);
SyncExecCommand(argc, argv);
}
static void DoMkSandbox(const struct CmdArgs *ctx)
......
......@@ -199,5 +199,6 @@ int SwitchRoot(const char *newRoot)
return -1;
}
FreeRootDir(oldRoot, oldRootStat.st_dev);
INIT_LOGI("SwitchRoot to %s finish", newRoot);
return 0;
}
......@@ -23,7 +23,6 @@ ohos_shared_library("bootchart") {
]
deps = [
"//base/startup/init/interfaces/innerkits:libbegetutil",
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/cJSON:cjson_static",
]
......
......@@ -89,11 +89,6 @@ if (defined(ohos_lite)) {
deps = service_ueventd_deps
defines = [ "__RAMDISK__" ]
cflags = []
if (use_musl == false) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
} else {
deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
}
if (build_selinux) {
external_deps = [ "selinux:librestorecon" ]
cflags += [ "-DWITH_SELINUX" ]
......
......@@ -32,16 +32,14 @@ if (defined(ohos_lite)) {
} else {
import("//build/ohos.gni")
ohos_executable("watchdog_service") {
sources = [ "init_watchdog.c" ]
sources = [
"//base/startup/init/services/log/init_commlog.c",
"init_watchdog.c",
]
deps = [
"//base/startup/init/services/log:init_log",
"//third_party/bounds_checking_function:libsec_shared",
]
if (use_musl == false) {
deps += [ "//base/startup/init/services/param/base:parameterbase" ]
} else {
deps += [ "//base/startup/init/services/param/base:parameterbase_ext" ]
}
defines = [ "LINUX_WATCHDOG" ]
defines += [ "_GNU_SOURCE" ]
install_enable = true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册