external: return storage size 0 if external storage does not exist 33/68933/1 accepted/tizen/common/20160511.142008 accepted/tizen/ivi/20160511.080634 accepted/tizen/mobile/20160511.080534 accepted/tizen/tv/20160511.080552 accepted/tizen/wearable/20160511.080621 submit/tizen/20160510.124102
authorTaeyoung Kim <ty317.kim@samsung.com>
Tue, 10 May 2016 11:46:15 +0000 (20:46 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Tue, 10 May 2016 11:46:15 +0000 (20:46 +0900)
- Previously, error was returned if external storage does not
  exist when getting storage size. But it is fixed to return
  size 0 for the backward compatibility.

Change-Id: I84eca101a740729cc038f7e02b6db97536913ca9
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
src/statvfs.c

index 6ccdb5e..dd038af 100644 (file)
@@ -347,16 +347,16 @@ int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf)
                snprintf(ext_path, sizeof(ext_path), "%s", path);
        else {
                ret = get_external_path(ext_path, sizeof(ext_path));
+               if (ret == -ENODEV)
+                       goto out_nodev;
                if (ret < 0) {
                        _E("Failed to get external path(%d)", ret);
                        return ret;
                }
        }
 
-       if (!mount_check(ext_path)) {
-               memset(buf, 0, sizeof(struct statvfs_32));
-               return 0;
-       }
+       if (!mount_check(ext_path))
+               goto out_nodev;
 
        ret = get_memory_size(ext_path, &temp);
        if (ret) {
@@ -366,6 +366,10 @@ int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf)
 
        memcpy(buf, &temp, sizeof(temp));
        return 0;
+
+out_nodev:
+       memset(buf, 0, sizeof(struct statvfs_32));
+       return 0;
 }
 
 int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf)
@@ -383,16 +387,16 @@ int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf
                snprintf(ext_path, sizeof(ext_path), "%s", path);
        else {
                ret = get_external_path(ext_path, sizeof(ext_path));
+               if (ret == -ENODEV)
+                       goto out_nodev;
                if (ret < 0) {
                        _E("Failed to get external path(%d)", ret);
                        return ret;
                }
        }
 
-       if (!mount_check(ext_path)) {
-               memset(buf, 0, sizeof(struct statvfs));
-               return 0;
-       }
+       if (!mount_check(ext_path))
+               goto out_nodev;
 
        ret = statvfs(ext_path, buf);
        if (ret) {
@@ -401,6 +405,10 @@ int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf
        }
 
        return 0;
+
+out_nodev:
+       memset(buf, 0, sizeof(struct statvfs));
+       return 0;
 }
 
 API int storage_get_external_memory_size(struct statvfs *buf)