From 9ec1a4f0bfdc76fd11f387b974871d0928d21c90 Mon Sep 17 00:00:00 2001 From: Jung Date: Mon, 19 Sep 2016 20:55:46 -0700 Subject: [PATCH] Revert "Revert "Supporting Internal Media Path Compatibility"" This reverts commit ea3ccd13aa047b695a4a5a56d9f9c43c31e75042. Change-Id: I63a2a0152be707b36deba35ffc94b1c32f97538f --- CMakeLists.txt | 1 + packaging/libstorage.spec | 1 + src/storage-internal.c | 29 ++++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55924cd..a8c5f4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ SET(dependents gio-2.0 libtzplatform-config capi-system-system-settings + mount ) SET(pc_dependents "capi-base-common") diff --git a/packaging/libstorage.spec b/packaging/libstorage.spec index 0204e53..ee26b84 100644 --- a/packaging/libstorage.spec +++ b/packaging/libstorage.spec @@ -14,6 +14,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(capi-system-system-settings) +BuildRequires: pkgconfig(mount) %description development package of library to get storage diff --git a/src/storage-internal.c b/src/storage-internal.c index 1867def..9be1060 100755 --- a/src/storage-internal.c +++ b/src/storage-internal.c @@ -22,10 +22,12 @@ #include #include #include +#include #include "common.h" #include "log.h" +#define COMPAT_DIR "/opt/usr/media" #ifndef __USE_FILE_OFFSET64 int __WEAK__ storage_get_internal_memory_size(struct statvfs *buf); @@ -60,7 +62,32 @@ static int internal_get_space(unsigned long long *total, unsigned long long *ava static const char *internal_get_root(void) { - return tzplatform_getenv(TZ_USER_CONTENT); + struct libmnt_table *t = NULL; + int r = 0; + struct libmnt_fs *fs; + const char *ret; + + ret = tzplatform_getenv(TZ_USER_CONTENT); + + t = mnt_new_table(); + if(!t) + return ret; + + r = mnt_table_parse_mtab(t, NULL); + if (r < 0) { + mnt_free_table(t); + return ret; + } + + fs = mnt_table_find_target(t, COMPAT_DIR, MNT_ITER_BACKWARD); + if (fs) { + // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT). + ret = COMPAT_DIR; + } + + mnt_free_table(t); + + return ret; } const struct storage_ops internal = { -- 2.7.4