diff options
author | Tao Bao <tbao@google.com> | 2017-03-29 08:29:11 +0200 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-29 08:29:11 +0200 |
commit | 6ac5c7c4d1fe76476ef42a548ab1382b544af772 (patch) | |
tree | 3ad81f8fb5def6ac09dea3349f1834a8646b35ab | |
parent | resolve merge conflicts of 39ef2d7f to oc-dev-plus-aosp (diff) | |
parent | Merge "Log the error message when failing to mount/umount." am: 850f89f198 (diff) | |
download | android_bootable_recovery-6ac5c7c4d1fe76476ef42a548ab1382b544af772.tar android_bootable_recovery-6ac5c7c4d1fe76476ef42a548ab1382b544af772.tar.gz android_bootable_recovery-6ac5c7c4d1fe76476ef42a548ab1382b544af772.tar.bz2 android_bootable_recovery-6ac5c7c4d1fe76476ef42a548ab1382b544af772.tar.lz android_bootable_recovery-6ac5c7c4d1fe76476ef42a548ab1382b544af772.tar.xz android_bootable_recovery-6ac5c7c4d1fe76476ef42a548ab1382b544af772.tar.zst android_bootable_recovery-6ac5c7c4d1fe76476ef42a548ab1382b544af772.zip |
-rw-r--r-- | Android.mk | 6 | ||||
-rw-r--r-- | mounts.cpp | 26 |
2 files changed, 22 insertions, 10 deletions
diff --git a/Android.mk b/Android.mk index 58b8a2240..037aa1673 100644 --- a/Android.mk +++ b/Android.mk @@ -29,9 +29,11 @@ include $(BUILD_STATIC_LIBRARY) # =============================== include $(CLEAR_VARS) LOCAL_SRC_FILES := mounts.cpp -LOCAL_CLANG := true -LOCAL_CFLAGS := -Wall -Wno-unused-parameter -Werror +LOCAL_CFLAGS := \ + -Wall \ + -Werror LOCAL_MODULE := libmounts +LOCAL_STATIC_LIBRARIES := libbase include $(BUILD_STATIC_LIBRARY) # recovery (static executable) diff --git a/mounts.cpp b/mounts.cpp index f23376b06..fbcbac014 100644 --- a/mounts.cpp +++ b/mounts.cpp @@ -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; } |