Chromium Code Reviews| Index: base/sys_info_posix.cc |
| diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc |
| index 5d1c450139a575705c3c5046ed32c565e4b5e404..65d050ab12afbba79c8301ebf874af1265a630f4 100644 |
| --- a/base/sys_info_posix.cc |
| +++ b/base/sys_info_posix.cc |
| @@ -73,6 +73,10 @@ base::LazyInstance< |
| base::internal::LazySysInfoValue<int64_t, AmountOfVirtualMemory>>::Leaky |
| g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER; |
| +} // namespace |
|
Lei Zhang
2016/07/19 23:45:10
No, that's not what I meant.
namespace base {
na
Sriram
2016/07/19 23:58:37
Done.
|
| + |
| +namespace base { |
| + |
| bool GetDiskSpaceInfo(const base::FilePath& path, |
| int64_t* available_bytes, |
| int64_t* total_bytes) { |
| @@ -80,16 +84,31 @@ 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; |
| - return true; |
| -} |
| +#if defined(OS_LINUX) |
| + // On Linux, stats.f_blocks is 0 when memory based file system like tmpfs, |
| + // ramfs, or hugetlbfs (all memory file systems). the is mounted without any |
|
Lei Zhang
2016/07/19 23:45:10
So have you checked the ramfs / hugetlbfs behavior
Lei Zhang
2016/07/19 23:45:10
typo: "the is mounted"
Sriram
2016/07/19 23:58:37
Yes, See Linux code for:
hugetlbfs - http://lxr.fr
Sriram
2016/07/19 23:58:37
Done.
|
| + // size limit (i.e. size set to 0). |
| + FileSystemType fs_type; |
| + const bool zero_size_means_unlimited = stats.f_blocks == 0 && |
| + GetFileSystemType(path, &fs_type) && |
| + fs_type == FILE_SYSTEM_MEMORY; |
| +#else |
| + const bool zero_size_means_unlimited = false; |
| +#endif |
| -} // namespace |
| + if (available_bytes) { |
| + *available_bytes = zero_size_means_unlimited ? |
| + std::numeric_limits<int64_t>::max() : |
| + static_cast<int64_t>(stats.f_bavail) * stats.f_frsize; |
| + } |
| -namespace base { |
| + if (total_bytes) { |
| + *total_bytes = zero_size_means_unlimited ? |
| + std::numeric_limits<int64_t>::max() : |
| + static_cast<int64_t>(stats.f_blocks) * stats.f_frsize; |
| + } |
| + return true; |
| +} |
| #if !defined(OS_OPENBSD) |
| int SysInfo::NumberOfProcessors() { |