Add hal-backend-service-storaged plugin for unified system service support
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 9 Apr 2025 08:03:15 +0000 (17:03 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 9 Apr 2025 11:27:26 +0000 (20:27 +0900)
Change-Id: Ifd1aaa3d5d99ef41a29382b2f22b4ebc1a45aabe
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
CMakeLists.txt
packaging/storaged.spec
src/core/main.c
systemd/storaged.service

index 6577dd966a3f0ea3fe7d51ed5ff96d575e740810..f5b9ba5ce127cd51241a0c9bc49f3d8fc6b16cee 100644 (file)
@@ -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)
index d0d0e5a4eabcdcae558348180277c45c5a57df0e..845fffa11546b12c408c02185d99700fe2dd941a 100644 (file)
@@ -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
index f36de3c2b87fdb15ab0763ffbbd103f24bd3481a..3318bd17dfe15a83b7f525abfb052ae1fed5bbeb 100644 (file)
@@ -27,6 +27,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include <hal/hal-common.h>
+
 #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,
+};
index ae5e525e91e9215df7d08588006b5d0bc1960b34..87a2bf3ed4ab2a223a18eb413de7b1edb9f851d9 100644 (file)
@@ -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