From bcf5533c58e28c2f05c13b500b8f96119cb5605a Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 14 May 2018 09:26:11 +0900 Subject: [PATCH 01/16] block: Change file permission to "rw-rw-rw-" in vfat external storage Change-Id: If37a891c911401308e906d2fb2ea14fef7881546 Signed-off-by: Hyotaek Shim --- src/block/vfat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/block/vfat.c b/src/block/vfat.c index 6fed522..8789e82 100644 --- a/src/block/vfat.c +++ b/src/block/vfat.c @@ -32,7 +32,7 @@ #define FS_VFAT_NAME "mkdosfs" /* guid 10001 - group priv_externalstorage */ -#define FS_VFAT_MOUNT_OPT "uid=0,gid=10001,dmask=0000,fmask=0117,iocharset=iso8859-1,utf8,shortname=mixed" +#define FS_VFAT_MOUNT_OPT "uid=0,gid=10001,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed" static const char *vfat_arg[] = { "/usr/bin/newfs_msdos", -- 2.7.4 From 8306364ef12d87b6dceb2c0a978383f31ea1875d Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Thu, 17 May 2018 13:50:30 +0900 Subject: [PATCH 02/16] dbus-policy: change to default deny policy Change-Id: I747566fac4beaf96dc72dbc962231b974e84930c Signed-off-by: sanghyeok.oh --- conf/org.tizen.system.storage.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/org.tizen.system.storage.conf b/conf/org.tizen.system.storage.conf index 8657f26..e91466a 100644 --- a/conf/org.tizen.system.storage.conf +++ b/conf/org.tizen.system.storage.conf @@ -17,6 +17,7 @@ + -- 2.7.4 From f9551151c4be5a2c30e4f2d3053fe1d6cd32e051 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 7 Jun 2018 17:30:50 +0900 Subject: [PATCH 03/16] storage: Check /opt partition storage size and add NeedCleanup signal - Check /opt/usr, /tmp, /opt size - Broadcast NeedCleanup signal when memory level is changed normal -> warning/critical/full warning -> critical/full critical -> full Change-Id: I39d42624be0dbe4923f79c5e744502f2661a2103 Signed-off-by: pr.jung --- src/storage/storage.c | 102 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 14 deletions(-) diff --git a/src/storage/storage.c b/src/storage/storage.c index 3106eae..de66353 100644 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -39,6 +39,7 @@ #include "module-intf.h" #define MEMORY_STATUS_TMP_PATH "/tmp" +#define MEMORY_STATUS_OPT_PATH "/opt" #define MEMNOTI_TMP_CRITICAL_VALUE (20) #define MEMORY_MEGABYTE_VALUE 1048576 @@ -47,6 +48,7 @@ #define MEMNOTI_CRITICAL_VALUE (0.1) /* 0.1% under */ #define MEMNOTI_FULL_VALUE (0.0) /* 0.0% under */ +#define SIGNAL_NEED_CLEANUP "NeedCleanup" #define SIGNAL_LOWMEM_STATE "ChangeState" #define SIGNAL_LOWMEM_FULL "Full" #define MEMNOTI_TIMER_INTERVAL 5000 /* milliseconds */ @@ -58,10 +60,10 @@ #define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) enum memnoti_level { - MEMNOTI_LEVEL_CRITICAL = 0, + MEMNOTI_LEVEL_FULL = 0, + MEMNOTI_LEVEL_CRITICAL, MEMNOTI_LEVEL_WARNING, MEMNOTI_LEVEL_NORMAL, - MEMNOTI_LEVEL_FULL, }; enum memnoti_status { @@ -69,7 +71,14 @@ enum memnoti_status { MEMNOTI_ENABLE, }; +enum memory_id { + MEMORY_INTERNAL = 0, + MEMORY_TMP, + MEMORY_OPT, +}; + struct storage_config_info { + enum memory_id mem_id; enum memnoti_level current_noti_level; double warning_level; double critical_level; @@ -82,6 +91,7 @@ static guint id_booting_done; static guint id_storage_poweroff; static struct storage_config_info storage_internal_info = { + .mem_id = MEMORY_INTERNAL, .current_noti_level = MEMNOTI_LEVEL_NORMAL, .warning_level = MEMNOTI_WARNING_VALUE, .critical_level = MEMNOTI_CRITICAL_VALUE, @@ -89,19 +99,63 @@ static struct storage_config_info storage_internal_info = { }; static struct storage_config_info storage_tmp_info = { + .mem_id = MEMORY_TMP, .current_noti_level = MEMNOTI_LEVEL_NORMAL, .warning_level = MEMNOTI_TMP_CRITICAL_VALUE, .critical_level = MEMNOTI_TMP_CRITICAL_VALUE, .full_level = MEMNOTI_FULL_VALUE, }; -static void memnoti_send_broadcast(char *signal, int status) +static struct storage_config_info storage_opt_info = { + .mem_id = MEMORY_OPT, + .current_noti_level = MEMNOTI_LEVEL_NORMAL, + .warning_level = MEMNOTI_WARNING_VALUE, + .critical_level = MEMNOTI_CRITICAL_VALUE, + .full_level = MEMNOTI_FULL_VALUE, +}; + +static void memstatus_send_broadcast(enum memory_id no, char *signal, int status) { + if (no == MEMORY_OPT) + return; + _I("signal %s status %d", signal, status); dbus_handle_broadcast_dbus_signal_var(STORAGED_PATH_LOWMEM, STORAGED_INTERFACE_LOWMEM, signal, g_variant_new("(i)", status)); } +static void memcleanup_send_broadcast(struct storage_config_info *info, enum memnoti_level level, enum memnoti_level prev_level) +{ + const char *path; + char *value; + + if (info->mem_id == MEMORY_INTERNAL) + path = tzplatform_getenv(TZ_SYS_HOME); + else if (info->mem_id == MEMORY_TMP) + path = MEMORY_STATUS_TMP_PATH; + else if (info->mem_id == MEMORY_OPT) + path = MEMORY_STATUS_OPT_PATH; + else + return; + + if (prev_level <= level) + return; + + if (level == MEMNOTI_LEVEL_WARNING) + value = "warning"; + else if (level == MEMNOTI_LEVEL_CRITICAL) + value = "critical"; + else if (level == MEMNOTI_LEVEL_FULL) + value = "full"; + else + return; + + _I("%s level: %s", path, value); + dbus_handle_broadcast_dbus_signal_var(STORAGED_PATH_LOWMEM, STORAGED_INTERFACE_LOWMEM, + SIGNAL_NEED_CLEANUP, g_variant_new("(ss)", path, value)); + +} + static int launch_memory_popup(int num, ...) { int ret; @@ -150,15 +204,20 @@ static void storage_status_broadcast(struct storage_config_info *info, double to { double level = (avail/total)*100; int status = MEMNOTI_DISABLE; + enum memnoti_level prev_noti_level; + prev_noti_level = info->current_noti_level; if (level <= info->full_level) { if (info->current_noti_level == MEMNOTI_LEVEL_FULL) return; info->current_noti_level = MEMNOTI_LEVEL_FULL; status = MEMNOTI_ENABLE; - memnoti_send_broadcast(SIGNAL_LOWMEM_FULL, status); - _I("current level %4.4lf w:%4.4lf c:%4.4lf f:%4.4lf", - level, info->warning_level, info->critical_level, info->full_level); + memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_FULL, status); + + memcleanup_send_broadcast(info, info->current_noti_level, prev_noti_level); + + _I("%d current level %4.4lf w:%4.4lf c:%4.4lf f:%4.4lf", + info->mem_id, level, info->warning_level, info->critical_level, info->full_level); return; } @@ -166,23 +225,32 @@ static void storage_status_broadcast(struct storage_config_info *info, double to if (info->current_noti_level == MEMNOTI_LEVEL_CRITICAL) return; if (info->current_noti_level == MEMNOTI_LEVEL_FULL) - memnoti_send_broadcast(SIGNAL_LOWMEM_FULL, status); + memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_FULL, status); info->current_noti_level = MEMNOTI_LEVEL_CRITICAL; status = MEMNOTI_ENABLE; - memnoti_send_broadcast(SIGNAL_LOWMEM_STATE, status); - _I("current level %4.4lf w:%4.4lf c:%4.4lf f:%4.4lf", - level, info->warning_level, info->critical_level, info->full_level); + memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_STATE, status); + + memcleanup_send_broadcast(info, info->current_noti_level, prev_noti_level); + + _I("%d current level %4.4lf w:%4.4lf c:%4.4lf f:%4.4lf", + info->mem_id, level, info->warning_level, info->critical_level, info->full_level); return; } if (info->current_noti_level == MEMNOTI_LEVEL_FULL) - memnoti_send_broadcast(SIGNAL_LOWMEM_FULL, status); + memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_FULL, status); if (info->current_noti_level == MEMNOTI_LEVEL_CRITICAL) - memnoti_send_broadcast(SIGNAL_LOWMEM_STATE, status); - if (level <= info->warning_level) + memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_STATE, status); + + if (level <= info->warning_level) { info->current_noti_level = MEMNOTI_LEVEL_WARNING; - else + _I("%d current level %4.4lf w:%4.4lf c:%4.4lf f:%4.4lf", + info->mem_id, level, info->warning_level, info->critical_level, info->full_level); + + memcleanup_send_broadcast(info, info->current_noti_level, prev_noti_level); + } else info->current_noti_level = MEMNOTI_LEVEL_NORMAL; + } static int storage_get_memory_size(const char *path, struct statvfs *s) @@ -258,6 +326,11 @@ static gboolean check_storage_status(gpointer data) dTotal = (double)s.f_frsize * s.f_blocks; dAvail = (double)s.f_bsize * s.f_bavail; storage_status_broadcast(&storage_tmp_info, dTotal, dAvail); + /* check opt */ + storage_get_memory_size(MEMORY_STATUS_OPT_PATH, &s); + dTotal = (double)s.f_frsize * s.f_blocks; + dAvail = (double)s.f_bsize * s.f_bavail; + storage_status_broadcast(&storage_opt_info, dTotal, dAvail); if (memnoti_timer) { g_source_remove(memnoti_timer); @@ -272,6 +345,7 @@ static int init_storage_config_info_all(void) { init_storage_config_info(tzplatform_getenv(TZ_SYS_HOME), &storage_internal_info); init_storage_config_info(MEMORY_STATUS_TMP_PATH, &storage_tmp_info); + init_storage_config_info(MEMORY_STATUS_OPT_PATH, &storage_opt_info); memnoti_timer = g_timeout_add(MEMNOTI_TIMER_INTERVAL, check_storage_status, NULL); if (memnoti_timer == 0) -- 2.7.4 From e38e617ced4ffafb321f69cf7883132348923352 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Thu, 21 Jun 2018 11:33:29 +0900 Subject: [PATCH 04/16] Boot optimization: add systemd unit dependency, After=dbus.service deviced.service Change-Id: I1a6d22fdc5480310d17934c4071b554746ac034c Signed-off-by: Hyotaek Shim --- systemd/storaged.service | 1 + 1 file changed, 1 insertion(+) diff --git a/systemd/storaged.service b/systemd/storaged.service index afbe628..61527cc 100644 --- a/systemd/storaged.service +++ b/systemd/storaged.service @@ -1,6 +1,7 @@ [Unit] Description=System storage daemon Requires=dbus.socket +After=dbus.service deviced.service [Service] Type=notify -- 2.7.4 From bc03daebbc0f7900646da84c95fb60f53deb89a5 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Tue, 12 Jun 2018 18:34:38 +0900 Subject: [PATCH 05/16] storage: Write file when storage status is changed - /run/storaged/needcleanup/trigger Change-Id: Ie48cb6020670e321a54771def0a4a40331df6152 Signed-off-by: pr.jung --- src/storage/storage.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/src/storage/storage.c b/src/storage/storage.c index de66353..60b3323 100644 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -57,6 +57,10 @@ #define STORAGE_CONF_FILE "/etc/storaged/storage.conf" +#define STORAGED_DIR_PATH "/run/storaged" +#define NEED_CLEANUP_DIR_PATH "/run/storaged/needcleanup" +#define NEED_CLEANUP_FILE_PATH "/run/storaged/needcleanup/trigger" + #define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) enum memnoti_level { @@ -91,7 +95,7 @@ static guint id_booting_done; static guint id_storage_poweroff; static struct storage_config_info storage_internal_info = { - .mem_id = MEMORY_INTERNAL, + .mem_id = MEMORY_INTERNAL, .current_noti_level = MEMNOTI_LEVEL_NORMAL, .warning_level = MEMNOTI_WARNING_VALUE, .critical_level = MEMNOTI_CRITICAL_VALUE, @@ -99,7 +103,7 @@ static struct storage_config_info storage_internal_info = { }; static struct storage_config_info storage_tmp_info = { - .mem_id = MEMORY_TMP, + .mem_id = MEMORY_TMP, .current_noti_level = MEMNOTI_LEVEL_NORMAL, .warning_level = MEMNOTI_TMP_CRITICAL_VALUE, .critical_level = MEMNOTI_TMP_CRITICAL_VALUE, @@ -107,13 +111,25 @@ static struct storage_config_info storage_tmp_info = { }; static struct storage_config_info storage_opt_info = { - .mem_id = MEMORY_OPT, + .mem_id = MEMORY_OPT, .current_noti_level = MEMNOTI_LEVEL_NORMAL, .warning_level = MEMNOTI_WARNING_VALUE, .critical_level = MEMNOTI_CRITICAL_VALUE, .full_level = MEMNOTI_FULL_VALUE, }; +static void write_file() +{ + FILE *fp; + + fp = fopen(NEED_CLEANUP_FILE_PATH, "w+"); + if (fp) { + fprintf(fp, "needcleanup\n"); + fclose(fp); + } else + _E("Fail to open %s", NEED_CLEANUP_FILE_PATH); +} + static void memstatus_send_broadcast(enum memory_id no, char *signal, int status) { if (no == MEMORY_OPT) @@ -126,8 +142,11 @@ static void memstatus_send_broadcast(enum memory_id no, char *signal, int status static void memcleanup_send_broadcast(struct storage_config_info *info, enum memnoti_level level, enum memnoti_level prev_level) { + time_t t; + struct tm *timeinfo; const char *path; char *value; + char buf[20]; if (info->mem_id == MEMORY_INTERNAL) path = tzplatform_getenv(TZ_SYS_HOME); @@ -150,7 +169,13 @@ static void memcleanup_send_broadcast(struct storage_config_info *info, enum mem else return; - _I("%s level: %s", path, value); + write_file(); + + t = time(NULL); + timeinfo = localtime(&t); + strftime(buf, sizeof(buf), "%b %d %T", timeinfo); + _D("time: %s path: %s level: %s", buf, path, value); + dbus_handle_broadcast_dbus_signal_var(STORAGED_PATH_LOWMEM, STORAGED_INTERFACE_LOWMEM, SIGNAL_NEED_CLEANUP, g_variant_new("(ss)", path, value)); @@ -505,6 +530,7 @@ static void storage_config_load(struct storage_config_info *info) static void storage_init(void *data) { + struct stat buf; int ret; storage_config_load(&storage_internal_info); @@ -524,6 +550,42 @@ static void storage_init(void *data) &storage_interface); if (ret < 0) _E("Failed to register dbus interface and methods(%d)", ret); + + ret = stat(STORAGED_DIR_PATH, &buf); + if (ret < 0) { + ret = mkdir(STORAGED_DIR_PATH, 0644); + if (ret < 0) + _E("Failed to make directory: %d", errno); + } else if (!S_ISDIR(buf.st_mode)) { + ret = remove(STORAGED_DIR_PATH); + if (ret < 0) + _E("Fail to remove %s. errno: %d", STORAGED_DIR_PATH, errno); + ret = mkdir(STORAGED_DIR_PATH, 0644); + if (ret < 0) + _E("Failed to make directory: %d", errno); + } else { + ret = chmod(STORAGED_DIR_PATH, 0644); + if (ret < 0) + _E("Fail to change permissions of a file"); + } + + ret = stat(NEED_CLEANUP_DIR_PATH, &buf); + if (ret < 0) { + ret = mkdir(NEED_CLEANUP_DIR_PATH, 0644); + if (ret < 0) + _E("Failed to make directory: %d", errno); + } else if (!S_ISDIR(buf.st_mode)) { + ret = remove(NEED_CLEANUP_DIR_PATH); + if (ret < 0) + _E("Fail to remove %s. errno: %d", NEED_CLEANUP_DIR_PATH, errno); + ret = mkdir(NEED_CLEANUP_DIR_PATH, 0644); + if (ret < 0) + _E("Failed to make directory: %d", errno); + } else { + ret = chmod(NEED_CLEANUP_DIR_PATH, 0644); + if (ret < 0) + _E("Fail to change permissions of a file"); + } } static void storage_exit(void *data) -- 2.7.4 From e034c18e8c3e4175e272955c73993d9f5ad41863 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Wed, 20 Jun 2018 14:00:07 +0900 Subject: [PATCH 06/16] storage: Add new dbus method "GetStorageLevel" - input: "i" TZ_SYS_USER, TZ_SYS_OPT, TZ_SYS_TMP - output: "s" normal, warning, critical, full, and error message Change-Id: I3954776c0f156bdbae43332393b62a55016eb015 Signed-off-by: pr.jung --- src/storage/storage.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/storage/storage.c b/src/storage/storage.c index 60b3323..c6965e9 100644 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -446,10 +446,44 @@ static GVariant *dbus_getstatvfs(GDBusConnection *conn, } +static GVariant *dbus_get_storage_level(GDBusConnection *conn, + const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, + GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) +{ + int path_id; + enum memnoti_level level; + char *value; + + g_variant_get(param, "(i)", &path_id); + + if (path_id == TZ_SYS_USER) + level = storage_internal_info.current_noti_level; + else if (path_id == TZ_SYS_OPT) + level = storage_opt_info.current_noti_level; + else if (path_id == TZ_SYS_TMP) + level = storage_tmp_info.current_noti_level; + else + level = -1; + + if (level == MEMNOTI_LEVEL_WARNING) + value = "warning"; + else if (level == MEMNOTI_LEVEL_CRITICAL) + value = "critical"; + else if (level == MEMNOTI_LEVEL_FULL) + value = "full"; + else if (level == MEMNOTI_LEVEL_NORMAL) + value = "normal"; + else + value = "Not supported path"; + + return g_variant_new("(s)", value); +} + static const dbus_method_s storage_methods[] = { - { "getstorage", NULL, "tt", dbus_getstatus }, - { "GetStatus", "s", "tt", dbus_get_storage_status}, - { "GetStatvfs", "s", "ttttttttttt", dbus_getstatvfs }, + { "getstorage", NULL, "tt", dbus_getstatus }, + { "GetStatus", "s", "tt", dbus_get_storage_status }, + { "GetStatvfs", "s", "ttttttttttt", dbus_getstatvfs }, + { "GetStorageLevel", "i", "s", dbus_get_storage_level }, /* Add methods here */ }; -- 2.7.4 From 5413fc0948f3609f365a042cfdc4e926f2691fe8 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 21 Jun 2018 16:34:30 +0900 Subject: [PATCH 07/16] Fix dbus returned error by unmatched signature between storaged and system-popup Change-Id: Iecf6cd5c6f57484b813bd9983bf9a5af0975714c Signed-off-by: lokilee73 --- src/shared/apps.c | 36 ++++++++++++++++++++++++++++++------ src/shared/apps.h | 2 +- src/storage/storage.c | 28 ++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/shared/apps.c mode change 100644 => 100755 src/shared/apps.h mode change 100644 => 100755 src/storage/storage.c diff --git a/src/shared/apps.c b/src/shared/apps.c old mode 100644 new mode 100755 index 4d7b13b..b0154e4 --- a/src/shared/apps.c +++ b/src/shared/apps.c @@ -1,5 +1,5 @@ /* - * deviced + * storaged * * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. * @@ -34,6 +34,26 @@ static const struct app_dbus_match { { POPUP_DEFAULT, POPUP_BUS_NAME, POPUP_PATH_SYSTEM, POPUP_INTERFACE_SYSTEM, POPUP_METHOD_LAUNCH }, }; +static void __cb(GVariant *var, void *user_data, GError *err) +{ + int ret; + + if (!var) { + _E("no message [%s]", err->message); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &ret)) { + _E("no message [%s]", g_variant_get_type_string(var)); + goto out; + } + + _D("reply value : %d", ret); + +out: + g_variant_unref(var); +} + int launch_system_app(char *type, int num, ...) { char *app_type; @@ -59,11 +79,15 @@ int launch_system_app(char *type, int num, ...) va_start(args, num); - ret = dbus_handle_method_async_pairs(app_match[match].bus, - app_match[match].path, - app_match[match].iface, - app_match[match].method, - num, args); + ret = dbus_handle_method_async_pairs_with_reply(app_match[match].bus, + app_match[match].path, + app_match[match].iface, + app_match[match].method, + num, + args, + __cb, + -1, + NULL); va_end(args); diff --git a/src/shared/apps.h b/src/shared/apps.h old mode 100644 new mode 100755 index cbd51ab..5dcaba7 --- a/src/shared/apps.h +++ b/src/shared/apps.h @@ -1,5 +1,5 @@ /* - * deviced + * storaged * * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. * diff --git a/src/storage/storage.c b/src/storage/storage.c old mode 100644 new mode 100755 index c6965e9..26aa270 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -181,6 +181,26 @@ static void memcleanup_send_broadcast(struct storage_config_info *info, enum mem } +static void __cb(GVariant *var, void *user_data, GError *err) +{ + int ret; + + if (!var) { + _E("no message [%s]", err->message); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &ret)) { + _E("no message [%s]", g_variant_get_type_string(var)); + goto out; + } + + _D("reply value : %d", ret); + +out: + g_variant_unref(var); +} + static int launch_memory_popup(int num, ...) { int ret; @@ -188,11 +208,15 @@ static int launch_memory_popup(int num, ...) va_start(args, num); - ret = dbus_handle_method_async_pairs(POPUP_BUS_NAME, + ret = dbus_handle_method_async_pairs_with_reply(POPUP_BUS_NAME, POPUP_PATH_SYSTEM, POPUP_INTERFACE_SYSTEM, "PopupLaunch", - num, args); + num, + args, + __cb, + -1, + NULL); va_end(args); -- 2.7.4 From 83e67b113165b1c0f9925d6620667dacd8a6a72e Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 25 Jun 2018 13:58:09 +0900 Subject: [PATCH 08/16] storage: Change NeedCleanup signal from "ss" to "is" - Change NeedCleanup signal "ss" to "is" Path is sent by tzplatform_variable enum - Remove Full and ChangeState signals Change-Id: Iac9f52b5ef7d03f6bdd38be7bcf29393f310a87d Signed-off-by: pr.jung --- src/storage/storage.c | 82 +++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/src/storage/storage.c b/src/storage/storage.c index 26aa270..8e9848b 100755 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -49,8 +49,6 @@ #define MEMNOTI_FULL_VALUE (0.0) /* 0.0% under */ #define SIGNAL_NEED_CLEANUP "NeedCleanup" -#define SIGNAL_LOWMEM_STATE "ChangeState" -#define SIGNAL_LOWMEM_FULL "Full" #define MEMNOTI_TIMER_INTERVAL 5000 /* milliseconds */ #define SIGNAL_POWEROFF_STATE "ChangeState" @@ -130,30 +128,20 @@ static void write_file() _E("Fail to open %s", NEED_CLEANUP_FILE_PATH); } -static void memstatus_send_broadcast(enum memory_id no, char *signal, int status) -{ - if (no == MEMORY_OPT) - return; - - _I("signal %s status %d", signal, status); - dbus_handle_broadcast_dbus_signal_var(STORAGED_PATH_LOWMEM, STORAGED_INTERFACE_LOWMEM, - signal, g_variant_new("(i)", status)); -} - static void memcleanup_send_broadcast(struct storage_config_info *info, enum memnoti_level level, enum memnoti_level prev_level) { time_t t; struct tm *timeinfo; - const char *path; + enum tzplatform_variable path; char *value; char buf[20]; if (info->mem_id == MEMORY_INTERNAL) - path = tzplatform_getenv(TZ_SYS_HOME); + path = TZ_SYS_USER; else if (info->mem_id == MEMORY_TMP) - path = MEMORY_STATUS_TMP_PATH; + path = TZ_SYS_TMP; else if (info->mem_id == MEMORY_OPT) - path = MEMORY_STATUS_OPT_PATH; + path = TZ_SYS_OPT; else return; @@ -161,11 +149,11 @@ static void memcleanup_send_broadcast(struct storage_config_info *info, enum mem return; if (level == MEMNOTI_LEVEL_WARNING) - value = "warning"; + value = "Warning"; else if (level == MEMNOTI_LEVEL_CRITICAL) - value = "critical"; + value = "Critical"; else if (level == MEMNOTI_LEVEL_FULL) - value = "full"; + value = "Full"; else return; @@ -174,10 +162,10 @@ static void memcleanup_send_broadcast(struct storage_config_info *info, enum mem t = time(NULL); timeinfo = localtime(&t); strftime(buf, sizeof(buf), "%b %d %T", timeinfo); - _D("time: %s path: %s level: %s", buf, path, value); + _D("time: %s path: %d level: %s", buf, path, value); dbus_handle_broadcast_dbus_signal_var(STORAGED_PATH_LOWMEM, STORAGED_INTERFACE_LOWMEM, - SIGNAL_NEED_CLEANUP, g_variant_new("(ss)", path, value)); + SIGNAL_NEED_CLEANUP, g_variant_new("(is)", path, value)); } @@ -252,7 +240,6 @@ static int memnoti_popup(enum memnoti_level level) static void storage_status_broadcast(struct storage_config_info *info, double total, double avail) { double level = (avail/total)*100; - int status = MEMNOTI_DISABLE; enum memnoti_level prev_noti_level; prev_noti_level = info->current_noti_level; @@ -260,8 +247,6 @@ static void storage_status_broadcast(struct storage_config_info *info, double to if (info->current_noti_level == MEMNOTI_LEVEL_FULL) return; info->current_noti_level = MEMNOTI_LEVEL_FULL; - status = MEMNOTI_ENABLE; - memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_FULL, status); memcleanup_send_broadcast(info, info->current_noti_level, prev_noti_level); @@ -273,11 +258,7 @@ static void storage_status_broadcast(struct storage_config_info *info, double to if (level <= info->critical_level) { if (info->current_noti_level == MEMNOTI_LEVEL_CRITICAL) return; - if (info->current_noti_level == MEMNOTI_LEVEL_FULL) - memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_FULL, status); info->current_noti_level = MEMNOTI_LEVEL_CRITICAL; - status = MEMNOTI_ENABLE; - memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_STATE, status); memcleanup_send_broadcast(info, info->current_noti_level, prev_noti_level); @@ -286,11 +267,6 @@ static void storage_status_broadcast(struct storage_config_info *info, double to return; } - if (info->current_noti_level == MEMNOTI_LEVEL_FULL) - memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_FULL, status); - if (info->current_noti_level == MEMNOTI_LEVEL_CRITICAL) - memstatus_send_broadcast(info->mem_id, SIGNAL_LOWMEM_STATE, status); - if (level <= info->warning_level) { info->current_noti_level = MEMNOTI_LEVEL_WARNING; _I("%d current level %4.4lf w:%4.4lf c:%4.4lf f:%4.4lf", @@ -322,7 +298,7 @@ static int storage_get_memory_size(const char *path, struct statvfs *s) static void get_storage_status(const char *path, struct statvfs *s) { - if (strcmp(path, tzplatform_getenv(TZ_SYS_HOME)) == 0) + if (strcmp(path, tzplatform_getenv(TZ_SYS_USER)) == 0) storage_get_internal_memory_size(s); else storage_get_memory_size(path, s); @@ -392,7 +368,7 @@ static gboolean check_storage_status(gpointer data) static int init_storage_config_info_all(void) { - init_storage_config_info(tzplatform_getenv(TZ_SYS_HOME), &storage_internal_info); + init_storage_config_info(tzplatform_getenv(TZ_SYS_USER), &storage_internal_info); init_storage_config_info(MEMORY_STATUS_TMP_PATH, &storage_tmp_info); init_storage_config_info(MEMORY_STATUS_OPT_PATH, &storage_opt_info); memnoti_timer = g_timeout_add(MEMNOTI_TIMER_INTERVAL, @@ -421,21 +397,37 @@ static GVariant *dbus_get_storage_status(GDBusConnection *conn, const gchar *sender, const gchar *path, const gchar *iface, const gchar *name, GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data) { + const char *temp; char *str_path; struct statvfs s; + struct stat buf; pid_t pid; unsigned long long dAvail = 0.0; unsigned long long dTotal = 0.0; + int ret; + bool success = true; g_variant_get(param, "(s)", &str_path); - if (!strcmp(str_path, tzplatform_getenv(TZ_SYS_HOME))) - storage_get_internal_memory_size(&s); - else - storage_get_memory_size(str_path, &s); + temp = tzplatform_getenv(TZ_SYS_USER); + if (!strncmp(str_path, temp, strlen(temp))) { + ret = stat(str_path, &buf); + if (ret == 0) { + ret = storage_get_internal_memory_size(&s); + if (ret < 0) + success = false; + } else + success = false; + } else { + ret = storage_get_memory_size(str_path, &s); + if (ret < 0) + success = false; + } - dTotal = (unsigned long long)s.f_frsize * s.f_blocks; - dAvail = (unsigned long long)s.f_bsize * s.f_bavail; + if (success) { + dTotal = (unsigned long long)s.f_frsize * s.f_blocks; + dAvail = (unsigned long long)s.f_bsize * s.f_bavail; + } pid = dbus_handle_get_sender_pid(NULL, sender); @@ -490,13 +482,13 @@ static GVariant *dbus_get_storage_level(GDBusConnection *conn, level = -1; if (level == MEMNOTI_LEVEL_WARNING) - value = "warning"; + value = "Warning"; else if (level == MEMNOTI_LEVEL_CRITICAL) - value = "critical"; + value = "Critical"; else if (level == MEMNOTI_LEVEL_FULL) - value = "full"; + value = "Full"; else if (level == MEMNOTI_LEVEL_NORMAL) - value = "normal"; + value = "Normal"; else value = "Not supported path"; -- 2.7.4 From 3e4532c1f80882480ec096b7e2dd6e0de87c820d Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Tue, 3 Jul 2018 15:29:05 +0900 Subject: [PATCH 09/16] svace fix Change-Id: I35d4440f60d1ef2468bd07a7afea1545c5178ded Signed-off-by: sanghyeok.oh --- src/storage/storage.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/storage/storage.c b/src/storage/storage.c index 8e9848b..545514a 100755 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -131,7 +131,7 @@ static void write_file() static void memcleanup_send_broadcast(struct storage_config_info *info, enum memnoti_level level, enum memnoti_level prev_level) { time_t t; - struct tm *timeinfo; + struct tm timeinfo; enum tzplatform_variable path; char *value; char buf[20]; @@ -160,10 +160,15 @@ static void memcleanup_send_broadcast(struct storage_config_info *info, enum mem write_file(); t = time(NULL); - timeinfo = localtime(&t); - strftime(buf, sizeof(buf), "%b %d %T", timeinfo); + if (localtime_r(&t, &timeinfo) == NULL) { + _E("Failed to localtime_r"); + goto out; + } + + strftime(buf, sizeof(buf), "%b %d %T", &timeinfo); _D("time: %s path: %d level: %s", buf, path, value); +out: dbus_handle_broadcast_dbus_signal_var(STORAGED_PATH_LOWMEM, STORAGED_INTERFACE_LOWMEM, SIGNAL_NEED_CLEANUP, g_variant_new("(is)", path, value)); -- 2.7.4 From e62913fc5cab951ee4e20194a75489246743c19b Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 6 Jul 2018 13:31:48 +0900 Subject: [PATCH 10/16] Change watchdog timeout from 30 sec. to 90 sec. It has been observed, after a long suspend timeout/delay, Systemd may kill processes by Watchdog timeout as soon as it is thawed. This is a workaground patch to avoid such a problem. [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] Freezing of tasks failed after 20.006 seconds (1 tasks refusing to freeze, wq_bu$ [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] shealth-exercis D 0 16604 3220 0x00400209 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] Call trace: [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] __switch_to+0x8c/0xa0 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] __schedule+0x37c/0x72c [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] schedule+0x8c/0xac [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] schedule_timeout+0x148/0x38c [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] kbase_destroy_context+0x394/0x448 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] kbase_release+0xf4/0x158 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] __fput+0xf4/0x1a8 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] ____fput+0xc/0x14 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] task_work_run+0xbc/0xe8 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] do_notify_resume+0x80/0x90 [Thu Jul 5 03:18:04 2018] [1: kworker/u4:9: 8153] [] work_pending+0x8/0x10 ... Jul 05 14:37:25 localhost systemd[1]: storaged.service: Watchdog timeout (limit 30s)! Jul 05 14:37:25 localhost systemd[1]: storaged.service: Killing process 3092 (storaged) with signal SIGABRT. Change-Id: I4ce6d243dca5b30bc8a6f7cd526c724227dbfcdf Signed-off-by: Hyotaek Shim --- src/core/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/main.c b/src/core/main.c index 365365f..3a202d1 100755 --- a/src/core/main.c +++ b/src/core/main.c @@ -93,7 +93,7 @@ int main(int argc, char **argv) timer = g_timeout_add(WATCHDOG_TIMEOUT * 1000, watchdog_cb, NULL); if (timer > 0) { - ret = aw_register(WATCHDOG_TIMEOUT * 2); + ret = aw_register(WATCHDOG_TIMEOUT * 6); if (ret < 0) _E("aw_register failed"); } -- 2.7.4 From 7cca1fb3791803c5e1d889021e287307aab72d8b Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Thu, 26 Jul 2018 17:48:32 +0900 Subject: [PATCH 11/16] Add GetStorageLevel dbus method Change-Id: I07bff489585935b5a533f010ae79c4e91d72cc65 Signed-off-by: pr.jung --- conf/org.tizen.system.storage.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/org.tizen.system.storage.conf b/conf/org.tizen.system.storage.conf index e91466a..db6f926 100644 --- a/conf/org.tizen.system.storage.conf +++ b/conf/org.tizen.system.storage.conf @@ -34,6 +34,9 @@ + Date: Thu, 16 Aug 2018 12:49:27 +0200 Subject: [PATCH 12/16] Add Apache 2.0 license headers Change-Id: I52155a8b06a6cc9f2a476d5ec76763051d9c7443 --- apps/extended-sd/include/es-preference-util.h | 16 ++++++++++++++++ apps/extended-sd/include/es-strings.h | 16 ++++++++++++++++ apps/extended-sd/include/extended-sd-main.h | 16 ++++++++++++++++ apps/extended-sd/include/log-util.h | 16 ++++++++++++++++ apps/extended-sd/src/es-common-util.c | 16 ++++++++++++++++ apps/extended-sd/src/es-home-page.c | 16 ++++++++++++++++ apps/extended-sd/src/es-internal-storage-page.c | 16 ++++++++++++++++ apps/extended-sd/src/es-portable-storage-page.c | 16 ++++++++++++++++ apps/extended-sd/src/es-preference-util.c | 16 ++++++++++++++++ apps/extended-sd/src/extended-sd-main.c | 16 ++++++++++++++++ 10 files changed, 160 insertions(+) diff --git a/apps/extended-sd/include/es-preference-util.h b/apps/extended-sd/include/es-preference-util.h index 86919b7..1ad733b 100644 --- a/apps/extended-sd/include/es-preference-util.h +++ b/apps/extended-sd/include/es-preference-util.h @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #ifndef __ES_PREFERENCE_UTIL_H__ #define __ES_PREFERENCE_UTIL_H__ diff --git a/apps/extended-sd/include/es-strings.h b/apps/extended-sd/include/es-strings.h index 20d5e7c..5189c35 100644 --- a/apps/extended-sd/include/es-strings.h +++ b/apps/extended-sd/include/es-strings.h @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #ifndef __ES_STRINGS_H__ #define __ES_STRINGS_H__ diff --git a/apps/extended-sd/include/extended-sd-main.h b/apps/extended-sd/include/extended-sd-main.h index 9c2f2ab..7f97e95 100644 --- a/apps/extended-sd/include/extended-sd-main.h +++ b/apps/extended-sd/include/extended-sd-main.h @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #ifndef __EXTENDED_SD_MAIN_H__ #define __EXTENDED_SD_MAIN_H__ diff --git a/apps/extended-sd/include/log-util.h b/apps/extended-sd/include/log-util.h index d12f4dd..7b76082 100644 --- a/apps/extended-sd/include/log-util.h +++ b/apps/extended-sd/include/log-util.h @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #ifndef __LOG_UTIL_H__ #define __LOG_UTIL_H__ diff --git a/apps/extended-sd/src/es-common-util.c b/apps/extended-sd/src/es-common-util.c index 93bf86c..03942a7 100644 --- a/apps/extended-sd/src/es-common-util.c +++ b/apps/extended-sd/src/es-common-util.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #include "extended-sd-main.h" #include "log-util.h" diff --git a/apps/extended-sd/src/es-home-page.c b/apps/extended-sd/src/es-home-page.c index 46a62a7..cc971e1 100644 --- a/apps/extended-sd/src/es-home-page.c +++ b/apps/extended-sd/src/es-home-page.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #include "extended-sd-main.h" #include "log-util.h" #include "es-preference-util.h" diff --git a/apps/extended-sd/src/es-internal-storage-page.c b/apps/extended-sd/src/es-internal-storage-page.c index 47b8c18..ac59c13 100644 --- a/apps/extended-sd/src/es-internal-storage-page.c +++ b/apps/extended-sd/src/es-internal-storage-page.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #include #include diff --git a/apps/extended-sd/src/es-portable-storage-page.c b/apps/extended-sd/src/es-portable-storage-page.c index 7b3843a..8aa3b29 100644 --- a/apps/extended-sd/src/es-portable-storage-page.c +++ b/apps/extended-sd/src/es-portable-storage-page.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #include #include diff --git a/apps/extended-sd/src/es-preference-util.c b/apps/extended-sd/src/es-preference-util.c index 56a1308..8f348f6 100644 --- a/apps/extended-sd/src/es-preference-util.c +++ b/apps/extended-sd/src/es-preference-util.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #include #include "extended-sd-main.h" diff --git a/apps/extended-sd/src/extended-sd-main.c b/apps/extended-sd/src/extended-sd-main.c index 192dbe2..0db8c9f 100644 --- a/apps/extended-sd/src/extended-sd-main.c +++ b/apps/extended-sd/src/extended-sd-main.c @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2017-2018 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + #include #include "extended-sd-main.h" -- 2.7.4 From f7f0b617dbe06e7d14fc9440f60877175944360b Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 7 Dec 2018 15:28:20 +0900 Subject: [PATCH 13/16] dlog: Fix dlog format errors Change-Id: I0e8141da652a5c6db57455740f5cb0e09e646c13 Signed-off-by: pr.jung --- src/auto-test/storage.c | 2 +- src/block/block.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/auto-test/storage.c b/src/auto-test/storage.c index 579fa22..323c0ad 100644 --- a/src/auto-test/storage.c +++ b/src/auto-test/storage.c @@ -40,7 +40,7 @@ static bool request_storage_method(const char *method, GVariant *param) _E("fail (%s): no message", method); else { if (val1 <= 0) { - _E("fail (%s): returned total storage (%d)", method, val1); + _E("fail (%s): returned total storage (%4.0llu)", method, val1); } else { _I("success (%s): Total: %4.0llu Avail: %4.0llu", method, val1, val2); ret = TRUE; diff --git a/src/block/block.c b/src/block/block.c index ec4295f..2093858 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -1592,7 +1592,7 @@ static int block_mount_device(struct block_device *bdev, void *data) l = DD_LIST_FIND(th_manager[thread_id].block_dev_list, bdev); pthread_mutex_unlock(&(th_manager[thread_id].mutex)); if (!l) { - _E("(%d) does not exist in the device list", bdev->data->devnode); + _E("(%s) does not exist in the device list", bdev->data->devnode); return -ENOENT; } @@ -1624,7 +1624,7 @@ static int block_format_device(struct block_device *bdev, void *data) l = DD_LIST_FIND(th_manager[thread_id].block_dev_list, bdev); pthread_mutex_unlock(&(th_manager[thread_id].mutex)); if (!l) { - _E("(%d) does not exist in the device list", bdev->data->devnode); + _E("(%s) does not exist in the device list", bdev->data->devnode); ret = -ENOENT; goto out; } -- 2.7.4 From d99f179b9fdecb23330890bdf8ae4f01fd67e723 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Fri, 14 Dec 2018 13:37:04 +0900 Subject: [PATCH 14/16] dlog: Fix dlog format errors Change-Id: I9fc9cbdbb7d52aff3de8bcaf23a475b840284ffe Signed-off-by: pr.jung --- apps/extended-sd/src/es-internal-storage-page.c | 4 ++-- apps/extended-sd/src/es-portable-storage-page.c | 4 ++-- apps/extended-sd/src/extended-sd-main.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/extended-sd/src/es-internal-storage-page.c b/apps/extended-sd/src/es-internal-storage-page.c index ac59c13..352df48 100644 --- a/apps/extended-sd/src/es-internal-storage-page.c +++ b/apps/extended-sd/src/es-internal-storage-page.c @@ -151,7 +151,7 @@ check_speed_done(GVariant *result, void *data, GError *err) g_variant_get(result, "(i)", &ret); if (ret < 0) { - DMSG("Performance warning", ret); + DMSG("Performance warning: %d", ret); Evas_Object* page_content = elm_object_part_content_unset(ad->internal_storage_page_data->internal_storage_page_base_layout, "elm.swallow.content"); EVAS_OBJECT_DEL(page_content); page_content = create_page_3(ad); @@ -189,7 +189,7 @@ _format_click_cb(void *data, Evas_Object* obj, void *event_info) DBUS_REPLY_TIMEOUT, // ms ad); if (ret < 0) - DMSG("Failed to check speed", ret); + DMSG("Failed to check speed: %d", ret); FUNC_END(); } diff --git a/apps/extended-sd/src/es-portable-storage-page.c b/apps/extended-sd/src/es-portable-storage-page.c index 8aa3b29..9b14665 100644 --- a/apps/extended-sd/src/es-portable-storage-page.c +++ b/apps/extended-sd/src/es-portable-storage-page.c @@ -146,7 +146,7 @@ mapper_device_cb(int mapper_id, storage_dev_e dev, storage_state_e state, 120000, ad); if (ret < 0) - DMSG("Failed to format", ret); + DMSG("Failed to format: %d", ret); FUNC_END(); } @@ -194,7 +194,7 @@ _format_click_cb(void *data, Evas_Object* obj, void *event_info) DBUS_REPLY_TIMEOUT, ad); if (ret < 0) - DMSG("Failed to format", ret); + DMSG("Failed to format: %d", ret); FUNC_END(); diff --git a/apps/extended-sd/src/extended-sd-main.c b/apps/extended-sd/src/extended-sd-main.c index 0db8c9f..53bbdfa 100644 --- a/apps/extended-sd/src/extended-sd-main.c +++ b/apps/extended-sd/src/extended-sd-main.c @@ -196,7 +196,7 @@ ui_app_lang_changed(app_event_info_h event_info, void *user_data) ret = app_event_get_language(event_info, &language); if (ret != APP_ERROR_NONE) { - DMSG_ERR("app_event_get_language() failed. Err = %s", ret); + DMSG_ERR("app_event_get_language() failed. Err = %d", ret); return; } -- 2.7.4 From 1ea8ee342e1fe18a6c4bceb3e5b010cb77848ce7 Mon Sep 17 00:00:00 2001 From: "pr.jung" Date: Mon, 17 Dec 2018 19:50:08 +0900 Subject: [PATCH 15/16] storage: Add popup and notification as well Change-Id: Ide44a71213baa09e4122c61030c4388b03f65e43 Signed-off-by: pr.jung Signed-off-by: lokilee73 (cherry picked from commit 663b8496576b7761ed4b1ae3a7db7b0eab7e6924) --- src/storage/storage.c | 152 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 137 insertions(+), 15 deletions(-) diff --git a/src/storage/storage.c b/src/storage/storage.c index 545514a..29a9960 100755 --- a/src/storage/storage.c +++ b/src/storage/storage.c @@ -61,6 +61,14 @@ #define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) +#define LOW_STORAGE_WARNING "lowstorage_warning" +#define LOW_STORAGE_CRITICAL "lowstorage_critical" +#define LOW_STORAGE_FULL "lowstorage_full" +#define LOW_STORAGE_REMOVE "lowstorage_remove" + +#define INTERNAL_STORAGE_NOTION "InternalStorageNotiOn" +#define INTERNAL_STORAGE_NOTIOFF "InternalStorageNotiOff" + enum memnoti_level { MEMNOTI_LEVEL_FULL = 0, MEMNOTI_LEVEL_CRITICAL, @@ -88,6 +96,7 @@ struct storage_config_info { }; static guint memnoti_timer; +static int noti_id; static guint id_booting_done; static guint id_storage_poweroff; @@ -174,7 +183,7 @@ out: } -static void __cb(GVariant *var, void *user_data, GError *err) +static void _popup_cb(GVariant *var, void *user_data, GError *err) { int ret; @@ -207,7 +216,7 @@ static int launch_memory_popup(int num, ...) "PopupLaunch", num, args, - __cb, + _popup_cb, -1, NULL); @@ -216,30 +225,138 @@ static int launch_memory_popup(int num, ...) return ret; } -static int memnoti_popup(enum memnoti_level level) +static void _noti_cb(GVariant *var, void *user_data, GError *err) +{ + int ret; + + if (!var) { + _E("no message [%s]", err->message); + return; + } + + if (!dh_get_param_from_var(var, "(i)", &ret)) { + _E("no message [%s]", g_variant_get_type_string(var)); + goto out; + } + + noti_id = ret; + _D("reply value : %d", ret); + +out: + g_variant_unref(var); +} + +static int remove_notification(void) +{ + const char *param[1]; + char id_str[16]; + int ret; + + snprintf(id_str, sizeof(id_str), "%d", noti_id); + param[0] = id_str; + + ret = dbus_handle_method_sync(POPUP_BUS_NAME, + POPUP_PATH_NOTI, + POPUP_INTERFACE_NOTI, + INTERNAL_STORAGE_NOTIOFF, + "i", + param); + if (ret < 0) + _E("Fail to remove noti : %d", noti_id); + + return ret; +} + +static int create_notification(void) +{ + int ret; + + ret = dbus_handle_method_async_with_reply(POPUP_BUS_NAME, + POPUP_PATH_NOTI, + POPUP_INTERFACE_NOTI, + INTERNAL_STORAGE_NOTION, + NULL, + NULL, + _noti_cb, + -1, + NULL); + if (ret < 0) + _E("Fail to create noti"); + + return ret; +} + +static int launch_memory_notification(char *type) +{ + int ret = -1; + + if (!type) + return -EINVAL; + + if (!strncmp(type, INTERNAL_STORAGE_NOTION, sizeof(INTERNAL_STORAGE_NOTION))) { + if (noti_id) { + ret = remove_notification(); + if (ret < 0) + return ret; + noti_id = 0; + } + + ret = create_notification(); + } else if (!strncmp(type, INTERNAL_STORAGE_NOTIOFF, sizeof(INTERNAL_STORAGE_NOTIOFF))) { + if (!noti_id) + return -1; + + ret = remove_notification(); + } else + _E("Invalid noti type : %s", type); + + return ret; +} + +static int process_memory_info(enum memnoti_level level) { int ret = -1; int val = -1; - char *value = NULL; + char *popup_value = NULL; + char *noti_value = NULL; - if (level != MEMNOTI_LEVEL_WARNING && level != MEMNOTI_LEVEL_CRITICAL) { + if (level < 0 || level > MEMNOTI_LEVEL_NORMAL) { _E("level check error : %d", level); return 0; } - if (level == MEMNOTI_LEVEL_WARNING) - value = "lowstorage_warning"; - else if (level == MEMNOTI_LEVEL_CRITICAL) - value = "lowstorage_critical"; + if (level == MEMNOTI_LEVEL_WARNING) { + popup_value = LOW_STORAGE_WARNING; + noti_value = INTERNAL_STORAGE_NOTION; + } else if (level == MEMNOTI_LEVEL_CRITICAL) { + popup_value = LOW_STORAGE_CRITICAL; + noti_value = INTERNAL_STORAGE_NOTION; + } else if (level == MEMNOTI_LEVEL_FULL) { + popup_value = LOW_STORAGE_FULL; + noti_value = INTERNAL_STORAGE_NOTION; + } else if (level == MEMNOTI_LEVEL_NORMAL) { + popup_value = LOW_STORAGE_REMOVE; + noti_value = INTERNAL_STORAGE_NOTIOFF; + } ret = vconf_get_int(VCONFKEY_STARTER_SEQUENCE, &val); if (val == 0 || ret != 0) return -1; - if (!value) + if (!popup_value && !noti_value) { + _E("Invalid memnoti level : %d", level); return 0; + } + + ret = launch_memory_popup(2, "_SYSPOPUP_CONTENT_", popup_value); + if (ret < 0) + _E("Fail to launch momory popup : %d", ret); - return launch_memory_popup(2, "_SYSPOPUP_CONTENT_", value); + ret = launch_memory_notification(noti_value); + if (ret < 0) + _E("Fail to launch momory notification : %d", ret); + + return ret; } static void storage_status_broadcast(struct storage_config_info *info, double total, double avail) @@ -280,7 +397,6 @@ static void storage_status_broadcast(struct storage_config_info *info, double to memcleanup_send_broadcast(info, info->current_noti_level, prev_noti_level); } else info->current_noti_level = MEMNOTI_LEVEL_NORMAL; - } static int storage_get_memory_size(const char *path, struct statvfs *s) @@ -326,13 +442,19 @@ static void init_storage_config_info(const char *path, struct storage_config_inf path, dTotal, dAvail, (dAvail*100/dTotal), info->warning_level, info->critical_level, info->full_level); } -static void check_internal_storage_popup(struct storage_config_info *info) +static void check_internal_storage(struct storage_config_info *info) { static enum memnoti_level old = MEMNOTI_LEVEL_NORMAL; int ret; if (info->current_noti_level < MEMNOTI_LEVEL_NORMAL && info->current_noti_level < old) { - ret = memnoti_popup(info->current_noti_level); + ret = process_memory_info(info->current_noti_level); + if (ret != 0) + info->current_noti_level = MEMNOTI_LEVEL_NORMAL; + } + + if (info->current_noti_level == MEMNOTI_LEVEL_NORMAL && info->current_noti_level > old) { + ret = process_memory_info(info->current_noti_level); if (ret != 0) info->current_noti_level = MEMNOTI_LEVEL_NORMAL; } @@ -350,7 +472,7 @@ static gboolean check_storage_status(gpointer data) dTotal = (double)s.f_frsize * s.f_blocks; dAvail = (double)s.f_bsize * s.f_bavail; storage_status_broadcast(&storage_internal_info, dTotal, dAvail); - check_internal_storage_popup(&storage_internal_info); + check_internal_storage(&storage_internal_info); /* check tmp */ storage_get_memory_size(MEMORY_STATUS_TMP_PATH, &s); dTotal = (double)s.f_frsize * s.f_blocks; -- 2.7.4 From 22f64a9c0da2c6805e385dc9676e30ddca6a95cf Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 27 Dec 2018 11:59:13 +0900 Subject: [PATCH 16/16] Remove executable flag from non-executable files Change-Id: Icd5e1876b505bb4e4cc5f7d513ab0ec60abbc761 Signed-off-by: lokilee73 --- src/core/main.c | 0 src/shared/apps.c | 0 src/shared/apps.h | 0 src/storage/storage.c | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/core/main.c mode change 100755 => 100644 src/shared/apps.c mode change 100755 => 100644 src/shared/apps.h mode change 100755 => 100644 src/storage/storage.c diff --git a/src/core/main.c b/src/core/main.c old mode 100755 new mode 100644 diff --git a/src/shared/apps.c b/src/shared/apps.c old mode 100755 new mode 100644 diff --git a/src/shared/apps.h b/src/shared/apps.h old mode 100755 new mode 100644 diff --git a/src/storage/storage.c b/src/storage/storage.c old mode 100755 new mode 100644 -- 2.7.4