diff options
author | Tao Bao <tbao@google.com> | 2017-03-28 21:12:36 -0700 |
---|---|---|
committer | Tao Bao <tbao@google.com> | 2017-03-28 21:21:28 -0700 |
commit | 5f85d1fb0a2f7dd85b2f1acabcce2d227a60b29c (patch) | |
tree | c1a706a6ea55d4bf42806bb785aecbeae0d88811 /mounts.cpp | |
parent | 34df98ee6dfaec9b95c2f5d3e6f64c0daacc1958 (diff) | |
download | android_bootable_recovery-5f85d1fb0a2f7dd85b2f1acabcce2d227a60b29c.tar.gz android_bootable_recovery-5f85d1fb0a2f7dd85b2f1acabcce2d227a60b29c.tar.bz2 android_bootable_recovery-5f85d1fb0a2f7dd85b2f1acabcce2d227a60b29c.zip |
Log the error message when failing to mount/umount.
Test: Observe the error messaage for a umount failure case.
Bug: 36686818
Change-Id: I28e335c2df4454dd0192f95e3909599fcc9dc1c0
Diffstat (limited to 'mounts.cpp')
-rw-r--r-- | mounts.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
@@ -27,6 +27,8 @@ #include <string> #include <vector> +#include <android-base/logging.h> + struct MountedVolume { std::string device; std::string mount_point; @@ -75,15 +77,23 @@ MountedVolume* find_mounted_volume_by_mount_point(const char* mount_point) { } int unmount_mounted_volume(MountedVolume* volume) { - // Intentionally pass the empty string to umount if the caller tries - // to unmount a volume they already unmounted using this - // function. - std::string mount_point = volume->mount_point; - volume->mount_point.clear(); - return umount(mount_point.c_str()); + // Intentionally pass the empty string to umount if the caller tries to unmount a volume they + // already unmounted using this function. + std::string mount_point = volume->mount_point; + volume->mount_point.clear(); + int result = umount(mount_point.c_str()); + if (result == -1) { + PLOG(WARNING) << "Failed to umount " << mount_point; + } + return result; } int remount_read_only(MountedVolume* volume) { - return mount(volume->device.c_str(), volume->mount_point.c_str(), volume->filesystem.c_str(), - MS_NOATIME | MS_NODEV | MS_NODIRATIME | MS_RDONLY | MS_REMOUNT, 0); + int result = mount(volume->device.c_str(), volume->mount_point.c_str(), + volume->filesystem.c_str(), + MS_NOATIME | MS_NODEV | MS_NODIRATIME | MS_RDONLY | MS_REMOUNT, 0); + if (result == -1) { + PLOG(WARNING) << "Failed to remount read-only " << volume->mount_point; + } + return result; } |