diff --git a/services/init/include/init_service.h b/services/init/include/init_service.h index 9988dcaed7897bfaf27125717b562a1684d6f79f..353d1c4bfd6247463b2ee0e98ac4dba260ab5610 100644 --- a/services/init/include/init_service.h +++ b/services/init/include/init_service.h @@ -51,6 +51,7 @@ extern "C" { #define SERVICE_ATTR_WITHOUT_SANDBOX 0x800 // make service not enter sandbox #define SERVICE_ATTR_NOTIFY_STATE 0x1000 // service notify state +#define SERVICE_ATTR_MODULE_UPDATE 0x2000 // module update #define MAX_SERVICE_NAME 32 #define MAX_APL_NAME 32 diff --git a/services/init/include/init_service_manager.h b/services/init/include/init_service_manager.h index 63cec2032472ae6095d004d178d4a758f452f346..89f2c4aea267fd2989120d48a1d4f6d6d0035597 100644 --- a/services/init/include/init_service_manager.h +++ b/services/init/include/init_service_manager.h @@ -37,6 +37,7 @@ extern "C" { #define D_CAPS_STR_IN_CFG "d-caps" #define APL_STR_IN_CFG "apl" #define CPU_CORE_STR_IN_CFG "cpucore" +#define MODULE_UPDATE_STR_IN_CFG "module-update" #define MAX_SERVICES_CNT_IN_FILE 100 diff --git a/services/init/init_common_service.c b/services/init/init_common_service.c index b1b0efb94056e97d85870bd46ed611f38bbb15bf..2e99fae95c66162ebf92c8d01eaff0fc75b2e429 100644 --- a/services/init/init_common_service.c +++ b/services/init/init_common_service.c @@ -13,6 +13,7 @@ * limitations under the License. */ +#include #include #include #include @@ -345,6 +346,22 @@ void EnterServiceSandbox(Service *service) #endif } +void CheckModuleUpdate(int argc, char **argv) +{ + INIT_LOGI("CheckModuleUpdate start"); + void *handle = dlopen("libmodule_update.z.so", RTLD_NOW); + INIT_ERROR_CHECK(handle != NULL, return, "dlopen module update lib failed with error:%s", dlerror()); + INIT_LOGI("dlopen success"); + typedef void (*ExtFunc)(int, char **); + ExtFunc func = (ExtFunc)dlsym(handle, "CheckModuleUpdate"); + if (func == NULL) { + INIT_LOGE("dlsym get func failed with error:%s", dlerror()); + } else { + func(argc, argv); + } + INIT_LOGI("CheckModuleUpdate end"); +} + int ServiceStart(Service *service) { INIT_ERROR_CHECK(service != NULL, return SERVICE_FAILURE, "start service failed! null ptr."); @@ -371,6 +388,9 @@ int ServiceStart(Service *service) #endif int pid = fork(); if (pid == 0) { + if (service->attribute & SERVICE_ATTR_MODULE_UPDATE) { + CheckModuleUpdate(service->pathArgs.count, service->pathArgs.argv); + } // fail must exit sub process INIT_ERROR_CHECK(InitServiceProperties(service) == 0, _exit(PROCESS_EXIT_CODE), "Failed init service property"); diff --git a/services/init/init_service_manager.c b/services/init/init_service_manager.c index 9f8ce4f9dd4651bc7dacdc13fb643e7551bdc56b..36bbf81ed69362d38a5bb6ba8275602038da4632 100755 --- a/services/init/init_service_manager.c +++ b/services/init/init_service_manager.c @@ -850,6 +850,8 @@ int ParseOneService(const cJSON *curItem, Service *service) INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get console for service %s", service->name); ret = GetServiceAttr(curItem, service, "notify-state", SERVICE_ATTR_NOTIFY_STATE, NULL); INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get notify-state for service %s", service->name); + ret = GetServiceAttr(curItem, service, MODULE_UPDATE_STR_IN_CFG, SERVICE_ATTR_MODULE_UPDATE, NULL); + INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get module-update for service %s", service->name); ParseOneServiceArgs(curItem, service); ret = GetServiceSandbox(curItem, service);