Merge "vold: include multiple devices for calculating storage size" into main am: 305620215e am: 9fdcefd0f7
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/3349457
Change-Id: I9ad1c0962930beb74cd32862528f7f8fa521f06d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.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;
+}