From 860995081934e9496ca2eeb6b1567edd9730e4b5 Mon Sep 17 00:00:00 2001 From: Wonki Kim Date: Wed, 24 Aug 2016 16:43:09 +0900 Subject: [PATCH] elm_config: Add fallback path to support lazy mount elm_config would access to user home directory to save their config information. However, elm_config couldn't accesss to the path because user data area could not be mounted (Lazy mount of user data area[below /opt/usr/] is applied) elm_config monitors some file which is created after mounting then if it doesn't exist, elm_config will access to the other path @tizen_feature Change-Id: I5c43b1076ee0468bed8c6b443a8d02c03e0fe1f3 Signed-off-by: Wonki Kim --- src/lib/elm_config.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c index 192f550..ca79388 100644 --- a/src/lib/elm_config.c +++ b/src/lib/elm_config.c @@ -126,6 +126,19 @@ static void _color_overlays_cancel(void); #define ELM_CONFIG_LIST(edd, type, member, eddtype) \ EET_DATA_DESCRIPTOR_ADD_LIST(edd, type, #member, member, eddtype) +// TIZEN_ONLY(20160824):support lazy mount of user data area +// +// elm_config would access to user home directory to save their info +// However, elm_config couldn't accesss to that path because +// user data area could not be mounted (lazy mount applied) +// +// elm_config monitors a file(TIZEN_MOUNT_CHECK_PATH) which is created +// after mounting. then if it doesn't exist, elm_config will access to +// the fallback path based on TIZEN_UNMOUNT_FALLBACK_BASE_DIR +#define TIZEN_MOUNT_CHECK_PATH getenv("HOME") +#define TIZEN_UNMOUNT_FALLBACK_BASE_DIR "/opt" +// END + static void _elm_font_overlays_del_free(void) { @@ -549,6 +562,31 @@ end: return off; } +// TIZEN_ONLY(20160824):support lazy mount of user data area +static size_t +_elm_config_user_fallback_dir(char *dst, + size_t size) +{ + size_t len = 0, off = 0; + len = snprintf(dst + off, size - off, "%s", TIZEN_UNMOUNT_FALLBACK_BASE_DIR); + if (len >= size - off) return off ; + off += len; + len = snprintf(dst + off, size - off, "/%s", ELEMENTARY_BASE_DIR); + if (len >= size - off) return off ; + off += len; +#if defined(HAVE_GETUID) + len = snprintf(dst + off, size - off, "/%d", getuid()); + if (len >= size - off) return off ; + off += len; +#endif + return off ; +} +static Eina_Bool +_user_data_path_mounted() +{ + return ecore_file_is_dir(TIZEN_MOUNT_CHECK_PATH); +} +//END size_t _elm_config_user_dir_snprintf(char *dst, size_t size, @@ -558,7 +596,19 @@ _elm_config_user_dir_snprintf(char *dst, const char *home = NULL; size_t user_dir_len = 0, off = 0; va_list ap; - +//TIZEN_ONLY(20160824):support lazy mount of user data area + if (!_user_data_path_mounted()) + { + user_dir_len = _elm_config_user_fallback_dir(dst, size); + off = user_dir_len + 1; + if (off >= size) return off; + dst[user_dir_len] = '/'; + va_start(ap, fmt); + off += vsnprintf(dst + off, size - off, fmt, ap); + va_end(ap); + return off; + } +//END #if defined(HAVE_GETUID) && defined(HAVE_GETEUID) if (getuid() == geteuid()) #endif -- 2.7.4