From: SangYoun Kwak Date: Tue, 13 May 2025 07:20:40 +0000 (+0900) Subject: Add unified-system-service-storaged plugin for unified system service support X-Git-Tag: accepted/tizen/unified/20250530.090418~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=edf84604d085871db10c1ee57b87fb16a5888af4;p=platform%2Fcore%2Fsystem%2Fstoraged.git Add unified-system-service-storaged plugin for unified system service support To support unified system service, plugin package is added. storaged-unified-system-plugin rpm is newly added to install libunified-system-service-storaged.so. Service execution will be replaced as a library init/exit() way. With this, unified-system-service can run system services as a thread simultaneously. To avoid dbus rule conflict, a part of dbus conf rule is removed as different config file 'org.tizen.system.storage-unified-system-service.conf'. This file will replace org.tizen.system.storage.conf by the postscript of plugin rpm when it is installed. Change-Id: If8339b900bd6b7aef2004a382e6a6b10eb846297 Signed-off-by: SangYoun Kwak --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ec484f..ef46f2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ PROJECT(storaged C) SET(CMAKE_VERBOSE_MAKEFILE OFF) SET(STORAGED_APPS ${CMAKE_SOURCE_DIR}/apps) +SET(LIBRARY_NAME "unified-system-service-storaged") SET(SRCS src/core/main.c @@ -51,7 +52,12 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${PROJECT_NAME}_pkgs_LDFLAGS} "-ldl" "-lm") INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) +ADD_LIBRARY(${LIBRARY_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${${PROJECT_NAME}_pkgs_LDFLAGS} "-ldl" "-lm") +INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) + INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/org.tizen.system.storage.conf DESTINATION /etc/dbus-1/system.d) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/org.tizen.system.storage-unified-system-service.conf DESTINATION /etc/dbus-1/system.d) INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/block.conf DESTINATION /etc/storaged) INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/storage.conf DESTINATION /etc/storaged) INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.storage.service DESTINATION /usr/share/dbus-1/system-services) diff --git a/conf/org.tizen.system.storage-unified-system-service.conf b/conf/org.tizen.system.storage-unified-system-service.conf new file mode 100644 index 0000000..b95c178 --- /dev/null +++ b/conf/org.tizen.system.storage-unified-system-service.conf @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packaging/storaged.spec b/packaging/storaged.spec index b906a92..308bb3f 100644 --- a/packaging/storaged.spec +++ b/packaging/storaged.spec @@ -41,6 +41,7 @@ BuildRequires: pkgconfig(efl-extension) %if %{extended_storage} BuildRequires: pkgconfig(ode) %endif +BuildRequires: pkgconfig(hal-api-common) #For /usr/bin/msgfmt BuildRequires: gettext-tools @@ -53,6 +54,12 @@ Requires: /usr/bin/newfs_msdos %description storage daemon. +%package unified-system-plugin +Summary: unified-system-service plugin +Requires: %{name} = %{version}-%{release} +%description unified-system-plugin +unified-system-service plugin + %package module_block Summary: block module plugin Requires: %{name} = %{version}-%{release} @@ -139,6 +146,10 @@ if [ "$1" == "1" ]; then systemctl restart storaged.service fi +%post unified-system-plugin +mv %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage-unified-system-service.conf \ + %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage.conf + %postun systemctl daemon-reload @@ -154,6 +165,15 @@ systemctl daemon-reload %{_unitdir}/storaged.service.d/storaged.asan.conf %endif +%files unified-system-plugin +%manifest %{name}.manifest +%license LICENSE.Apache-2.0 +%config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage-unified-system-service.conf +%{_libdir}/libunified-system-service-storaged.so +%if "%{asan}" == "1" +%{_unitdir}/storaged.service.d/storaged.asan.conf +%endif + %files module_block %manifest %{name}.manifest %license LICENSE.Apache-2.0 diff --git a/src/core/main.c b/src/core/main.c index f36de3c..08d9e8c 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -27,6 +27,8 @@ #include #include +#include + #include "log.h" #include "modules.h" #include "storaged_common.h" @@ -80,21 +82,15 @@ static void dir_init(void) } -int main(int argc, char **argv) +static int storaged_init(void *data) { - int ret; guint timer; + int ret; dbus_handle_h handle = NULL; - loop = g_main_loop_new(NULL, TRUE); - if (!loop) { - _E("Failed to make main loop."); - return -ENOMEM; - } - handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, FALSE); if (!handle) - _E("Failed to get dbus connection.");; + _E("Failed to get dbus connection."); dir_init(); modules_init(NULL); @@ -115,9 +111,38 @@ int main(int argc, char **argv) _E("Failed to aw_register."); } - g_main_loop_run(loop); + return 0; +} +static int storaged_exit(void *data) +{ modules_deinit(NULL); return 0; } + +int main(int argc, char **argv) +{ + loop = g_main_loop_new(NULL, TRUE); + if (!loop) { + _E("Failed to make main loop."); + return -ENOMEM; + } + + storaged_init(NULL); + + g_main_loop_run(loop); + + storaged_exit(NULL); + + return 0; +} + +__attribute__ ((visibility("default"))) +unified_system_service unified_system_service_storaged_data = { + .name = "unified-system-service-storaged", + .early_init = NULL, + .init = storaged_init, + .exit = storaged_exit, + .late_exit = NULL, +};