vold: include multiple devices for calculating storage size
Since F2FS supports multiple devices, we must include all the sizes of
them into the storage size.
Bug: 377560222
Test: check the total size in Setting
Change-Id: I4252733e16dac60f07899b29b016e7f11ef9a2ed
Signed-off-by: Daeho Jeong <daehojeong@google.com>
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index a7c87a3..d932ec8 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -1247,19 +1247,11 @@
return android::vold::OpenAppFuseFile(uid, mountId, fileId, flags);
}
-android::status_t android::vold::GetStorageSize(int64_t* storageSize) {
- // Start with the /data mount point from fs_mgr
- auto entry = android::fs_mgr::GetEntryForMountPoint(&fstab_default, DATA_MNT_POINT);
- if (entry == nullptr) {
- LOG(ERROR) << "No mount point entry for " << DATA_MNT_POINT;
- return EINVAL;
- }
-
+static android::status_t getDeviceSize(std::string& device, int64_t* storageSize) {
// Follow any symbolic links
- std::string blkDevice = entry->blk_device;
std::string dataDevice;
- if (!android::base::Realpath(blkDevice, &dataDevice)) {
- dataDevice = blkDevice;
+ if (!android::base::Realpath(device, &dataDevice)) {
+ dataDevice = device;
}
// Handle mapped volumes.
@@ -1311,3 +1303,29 @@
*storageSize *= 512;
return OK;
}
+
+android::status_t android::vold::GetStorageSize(int64_t* storageSize) {
+ android::status_t status;
+ // Start with the /data mount point from fs_mgr
+ auto entry = android::fs_mgr::GetEntryForMountPoint(&fstab_default, DATA_MNT_POINT);
+ if (entry == nullptr) {
+ LOG(ERROR) << "No mount point entry for " << DATA_MNT_POINT;
+ return EINVAL;
+ }
+
+ status = getDeviceSize(entry->blk_device, storageSize);
+ if (status != OK) {
+ return status;
+ }
+
+ for (auto device : entry->user_devices) {
+ int64_t deviceStorageSize;
+ status = getDeviceSize(device, &deviceStorageSize);
+ if (status != OK) {
+ return status;
+ }
+ *storageSize += deviceStorageSize;
+ }
+
+ return OK;
+}