From: Taeyoung Kim Date: Tue, 10 May 2016 11:46:15 +0000 (+0900) Subject: external: return storage size 0 if external storage does not exist X-Git-Tag: accepted/tizen/common/20160511.142008^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F33%2F68933%2F1;p=platform%2Fcore%2Fsystem%2Flibstorage.git external: return storage size 0 if external storage does not exist - 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 --- diff --git a/src/statvfs.c b/src/statvfs.c index 6ccdb5e..dd038af 100644 --- a/src/statvfs.c +++ b/src/statvfs.c @@ -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)