summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Jung <jh8801.jung@samsung.com>2018-07-20 15:43:22 +0900
committersaerome.kim <saerome.kim@samsung.com>2018-07-20 17:37:17 +0900
commitb1c3e40ab7c21c4a1eeb0ee8f034b06470f70fdc (patch)
treef76ddb314959da83385eac85d4a61b1f7a08af36
parentc0158cb8bea0ec7b4db6a70d4581f9d44ac7fcee (diff)
downloadmtp-responder-b1c3e40ab7c21c4a1eeb0ee8f034b06470f70fdc.tar.gz
mtp-responder-b1c3e40ab7c21c4a1eeb0ee8f034b06470f70fdc.tar.bz2
mtp-responder-b1c3e40ab7c21c4a1eeb0ee8f034b06470f70fdc.zip
Change impl about get total / avaiable storage sizesubmit/tizen/20180720.091301accepted/tizen/unified/20180723.151434
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com> Change-Id: Iaff928591797b98c5f66e7a5b74c11339d4b98ec
-rwxr-xr-xCMakeLists.txt2
-rwxr-xr-xsrc/util/mtp_fs.c45
2 files changed, 44 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b384e2..87b74f9 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,7 +23,7 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror-implicit-function-declaration")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fexceptions -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
-SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -pie -Wl,--hash-style=both,-z,relro")
+SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -pie -Wl,--hash-style=both,-z,relroi ")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} pthread rt gcrypt)
diff --git a/src/util/mtp_fs.c b/src/util/mtp_fs.c
index 4085c0e..5723dba 100755
--- a/src/util/mtp_fs.c
+++ b/src/util/mtp_fs.c
@@ -26,6 +26,7 @@
#include <dirent.h>
#include <glib.h>
#include <glib/gprintf.h>
+#include <storage.h>
#include "mtp_fs.h"
#include "mtp_util.h"
#include "mtp_support.h"
@@ -753,7 +754,8 @@ mtp_bool _util_ifind_next(mtp_char *dir_name, DIR *dirp, dir_entry_t *dir_info)
return TRUE;
}
-mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info)
+mtp_bool _util_get_filesystem_info_ext(mtp_char *storepath,
+ fs_info_t *fs_info)
{
struct statfs buf = { 0 };
mtp_uint64 avail_size = 0;
@@ -761,7 +763,7 @@ mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info)
mtp_uint64 used_size = 0;
if (statfs(storepath, &buf) != 0) {
- ERR("statfs Fail");
+ ERR("statfs is failed\n");
return FALSE;
}
@@ -778,6 +780,45 @@ mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info)
return TRUE;
}
+mtp_bool _util_get_filesystem_info_int(mtp_char *storepath, fs_info_t *fs_info)
+{
+ struct statvfs s;
+ int ret;
+
+ mtp_uint64 avail_size = 0;
+ mtp_uint64 capacity = 0;
+ mtp_uint64 used_size = 0;
+
+ ret = storage_get_internal_memory_size(&s);
+ if (ret < 0) {
+ ERR("storage_get_internal_memory_size : ret = %d", ret);
+ return FALSE;
+ }
+
+ capacity = (mtp_uint64)s.f_frsize*s.f_blocks;
+ avail_size = (mtp_uint64)s.f_bsize*s.f_bavail;
+ used_size = (capacity - avail_size);
+
+ DBG("total : %llu , avail %llu , used %llu", capacity, avail_size, used_size);
+
+ fs_info->disk_size = capacity;
+ fs_info->reserved_size = used_size;
+ fs_info->avail_size = avail_size;
+
+ return TRUE;
+}
+
+mtp_bool _util_get_filesystem_info(mtp_char *storepath,
+ fs_info_t *fs_info)
+{
+ if (!g_strcmp0(storepath, MTP_EXTERNAL_PATH_CHAR))
+ return _util_get_filesystem_info_ext(storepath, fs_info);
+ else
+ return _util_get_filesystem_info_int(storepath, fs_info);
+
+ return FALSE;
+}
+
void _util_count_num_lines(FILE* fhandle, mtp_uint32 *num_lines)
{
if (fhandle == NULL)