From c075e0569c9f8059dbda2a7d8111143a35e7569d Mon Sep 17 00:00:00 2001 From: Taeyoung Kim Date: Tue, 10 May 2016 20:46:15 +0900 Subject: [PATCH] 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 --- src/statvfs.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) 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) -- 2.7.4