Fix documentation for storage_get_internal_memory_size and storage_get_external_memor...
[platform/core/system/libstorage.git] / src / statvfs.c
index eda17bd..13c5561 100644 (file)
@@ -241,6 +241,7 @@ static int get_memory_size(const char *path, struct statvfs_32 *buf)
        return 0;
 }
 
+/* This api is intended for binaries built with _FILE_OFFSET_BITS=32 */
 API int storage_get_internal_memory_size(struct statvfs *buf)
 {
        struct statvfs_32 temp;
@@ -249,13 +250,13 @@ API int storage_get_internal_memory_size(struct statvfs *buf)
 
        if (!buf) {
                _E("input param error");
-               return -EINVAL;
+               return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
        ret = get_memory_size(tzplatform_getenv(TZ_SYS_HOME), &temp);
        if (ret || temp.f_bsize == 0) {
-               _E("fail to get memory size"); //LCOV_EXCL_LINE
-               return -errno; //LCOV_EXCL_LINE System Error
+               _E("fail to get memory size %d", ret); //LCOV_EXCL_LINE
+               return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        if (reserved == 0) {
@@ -272,9 +273,10 @@ API int storage_get_internal_memory_size(struct statvfs *buf)
                temp.f_bavail -= reserved;
 
        memcpy(buf, &temp, sizeof(temp));
-       return 0;
+       return STORAGE_ERROR_NONE;
 }
 
+/* This api is intended for binaries built with __USE_FILE_OFFSET64(_FILE_OFFSET_BITS=64) */
 API int storage_get_internal_memory_size64(struct statvfs *buf)
 {
        static unsigned long reserved = 0;
@@ -282,13 +284,13 @@ API int storage_get_internal_memory_size64(struct statvfs *buf)
 
        if (!buf) {
                _E("input param error"); //LCOV_EXCL_LINE
-               return -EINVAL;
+               return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
        ret = statvfs(tzplatform_getenv(TZ_SYS_HOME), buf);
        if (ret) {
                _E("fail to get memory size"); //LCOV_EXCL_LINE
-               return -errno; //LCOV_EXCL_LINE System Error
+               return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        if (reserved == 0) {
@@ -303,7 +305,7 @@ API int storage_get_internal_memory_size64(struct statvfs *buf)
                buf->f_bavail = 0;
        else
                buf->f_bavail -= reserved;
-       return 0;
+       return STORAGE_ERROR_NONE;
 }
 
 static int mount_check(char *path)
@@ -331,6 +333,7 @@ static int get_external_path(char *path, size_t len)
        return storage_ext_get_primary_mmc_path(path, len);
 }
 
+/* This api is intended for binaries built with _FILE_OFFSET_BITS=32 */
 int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf)
 {
        struct statvfs_32 temp;
@@ -340,18 +343,22 @@ int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf)
        _D("storage_get_external_memory_size");
        if (!buf) {
                _E("input param error");
-               return -EINVAL;
+               return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
        if (path)
                snprintf(ext_path, sizeof(ext_path), "%s", path);
        else {
+               if (!storage_ext_is_supported()) {
+                       _D("Block module is not enabled");
+                       goto out_nodev;
+               }
                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); //LCOV_EXCL_LINE
-                       return ret;
+                       return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
                }
        }
 
@@ -361,7 +368,7 @@ int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf)
        ret = get_memory_size(ext_path, &temp);
        if (ret) {
                _E("fail to get memory size"); //LCOV_EXCL_LINE
-               return -errno; //LCOV_EXCL_LINE System Error
+               return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        }
 
        memcpy(buf, &temp, sizeof(temp));
@@ -369,9 +376,10 @@ int storage_get_external_memory_size_with_path(char *path, struct statvfs *buf)
 
 out_nodev:
        memset(buf, 0, sizeof(struct statvfs_32));
-       return 0;
+       return STORAGE_ERROR_NONE;
 }
 
+/* This api is intended for binaries built with __USE_FILE_OFFSET64(_FILE_OFFSET_BITS=64) */
 int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf)
 {
        int ret;
@@ -380,18 +388,22 @@ int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf
        _D("storage_get_external_memory_size64");
        if (!buf) {
                _E("input param error");
-               return -EINVAL;
+               return STORAGE_ERROR_INVALID_PARAMETER;
        }
 
        if (path)
                snprintf(ext_path, sizeof(ext_path), "%s", path);
        else {
+               if (!storage_ext_is_supported()) {
+                       _D("Block module is not enabled");
+                       goto out_nodev;
+               }
                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;
+                       return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
                }
        }
 
@@ -402,11 +414,11 @@ int storage_get_external_memory_size64_with_path(char *path, struct statvfs *buf
        if (ret) {
        //LCOV_EXCL_START System Error
                _E("fail to get memory size");
-               return -errno;
+               return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
        //LCOV_EXCL_STOP
        }
 
-       return 0;
+       return STORAGE_ERROR_NONE;
 
 out_nodev:
        memset(buf, 0, sizeof(struct statvfs));