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
ENDFOREACH(flag)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Werror -rdynamic -Wno-deprecated-declarations")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions -DUNIFIED_SYSTEM_SERVICE_ENABLED=${ENABLE_UNIFIED_SYSTEM_SERVICE}")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt -fPIE")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
# To apply Armoring(Full RELRO), which means GOT Table becomes read-only.
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
-if(${ENABLE_UNIFIED_SYSTEM_SERVICE})
-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}/system/plugin/ COMPONENT RuntimeLibraries)
-else()
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${PROJECT_NAME}_pkgs_LDFLAGS} "-ldl" "-lm")
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
-endif()
-if (${ENABLE_UNIFIED_SYSTEM_SERVICE})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/org.tizen.system.storage-unified-system-service.conf DESTINATION /etc/dbus-1/system.d)
-else()
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)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/org.tizen.system.storage.service DESTINATION /usr/share/dbus-1/system-services)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/systemd/ DESTINATION lib/systemd/system
FILES_MATCHING
PATTERN "storaged.service")
-endif()
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/block.conf DESTINATION /etc/storaged)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/conf/storage.conf DESTINATION /etc/storaged)
IF(BLOCK_MODULE STREQUAL on)
ADD_SUBDIRECTORY(src/block)
+++ /dev/null
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
- <policy user="root">
- <allow own="org.tizen.system.storage"/>
- <allow send_destination="org.tizen.system.storage"/>
- </policy>
-
- <policy user="security_fw">
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="GetControl"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="Control"/>
- </policy>
-
- <policy context="default">
- <deny own="org.tizen.system.storage"/>
-
- <!-- /Org/Tizen/System/Storage/Storage -->
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Storage"
- send_member="GetStatus"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Storage"
- send_member="getstorage"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Storage"
- send_member="GetStatvfs"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Storage"
- send_member="GetStorageLevel"/>
-
- <!-- /Org/Tizen/System/Storage/Block/Manager -->
- <check send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- privilege="http://tizen.org/privilege/externalstorage"/>
-
- <deny send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="GetControl"/>
- <deny send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="Control"/>
-
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="ShowDeviceList"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="GetDeviceList"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="GetDeviceList2"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="GetDeviceInfo"/>
- <allow send_destination="org.tizen.system.storage"
- send_path="/Org/Tizen/System/Storage/Block/Manager"
- send_member="GetMmcPrimary"/>
- </policy>
-</busconfig>
#These options are DEACTIVATED by default.
%bcond_with emulator
%define extended_storage 0
-%define enable_unified_system_service 0
Name: storaged
Summary: Storaged
%if %{extended_storage}
BuildRequires: pkgconfig(ode)
%endif
-BuildRequires: pkgconfig(hal-api-common)
#For /usr/bin/msgfmt
BuildRequires: gettext-tools
-DBLOCK_TMPFS=on \
-DSTORAGE_MODULE=on \
-DEXTENDED_STORAGE=%{extended_storage} \
- -DENABLE_UNIFIED_SYSTEM_SERVICE=%{enable_unified_system_service} \
-DCRITICAL_LOG_MODULE=on \
#eol
rm -rf %{buildroot}
%make_install
-%if %{enable_unified_system_service} != 1
%install_service delayed.target.wants storaged.service
-%endif
%if "%{asan}" == "1"
mkdir -p %{buildroot}%{_unitdir}/storaged.service.d
%find_lang extended-sd
%post
-%if %{enable_unified_system_service}
-mv %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage-unified-system-service.conf \
- %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage.conf
-%endif
-
systemctl daemon-reload
if [ "$1" == "1" ]; then
systemctl restart storaged.service
%files
%manifest %{name}.manifest
%license LICENSE.Apache-2.0
-%if %{enable_unified_system_service}
-%config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage-unified-system-service.conf
-%{_libdir}/system/plugin/libunified-system-service-storaged.so
-%else
%config %{_sysconfdir}/dbus-1/system.d/org.tizen.system.storage.conf
%{_datadir}/dbus-1/system-services/org.tizen.system.storage.service
%{_unitdir}/delayed.target.wants/storaged.service
%{_unitdir}/storaged.service
%{_bindir}/storaged
-%endif
%if "%{asan}" == "1"
%{_unitdir}/storaged.service.d/storaged.asan.conf
%endif
#include <sys/types.h>
#include <sys/stat.h>
-#include <unified-system-service-common.h>
-
#include "log.h"
#include "modules.h"
#include "storaged_common.h"
}
-static int storaged_init(void *data)
+int main(int argc, char **argv)
{
guint timer;
int ret;
if (!g_handle)
_E("Failed to get dbus connection.");
+ loop = g_main_loop_new(NULL, TRUE);
+ if (!loop) {
+ _E("Failed to make main loop.");
+ return -ENOMEM;
+ }
+
dir_init();
modules_init((void *)&g_handle);
_E("Failed to aw_register.");
}
- return 0;
-}
+ g_main_loop_run(loop);
-static int storaged_exit(void *data)
-{
- int ret = 0;
modules_deinit(NULL);
if (!g_handle)
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,
-};
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
-#include <spawn.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#define MODEL_NAME "http://tizen.org/system/model_name"
#define MODEL_EMULATOR "Emulator"
-static int g_unified_system_service_on = UNIFIED_SYSTEM_SERVICE_ENABLED;
-
static const char *rm_arg[] = {
"/usr/bin/rm",
"-rf", NULL, NULL,
exit(EXIT_FAILURE);
}
-int run_fork(int argc, const char *argv[])
+int run_child(int argc, const char *argv[])
{
pid_t pid;
struct sigaction act, oldact;
return r;
}
-int run_posix_spawn(int argc, const char *argv[])
-{
- pid_t pid;
- int status;
- int r = 0;
- FILE *fp;
- posix_spawnattr_t attr;
- sigset_t sigmask;
- sigset_t sigdefault;
-
- if (!argv)
- return -EINVAL;
-
- fp = fopen(argv[0], "r");
- if (fp == NULL) {
- _E("Failed to %s: %d", argv[0], errno);
- return -errno;
- }
- fclose(fp);
-
- posix_spawnattr_init(&attr);
- sigemptyset(&sigmask);
- sigemptyset(&sigdefault);
- sigprocmask(SIG_BLOCK, &sigmask, NULL);
-
- posix_spawnattr_setsigmask(&attr, &sigmask);
- posix_spawnattr_setsigdefault(&attr, &sigdefault);
- posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK | POSIX_SPAWN_SETSIGDEF);
-
- r = posix_spawn(&pid, argv[0], NULL, &attr, (char**)argv, NULL);
- if (r != 0)
- _E("Failed to posix_spawn: %d", r);
-
- waitpid(pid, &status, 0);
- _I("Process(%d) terminated by exit(%d).", pid, WEXITSTATUS(status));
-
- r = posix_spawnattr_destroy(&attr);
- if (r != 0)
- _E("Failed to posix_spawnattr_destroy: %d", r);
-
- return r;
-}
-
-int run_child(int argc, const char *argv[])
-{
- if (g_unified_system_service_on)
- return run_posix_spawn(argc, argv);
- else
- return run_fork(argc, argv);
-}
-
int remove_directory(const char*path)
{
int argc;