Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5840af7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "allow adb to remount symlink mount points" into pie-gsi

parents 41676471 25d86f56
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

#include <string>

#include <android-base/file.h>
#include <android-base/properties.h>

#include "adb.h"
@@ -36,6 +37,8 @@
#include "adb_utils.h"
#include "fs_mgr.h"

using android::base::Realpath;

// Returns the device used to mount a directory in /proc/mounts.
static std::string find_proc_mount(const char* dir) {
    std::unique_ptr<FILE, int(*)(FILE*)> fp(setmntent("/proc/mounts", "r"), endmntent);
@@ -43,9 +46,15 @@ static std::string find_proc_mount(const char* dir) {
        return "";
    }

    // dir might be a symlink, e.g., /product -> /system/product in GSI.
    std::string canonical_path;
    if (!Realpath(dir, &canonical_path)) {
        PLOG(ERROR) << "Realpath failed: " << dir;
    }

    mntent* e;
    while ((e = getmntent(fp.get())) != nullptr) {
        if (strcmp(dir, e->mnt_dir) == 0) {
        if (canonical_path == e->mnt_dir) {
            return e->mnt_fsname;
        }
    }