OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" |
6 | 6 |
7 #include <sys/stat.h> | 7 #include <sys/stat.h> |
8 #include <sys/statvfs.h> | 8 #include <sys/statvfs.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #include <utime.h> | 10 #include <utime.h> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 // Retrieves total and remaining available size on |mount_path|. | 130 // Retrieves total and remaining available size on |mount_path|. |
131 void GetSizeStatsOnBlockingPool(const std::string& mount_path, | 131 void GetSizeStatsOnBlockingPool(const std::string& mount_path, |
132 uint64* total_size, | 132 uint64* total_size, |
133 uint64* remaining_size) { | 133 uint64* remaining_size) { |
134 struct statvfs stat = {}; // Zero-clear | 134 struct statvfs stat = {}; // Zero-clear |
135 if (HANDLE_EINTR(statvfs(mount_path.c_str(), &stat)) == 0) { | 135 if (HANDLE_EINTR(statvfs(mount_path.c_str(), &stat)) == 0) { |
136 *total_size = | 136 *total_size = |
137 static_cast<uint64>(stat.f_blocks) * stat.f_frsize; | 137 static_cast<uint64>(stat.f_blocks) * stat.f_frsize; |
138 *remaining_size = | 138 *remaining_size = |
139 static_cast<uint64>(stat.f_bfree) * stat.f_frsize; | 139 static_cast<uint64>(stat.f_bavail) * stat.f_frsize; |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 // Retrieves the maximum file name length of the file system of |path|. | 143 // Retrieves the maximum file name length of the file system of |path|. |
144 // Returns 0 if it could not be queried. | 144 // Returns 0 if it could not be queried. |
145 size_t GetFileNameMaxLengthOnBlockingPool(const std::string& path) { | 145 size_t GetFileNameMaxLengthOnBlockingPool(const std::string& path) { |
146 struct statvfs stat = {}; | 146 struct statvfs stat = {}; |
147 if (statvfs(path.c_str(), &stat) != 0) { | 147 if (statvfs(path.c_str(), &stat) != 0) { |
148 // The filesystem seems not supporting statvfs(). Assume it to be a commonly | 148 // The filesystem seems not supporting statvfs(). Assume it to be a commonly |
149 // used bound 255, and log the failure. | 149 // used bound 255, and log the failure. |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 render_view_host(), profile(), GURL(volume_file_url)); | 592 render_view_host(), profile(), GURL(volume_file_url)); |
593 if (file_path.empty()) | 593 if (file_path.empty()) |
594 return false; | 594 return false; |
595 | 595 |
596 DiskMountManager::GetInstance()->FormatMountedDevice(file_path.value()); | 596 DiskMountManager::GetInstance()->FormatMountedDevice(file_path.value()); |
597 SendResponse(true); | 597 SendResponse(true); |
598 return true; | 598 return true; |
599 } | 599 } |
600 | 600 |
601 } // namespace file_manager | 601 } // namespace file_manager |
OLD | NEW |