elm_config: Add fallback path to support lazy mount 18/85218/3
authorWonki Kim <wonki_.kim@samsung.com>
Wed, 24 Aug 2016 07:43:09 +0000 (16:43 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Thu, 25 Aug 2016 10:56:29 +0000 (19:56 +0900)
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 <wonki_.kim@samsung.com>
src/lib/elm_config.c

index 192f550..ca79388 100644 (file)
@@ -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