#include "fd_handler.h"
#include "utils.h"
#include "apps.h"
+#include "storaged_common.h"
/**
* TODO Assume root device is always mmcblk0*.
} while (true);
}
}
-
-static void booting_done(GDBusConnection *conn,
- const gchar *sender,
- const gchar *path,
- const gchar *iface,
- const gchar *name,
- GVariant *param,
- gpointer data)
+static void booting_done(void)
{
static int done = 0;
int ret;
if (done > 0)
return;
done = 1;
- _I("Booting done");
+ _I("Booting done.");
/* register mmc uevent control routine */
ret = register_udev_uevent_control(&uh);
if (ret < 0)
- _E("fail to register block uevent : %d", ret);
+ _E("Failed to register block uevent : %d", ret);
block_control = true;
/* if there is the attached device, try to mount */
block_boot = true;
}
+static void booting_done_received(GDBusConnection *conn,
+ const gchar *sender,
+ const gchar *path,
+ const gchar *iface,
+ const gchar *name,
+ GVariant *param,
+ gpointer data)
+{
+ _I("Signal received: %s", SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED);
+ booting_done();
+}
+
static void block_poweroff(GDBusConnection *conn,
const gchar *sender,
const gchar *path,
if (ret < 0)
_E("fail to init pipe");
- /* System Session is loaded completely */
- id_booting_done = subscribe_dbus_signal(NULL, SYSTEMD_DBUS_PATH,
- SYSTEMD_DBUS_IFACE_MANAGER,
- SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED,
- booting_done, NULL, NULL);
-
- id_block_poweroff = subscribe_dbus_signal(NULL, DEVICED_PATH_POWEROFF,
- DEVICED_INTERFACE_POWEROFF,
- SIGNAL_POWEROFF_STATE,
- block_poweroff, NULL, NULL);
-
for (i = 0; i < THREAD_MAX; i++) {
th_manager[i].num_dev = 0;
th_manager[i].op_len = 0;
ret = get_internal_storage_number();
if (ret < 0)
_E("Failed to get internal storage number");
+
+ if (check_system_boot_finished() != 0) {
+ _I("System session is already loaded.");
+ booting_done();
+ } else {
+ /* System Session is loaded completely */
+ id_booting_done = subscribe_dbus_signal(NULL, SYSTEMD_DBUS_PATH,
+ SYSTEMD_DBUS_IFACE_MANAGER,
+ SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED,
+ booting_done_received, NULL, NULL);
+ }
+
+ id_block_poweroff = subscribe_dbus_signal(NULL, DEVICED_PATH_POWEROFF,
+ DEVICED_INTERFACE_POWEROFF,
+ SIGNAL_POWEROFF_STATE,
+ block_poweroff, NULL, NULL);
}
static void terminate_threads(void)
{
#include <system_info.h>
#include <sys/mount.h>
#include <sys/time.h>
+#include <libgdbus/dbus-system.h>
+
#include "log.h"
#include "storaged_common.h"
-
#define MODEL_NAME "http://tizen.org/system/model_name"
#define MODEL_EMULATOR "Emulator"
+#define SYSTEMD_DBUS_DEST "org.freedesktop.systemd1"
+#define SYSTEMD_DBUS_PATH "/org/freedesktop/systemd1"
+#define DBUS_IFACE_DBUS_PROPERTIES "org.freedesktop.DBus.Properties"
+#define SYSTEMD_DBUS_IFACE_MANAGER SYSTEMD_DBUS_DEST ".Manager"
+
+#define SYSTEMD_DBUS_METHOD_SYSTEM_STATE "SystemState"
+#define SYSTEMD_STATE_RUNNING "running"
+#define SYSTEMD_STATE_DEGRADED "degraded"
+
bool is_emulator(void)
{
int ret;
return r;
}
+
+int check_system_boot_finished(void)
+{
+ char *state = NULL;
+ int ret = 0;
+ size_t len;
+ GVariant *reply = NULL;
+ GVariant *val = NULL;
+
+ reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
+ SYSTEMD_DBUS_PATH,
+ DBUS_IFACE_DBUS_PROPERTIES,
+ "Get",
+ g_variant_new("(ss)", SYSTEMD_DBUS_IFACE_MANAGER, SYSTEMD_DBUS_METHOD_SYSTEM_STATE));
+ if (!reply || !dh_get_param_from_var(reply, "(v)", &val)) {
+ _E("Failed to get system state: No reply");
+ goto err;
+ }
+
+ if (!dh_get_param_from_var(val, "s", &state)) {
+ _E("Failed to get system state(%s)", g_variant_get_type_string(reply));
+ goto err;
+ }
+
+ _I("System state=%s", state);
+
+ len = strlen(state) + 1;
+ if (!strncmp(state, SYSTEMD_STATE_RUNNING, len) ||
+ !strncmp(state, SYSTEMD_STATE_DEGRADED, len))
+ ret = 1;
+ else
+ ret = 0;
+
+err:
+ if (reply)
+ g_variant_unref(reply);
+
+ if (val)
+ g_variant_unref(val);
+
+ free(state);
+ return ret;
+}
int run_child(int argc, const char *argv[]);
bool is_emulator(void);
+int check_system_boot_finished(void);
#endif /* __STORAGED_COMMON_H__ */
storage
vconf
libgdbus
+ capi-system-info
)
FOREACH(flag ${${PROJECT_NAME}_pkgs_CFLAGS})
SET(SHARED_SRCS
../shared/config-parser.c
../shared/fd_handler.c
+ ../shared/common.c
)
ADD_LIBRARY(${PROJECT_NAME} ${SRCS} ${SHARED_SRCS})
#include "log.h"
#include "config-parser.h"
#include "module-intf.h"
+#include "storaged_common.h"
#define MEMORY_STATUS_TMP_PATH "/tmp"
#define MEMORY_STATUS_OPT_PATH "/opt"
.nr_methods = ARRAY_SIZE(storage_methods),
};
-static void booting_done(GDBusConnection *conn,
- const gchar *sender,
- const gchar *path,
- const gchar *iface,
- const gchar *name,
- GVariant *param,
- gpointer data)
+static void booting_done(void)
{
static int done;
if (done > 0)
return;
done = 1;
- _I("booting done");
+ _I("Booting done.");
if (init_storage_config_info_all() == -1)
- _E("fail remain mem noti control fd init");
+ _E("Failed remain mem noti control fd init.");
+}
+
+static void booting_done_received(GDBusConnection *conn,
+ const gchar *sender,
+ const gchar *path,
+ const gchar *iface,
+ const gchar *name,
+ GVariant *param,
+ gpointer data)
+{
+ _I("Signal received: %s", SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED);
+ booting_done();
}
static void storage_poweroff(GDBusConnection *conn,
storage_config_load(&storage_internal_info);
- /* System Session is loaded completely */
- id_booting_done = subscribe_dbus_signal(NULL, SYSTEMD_DBUS_PATH,
- SYSTEMD_DBUS_IFACE_MANAGER,
- SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED,
- booting_done, NULL, NULL);
-
- id_storage_poweroff = subscribe_dbus_signal(NULL, DEVICED_PATH_POWEROFF,
- DEVICED_INTERFACE_POWEROFF,
- SIGNAL_POWEROFF_STATE,
- storage_poweroff, NULL, NULL);
-
ret = dbus_handle_register_dbus_object(NULL, STORAGED_PATH_STORAGE,
&storage_interface);
if (ret < 0)
if (ret < 0)
_E("Fail to change permissions of a file");
}
+
+ if (check_system_boot_finished() != 0) {
+ _I("System session is already loaded.");
+ id_booting_done = 0;
+ booting_done();
+ } else {
+ /* System Session is loaded completely */
+ id_booting_done = subscribe_dbus_signal(NULL, SYSTEMD_DBUS_PATH,
+ SYSTEMD_DBUS_IFACE_MANAGER,
+ SYSTEMD_DBUS_SIGNAL_SYSTEM_STARTUP_FINISHED,
+ booting_done_received, NULL, NULL);
+ }
+
+ id_storage_poweroff = subscribe_dbus_signal(NULL, DEVICED_PATH_POWEROFF,
+ DEVICED_INTERFACE_POWEROFF,
+ SIGNAL_POWEROFF_STATE,
+ storage_poweroff, NULL, NULL);
}
static void storage_exit(void *data)