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

减少不必要依赖

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