Loading Android.mk +4 −2 Original line number Original line Diff line number Diff line Loading @@ -29,9 +29,11 @@ include $(BUILD_STATIC_LIBRARY) # =============================== # =============================== include $(CLEAR_VARS) include $(CLEAR_VARS) LOCAL_SRC_FILES := mounts.cpp LOCAL_SRC_FILES := mounts.cpp LOCAL_CLANG := true LOCAL_CFLAGS := \ LOCAL_CFLAGS := -Wall -Wno-unused-parameter -Werror -Wall \ -Werror LOCAL_MODULE := libmounts LOCAL_MODULE := libmounts LOCAL_STATIC_LIBRARIES := libbase include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY) # recovery (static executable) # recovery (static executable) Loading mounts.cpp +18 −8 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,8 @@ #include <string> #include <string> #include <vector> #include <vector> #include <android-base/logging.h> struct MountedVolume { struct MountedVolume { std::string device; std::string device; std::string mount_point; std::string mount_point; Loading Loading @@ -75,15 +77,23 @@ MountedVolume* find_mounted_volume_by_mount_point(const char* mount_point) { } } int unmount_mounted_volume(MountedVolume* volume) { int unmount_mounted_volume(MountedVolume* volume) { // Intentionally pass the empty string to umount if the caller tries // Intentionally pass the empty string to umount if the caller tries to unmount a volume they // to unmount a volume they already unmounted using this // already unmounted using this function. // function. std::string mount_point = volume->mount_point; std::string mount_point = volume->mount_point; volume->mount_point.clear(); volume->mount_point.clear(); return umount(mount_point.c_str()); 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) { int remount_read_only(MountedVolume* volume) { return mount(volume->device.c_str(), volume->mount_point.c_str(), volume->filesystem.c_str(), 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); 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; } } Loading
Android.mk +4 −2 Original line number Original line Diff line number Diff line Loading @@ -29,9 +29,11 @@ include $(BUILD_STATIC_LIBRARY) # =============================== # =============================== include $(CLEAR_VARS) include $(CLEAR_VARS) LOCAL_SRC_FILES := mounts.cpp LOCAL_SRC_FILES := mounts.cpp LOCAL_CLANG := true LOCAL_CFLAGS := \ LOCAL_CFLAGS := -Wall -Wno-unused-parameter -Werror -Wall \ -Werror LOCAL_MODULE := libmounts LOCAL_MODULE := libmounts LOCAL_STATIC_LIBRARIES := libbase include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY) # recovery (static executable) # recovery (static executable) Loading
mounts.cpp +18 −8 Original line number Original line Diff line number Diff line Loading @@ -27,6 +27,8 @@ #include <string> #include <string> #include <vector> #include <vector> #include <android-base/logging.h> struct MountedVolume { struct MountedVolume { std::string device; std::string device; std::string mount_point; std::string mount_point; Loading Loading @@ -75,15 +77,23 @@ MountedVolume* find_mounted_volume_by_mount_point(const char* mount_point) { } } int unmount_mounted_volume(MountedVolume* volume) { int unmount_mounted_volume(MountedVolume* volume) { // Intentionally pass the empty string to umount if the caller tries // Intentionally pass the empty string to umount if the caller tries to unmount a volume they // to unmount a volume they already unmounted using this // already unmounted using this function. // function. std::string mount_point = volume->mount_point; std::string mount_point = volume->mount_point; volume->mount_point.clear(); volume->mount_point.clear(); return umount(mount_point.c_str()); 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) { int remount_read_only(MountedVolume* volume) { return mount(volume->device.c_str(), volume->mount_point.c_str(), volume->filesystem.c_str(), 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); 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; } }