tizen 2.4 release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20151029.031840 submit/tizen_2.4/20151028.064630 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 08:04:11 +0000 (17:04 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 08:04:11 +0000 (17:04 +0900)
CMakeLists.txt
include/storage-expand.h
packaging/libstorage.spec
src/statvfs.c
src/storage-sdcard.c

index e4a7163..9e01995 100644 (file)
@@ -45,7 +45,7 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
 
 CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/libstorage.conf DESTINATION lib/pkgconfig RENAME libstorage.conf)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/libstorage.conf DESTINATION /etc/${PROJECT_NAME} RENAME libstorage.conf)
 
 FOREACH(hfile ${HEADERS})
        INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
index b4ddeca..83f3491 100644 (file)
@@ -161,7 +161,8 @@ typedef enum
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  *
  * @remarks The directory path may not exist, so you must make sure that it exists before using it.\n
- * If you want to access files or directories in internal storage, you must declare http://tizen.org/privilege/mediastorage.\n
+ * If you want to access files or directories in internal storage except #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare http://tizen.org/privilege/mediastorage.\n
+ * If you want to access files or directories in #STORAGE_DIRECTORY_SYSTEM_RINGTONES, you must declare %http://tizen.org/privilege/systemsettings.\n
  * If you want to access files or directories in external storage, you must declare http://tizen.org/privilege/externalstorage.\n
  * You must release @a path using free().
  *
index 3278b3c..3408d67 100644 (file)
@@ -3,7 +3,7 @@ Summary:    Library to get storage information
 Version:    0.1.0
 Release:    0
 Group:      System/Libraries
-License:    Apache-2.0
+License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    %{name}.manifest
 BuildRequires:  cmake
@@ -47,7 +47,7 @@ cp -a %{SOURCE1} %{buildroot}%{_datadir}/
 
 %files
 %{_libdir}/*.so.*
-%{_libdir}/pkgconfig/libstorage.conf
+%{_sysconfdir}/storage/libstorage.conf
 %{_datadir}/license/%{name}
 %manifest %{_datadir}/%{name}.manifest
 
index 96ff783..ff93b21 100644 (file)
@@ -34,7 +34,7 @@
 
 #define MEMORY_STATUS_USR_PATH "/opt/usr"
 #define EXTERNAL_MEMORY_PATH   "/opt/storage/sdcard"
-#define STORAGE_CONF_FILE      "/usr/lib/pkgconfig/libstorage.conf"
+#define STORAGE_CONF_FILE      "/etc/storage/libstorage.conf"
 
 /* it's for 32bit file offset */
 struct statvfs_32 {
@@ -192,7 +192,7 @@ static int load_config(struct parse_result *result, void *user_data)
        value = result->value;
 
        if (info->check_size > 0 && check_size < 0)
-               check_size = (storage_info.total_size < info->check_size)? 1 : 0;
+               check_size = (storage_info.total_size < info->check_size) ? 1 : 0;
        if (MATCH(name, "CHECK_SIZE"))
                info->check_size = atoi(value);
        else if (check_size == 0 && MATCH(name, "RESERVE"))
@@ -223,6 +223,8 @@ static int get_memory_size(const char *path, struct statvfs_32 *buf)
        if (ret)
                return -errno;
 
+       memset(buf, 0, sizeof(struct statvfs_32));
+
        buf->f_bsize  = s.f_bsize;
        buf->f_frsize = s.f_frsize;
        buf->f_blocks = (unsigned long)s.f_blocks;
@@ -240,7 +242,7 @@ static int get_memory_size(const char *path, struct statvfs_32 *buf)
 
 API int storage_get_internal_memory_size(struct statvfs *buf)
 {
-       struct statvfs_32 temp = {0,};
+       struct statvfs_32 temp;
        static unsigned long reserved = 0;
        int ret;
 
@@ -250,7 +252,7 @@ API int storage_get_internal_memory_size(struct statvfs *buf)
        }
 
        ret = get_memory_size(MEMORY_STATUS_USR_PATH, &temp);
-       if (ret) {
+       if (ret || temp.f_bsize == 0) {
                _E("fail to get memory size");
                return -errno;
        }
@@ -303,17 +305,17 @@ API int storage_get_internal_memory_size64(struct statvfs *buf)
        return 0;
 }
 
-static int mount_check(const charpath)
+static int mount_check(const char *path)
 {
        int ret = false;
-       struct mntentmnt;
-       const chartable = "/etc/mtab";
-       FILEfp;
+       struct mntent *mnt;
+       const char *table = "/etc/mtab";
+       FILE *fp;
 
        fp = setmntent(table, "r");
        if (!fp)
                return ret;
-       while ((mnt=getmntent(fp))) {
+       while ((mnt = getmntent(fp))) {
                if (!strcmp(mnt->mnt_dir, path)) {
                        ret = true;
                        break;
@@ -325,7 +327,7 @@ static int mount_check(const char* path)
 
 API int storage_get_external_memory_size(struct statvfs *buf)
 {
-       struct statvfs_32 temp = {0,};
+       struct statvfs_32 temp;
        int ret;
 
        _D("storage_get_external_memory_size");
index 65747af..70be220 100755 (executable)
@@ -61,13 +61,11 @@ static int sdcard_get_space(unsigned long long *total, unsigned long long *avail
 {
        storage_state_e state;
        struct statvfs s;
-       int ret, t, a;
+       int ret;
+       unsigned long long t = 0, a = 0;
 
        state = sdcard_get_state();
-       if (state < STORAGE_STATE_MOUNTED) {
-               t = 0;
-               a = 0;
-       } else {        /* if sdcard is mounted */
+       if (state >= STORAGE_STATE_MOUNTED) {
 #ifndef __USE_FILE_OFFSET64
                ret = storage_get_external_memory_size(&s);
 #else
@@ -93,7 +91,7 @@ static const char *sdcard_get_root(void)
        return SDCARD_PATH;
 }
 
-static void sdcard_state_cb(keynode_t* key, void* data)
+static void sdcard_state_cb(keynode_t *key, void *data)
 {
        struct storage_cb_info *cb_info;
        dd_list *elem;