Index: base/sys_info_posix.cc |
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc |
index 5d1c450139a575705c3c5046ed32c565e4b5e404..9f110c3cd6928477505232f304ce2ad216ac6d25 100644 |
--- a/base/sys_info_posix.cc |
+++ b/base/sys_info_posix.cc |
@@ -80,10 +80,19 @@ bool GetDiskSpaceInfo(const base::FilePath& path, |
if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0) |
return false; |
- if (available_bytes) |
- *available_bytes = static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; |
- if (total_bytes) |
- *total_bytes = static_cast<int64_t>(stats.f_blocks) * stats.f_frsize; |
+ // f_blocks is 0 when tmpfs is mounted without any size limit (i.e. size set |
Lei Zhang
2016/07/16 00:19:12
You need to check that the file system is tmpfs. T
Lei Zhang
2016/07/18 19:05:07
Basically something like the following, though it
Sriram
2016/07/19 23:41:32
Acknowledged.
Sriram
2016/07/19 23:41:32
Done.
|
+ // to 0). |
+ if (available_bytes) { |
+ *available_bytes = (stats.f_blocks == 0) ? |
+ std::numeric_limits<int64_t>::max() : |
+ static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; |
+ } |
+ |
+ if (total_bytes) { |
+ *total_bytes = (stats.f_blocks == 0) ? |
+ std::numeric_limits<int64_t>::max() : |
+ static_cast<int64_t>(stats.f_blocks) * stats.f_frsize; |
+ } |
return true; |
} |