提交 147227fd 编写于 作者: H hw_mzyan 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/startup_init_lite into master

......@@ -13,7 +13,7 @@
declare_args() {
param_feature_watcher = true
param_test = false
param_test = true
if (defined(product_name) && product_name == "rk3568") {
boot_kernel_extended_cmdline =
......
......@@ -184,6 +184,9 @@ if (defined(ohos_lite)) {
if (!enable_ramdisk) {
defines += [ "DISABLE_INIT_TWO_STAGES" ]
}
if (support_jsapi) {
defines += [ "SUPPORT_PROFILER_HIDEBUG" ]
}
if (defined(product_name) && product_name == "rk3568") {
defines += [ "PRODUCT_RK" ]
......
......@@ -420,8 +420,7 @@
"name" : "boot && param:const.debuggable=1",
"condition" : "boot && const.debuggable=1",
"cmds" : [
"start console",
"start misc"
"start console"
]
}, {
"name" : "services:console",
......@@ -481,7 +480,6 @@
"gid" : ["shell", "log", "readproc"]
}, {
"name" : "misc",
"start-mode" : "normal",
"path" : ["/system/bin/misc_daemon", "--write_logo", "/vendor/logo.rgb"],
"once" : 1
}
......
......@@ -188,7 +188,6 @@
}, {
"name" : "post-fs-data",
"cmds" : [
"start misc",
"mkdir /data/app 0711 root root",
"mkdir /data/app/el1 0711 root root",
"mkdir /data/app/el1/bundle 0711 root root",
......@@ -453,8 +452,7 @@
}, {
"name" : "misc",
"path" : ["/system/bin/misc_daemon", "--write_logo", "/vendor/logo.rgb"],
"once" : 1,
"start-mode" : "normal"
"once" : 1
}
]
}
......@@ -352,8 +352,8 @@ int ServiceStop(Service *service)
static bool CalculateCrashTime(Service *service, int crashTimeLimit, int crashCountLimit)
{
INIT_ERROR_CHECK(service != NULL && crashTimeLimit > 0 && crashCountLimit > 0, return 0,
"Service name=%s, input params error.", service->name);
INIT_ERROR_CHECK(service != NULL && crashTimeLimit > 0 && crashCountLimit > 0,
return false, "input params error.");
time_t curTime = time(NULL);
if (service->crashCnt == 0) {
service->firstCrashTime = curTime;
......
......@@ -640,10 +640,7 @@ static int CheckServiceKeyName(const cJSON *curService)
char *cfgServiceKeyList[] = {
"name", "path", "uid", "gid", "once", "importance", "caps", "disabled",
"writepid", "critical", "socket", "console", "dynamic", "file", "ondemand",
"d-caps", "apl", "jobs", "start-mode", "end-mode", "cpucore",
#ifdef WITH_SELINUX
SECON_STR_IN_CFG,
#endif // WITH_SELINUX
"d-caps", "apl", "jobs", "start-mode", "end-mode", "cpucore", "secon"
};
INIT_CHECK_RETURN_VALUE(curService != NULL, SERVICE_FAILURE);
cJSON *child = curService->child;
......
......@@ -202,6 +202,7 @@ void SocketDelWatcher(ServiceWatcher watcherHandle)
int CreateServiceSocket(Service *service)
{
INIT_CHECK(service != NULL && service->socketCfg != NULL, return 0);
INIT_CHECK(service->socketCfg->sockFd == -1, return 0);
int ret = 0;
ServiceSocket *tmpSock = service->socketCfg;
while (tmpSock != NULL) {
......
......@@ -62,6 +62,7 @@ static int FdHolderSockInit(void)
unlink(INIT_HOLDER_SOCKET_PATH);
}
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
if (strncpy_s(addr.sun_path, sizeof(addr.sun_path),
INIT_HOLDER_SOCKET_PATH, strlen(INIT_HOLDER_SOCKET_PATH)) != 0) {
INIT_LOGE("Faild to copy fd hoder socket path");
......@@ -70,7 +71,7 @@ static int FdHolderSockInit(void)
}
socklen_t len = (socklen_t)(offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path) + 1);
if (bind(sock, (struct sockaddr *)&addr, len) < 0) {
INIT_LOGE("Failed to binder fd folder socket");
INIT_LOGE("Failed to binder fd folder socket %d", errno);
close(sock);
return -1;
}
......@@ -158,6 +159,7 @@ static int StartUeventd(char **requiredDevices, int num)
return -1;
}
RetriggerUevent(ueventSockFd, requiredDevices, num);
close(ueventSockFd);
return 0;
}
......@@ -242,12 +244,7 @@ static void BootStateChange(const char *content)
{
INIT_LOGI("boot start %s finish.", content);
if (strcmp("init", content) == 0) {
static const char *bootServiceNames[] = {
"hdf_devmgr", "samgr", "appspawn", "faultloggerd"
};
for (int i = 0; i < ARRAY_LENGTH(bootServiceNames); i++) {
StartServiceByName(bootServiceNames[i], 0);
}
StartAllServices(START_MODE_BOOT);
return;
}
if (strcmp("post-init", content) == 0) {
......
......@@ -63,6 +63,7 @@ int GetParamValue(const char *symValue, unsigned int symLen, char *paramValue, u
curr += begin - start;
}
while (*begin != '{') {
INIT_CHECK_RETURN_VALUE(*begin != '\0', -1);
begin++;
}
begin++;
......
......@@ -132,7 +132,7 @@ void GetAccessToken(void)
uint64_t tokenId = GetAccessTokenId(service->name, (const char **)service->capsArgs.argv,
service->capsArgs.count, service->apl);
if (tokenId == 0) {
INIT_LOGE("Set totken id %lld of service \' %s \' failed", service->name, tokenId);
INIT_LOGE("Get totken id %lld of service \' %s \' failed", tokenId, service->name);
}
service->tokenId = tokenId;
}
......
......@@ -69,7 +69,7 @@ typedef struct {
typedef struct {
ParamMessage msg;
uint32_t result;
int32_t result;
} ParamResponseMessage;
typedef LoopBase *ParamTaskPtr;
......
......@@ -17,11 +17,11 @@ if (defined(ohos_lite)) {
sources = [
"//base/startup/init_lite/services/utils/init_utils.c",
"//base/startup/init_lite/services/utils/list.c",
"//base/startup/init_lite/ueventd/lite/ueventd_main.c",
"//base/startup/init_lite/ueventd/lite/ueventd_parameter.c",
"//base/startup/init_lite/ueventd/ueventd.c",
"//base/startup/init_lite/ueventd/ueventd_device_handler.c",
"//base/startup/init_lite/ueventd/ueventd_firmware_handler.c",
"//base/startup/init_lite/ueventd/ueventd_main.c",
"//base/startup/init_lite/ueventd/ueventd_read_cfg.c",
"//base/startup/init_lite/ueventd/ueventd_socket.c",
]
......@@ -104,8 +104,8 @@ if (defined(ohos_lite)) {
ohos_executable("ueventd") {
sources = service_ueventd_sources
sources += [
"//base/startup/init_lite/ueventd/standard/ueventd_main.c",
"//base/startup/init_lite/ueventd/standard/ueventd_parameter.c",
"//base/startup/init_lite/ueventd/ueventd_main.c",
]
include_dirs = service_ueventd_include
include_dirs += [
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <poll.h>
#include "ueventd.h"
#include "ueventd_read_cfg.h"
#include "ueventd_socket.h"
#define INIT_LOG_TAG "ueventd"
#include "init_log.h"
int main(int argc, char **argv)
{
char *ueventdConfigs[] = {"/etc/ueventd.config", NULL};
int i = 0;
int ret = -1;
while (ueventdConfigs[i] != NULL) {
ParseUeventdConfigFile(ueventdConfigs[i++]);
}
int ueventSockFd = UeventdSocketInit();
if (ueventSockFd < 0) {
INIT_LOGE("Failed to create uevent socket");
return -1;
}
RetriggerUevent(ueventSockFd, NULL, 0); // Not require boot devices
struct pollfd pfd = {};
pfd.events = POLLIN;
pfd.fd = ueventSockFd;
while (1) {
pfd.revents = 0;
ret = poll(&pfd, 1, -1);
if (ret <= 0) {
continue;
}
if (pfd.revents & POLLIN) {
ProcessUevent(ueventSockFd, NULL, 0); // Not require boot devices
}
}
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册