Change internal storage media path returned from storage_get_directory() 70/184570/4 accepted/tizen/unified/20180719.152633 submit/tizen/20180719.052039
authorHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 19 Jul 2018 02:16:24 +0000 (11:16 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 19 Jul 2018 04:24:16 +0000 (13:24 +0900)
(Before) /opt/usr/media/XXX
(After)  /opt/usr/home/USER/media/XXX

/opt/usr/media bind-mounted by /opt/usr/home/USER/media
is workaround for supporting legacy Tizen applications based on /opt/usr/media hard coding.
Strictly, public apis do not need to use legacy path (/opt/usr/media).

Change-Id: Ida39777ac40587719beb8d28b8f04172c98900e5
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/storage-internal.c
src/storage.c

index 7f5d359..0dadec9 100755 (executable)
@@ -15,6 +15,8 @@
  */
 
 
+#include <unistd.h>
+#include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -61,11 +63,7 @@ static int internal_get_space(unsigned long long *total, unsigned long long *ava
 static const char *internal_get_root(void)
 {
        const char *ret;
-
-       if (is_compat_bind_mount())
-               ret = COMPAT_DIR;
-       else
-               ret = tzplatform_getenv(TZ_USER_CONTENT);
+       ret = tzplatform_uid_getenv(getuid(), TZ_USER_CONTENT);
 
        return ret;
 }
index 6dfef6d..b0d6465 100644 (file)
@@ -72,7 +72,7 @@ API int storage_foreach_device_supported(storage_device_supported_cb callback, v
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
-       if (getuid() < USER_UID_START)
+       if (getuid() <= USER_UID_START)
                user = false;
 
        DD_LIST_FOREACH(st_int_head, elem, st) {
@@ -116,7 +116,7 @@ API int storage_get_root_directory(int storage_id, char **path)
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
-       if (getuid() < USER_UID_START)
+       if (getuid() <= USER_UID_START)
                user = false;
 
        /* internal storage */
@@ -124,8 +124,8 @@ API int storage_get_root_directory(int storage_id, char **path)
                if (st->storage_id != storage_id)
                        continue;
                if (!user) {
-                       _E("Only Tizen applications and user session daemons can use \
-                               storage_get_root_directory(id , ...)");
+                       _E("Only Tizen applications and user session daemons can use\
+                               storage_get_root_directory(INTERNAL_STORAGE_ID, ...)");
                        return STORAGE_ERROR_INVALID_PARAMETER;
                }
 
@@ -189,13 +189,13 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p
                break;
        }
 
-       if (getuid() < USER_UID_START)
+       if (getuid() <= USER_UID_START)
                user = false;
 
        if (found && st) {
                if (!user) {
-                       _E("Only Tizen applications and user session daemons can use \
-                               storage_get_directory(id, ...)");
+                       _E("Only Tizen applications and user session daemons can use\
+                               storage_get_directory(INTERNAL_STORAGE_ID, ...)");
                        return STORAGE_ERROR_INVALID_PARAMETER;
                }