From: Chanwoo Choi Date: Wed, 9 Apr 2025 08:03:15 +0000 (+0900) Subject: Add hal-backend-service-storaged plugin for unified system service support X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67b6ebe1a099cb345dce59edce96b236b99430a5;p=platform%2Fcore%2Fsystem%2Fstoraged.git Add hal-backend-service-storaged plugin for unified system service support Change-Id: Ifd1aaa3d5d99ef41a29382b2f22b4ebc1a45aabe Signed-off-by: Chanwoo Choi --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 6577dd9..f5b9ba5 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 "hal-backend-service-storaged") SET(SRCS src/core/main.c @@ -51,6 +52,10 @@ 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}/hal 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/block.conf DESTINATION /etc/storaged) INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/storage.conf DESTINATION /etc/storaged) diff --git a/packaging/storaged.spec b/packaging/storaged.spec index d0d0e5a..845fffa 100644 --- a/packaging/storaged.spec +++ b/packaging/storaged.spec @@ -40,6 +40,7 @@ BuildRequires: pkgconfig(efl-extension) %if %{extended_storage} BuildRequires: pkgconfig(ode) %endif +BuildRequires: pkgconfig(hal-api-common) #For /usr/bin/msgfmt BuildRequires: gettext-tools @@ -151,6 +152,7 @@ systemctl daemon-reload %if "%{asan}" == "1" %{_unitdir}/storaged.service.d/storaged.asan.conf %endif +%{_libdir}/hal/libhal-backend-service-storaged.so %files module_block %manifest %{name}.manifest diff --git a/src/core/main.c b/src/core/main.c index f36de3c..3318bd1 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" @@ -121,3 +123,41 @@ int main(int argc, char **argv) return 0; } + +static int storaged_exit(void *data) +{ + modules_deinit(NULL); + + return 0; +} + +static int storaged_init(void *data) +{ + int ret; + dbus_handle_h handle = NULL; + + handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, FALSE); + if (!handle) + _E("Failed to get dbus connection.");; + + dir_init(); + modules_init(NULL); + + ret = gdbus_request_name(handle, STORAGED_BUS_NAME, dbus_name_acquired, NULL); + if (ret <= 0) { + _E("Failed to request bus name."); + gdbus_check_name_owner(NULL, STORAGED_BUS_NAME); + } + + return 0; +} + +__attribute__ ((visibility("default"))) +hal_backend_service hal_backend_service_storaged_data = { + .module = HAL_MODULE_STORAGED, + .name = "hal-backend-service-storaged", + .early_init = NULL, + .init = storaged_init, + .exit = storaged_exit, + .late_exit = NULL, +}; diff --git a/systemd/storaged.service b/systemd/storaged.service index ae5e525..87a2bf3 100644 --- a/systemd/storaged.service +++ b/systemd/storaged.service @@ -1,17 +1,8 @@ [Unit] Description=System storage daemon -Requires=dbus.socket -Wants=wait-mount@opt-usr.service -After=wait-mount@opt-usr.service dbus.service [Service] -Type=notify -SmackProcessLabel=System::Privileged -ExecStart=/usr/bin/storaged -Restart=always -RestartSec=0 -KillSignal=SIGUSR1 -MemoryMax=20M +Type=simple [Install] WantedBy=delayed.target