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

Commit 430fcc8a authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Check if sandbox is prepared before mounting pkg specific dirs.

Bug: 123948473
Test: manual
Change-Id: I250f3f84b0cac3cccc2d6f79183d85c5a17e2e09
parent 7d3adab5
Loading
Loading
Loading
Loading
+17 −0
Original line number Original line Diff line number Diff line
@@ -646,6 +646,23 @@ static void MountPkgSpecificDir(const std::string& mntSourceRoot,
static void PreparePkgSpecificDirs(const std::vector<std::string>& packageNames,
static void PreparePkgSpecificDirs(const std::vector<std::string>& packageNames,
                                   const std::vector<std::string>& volumeLabels,
                                   const std::vector<std::string>& volumeLabels,
                                   bool mountAllObbs, userid_t userId, fail_fn_t fail_fn) {
                                   bool mountAllObbs, userid_t userId, fail_fn_t fail_fn) {
    if (volumeLabels.size() > 0) {
        std::string sandboxDataDir = StringPrintf("/storage/%s", volumeLabels[0].c_str());
        if (volumeLabels[0] == "emulated") {
            StringAppendF(&sandboxDataDir, "/%d", userId);
        }
        StringAppendF(&sandboxDataDir, "/Android/data/%s", packageNames[0].c_str());
        struct stat sb;
        if (TEMP_FAILURE_RETRY(lstat(sandboxDataDir.c_str(), &sb)) == -1) {
            if (errno == ENOENT) {
                ALOGD("Sandbox not fully prepared for %s", sandboxDataDir.c_str());
                return;
            } else {
                fail_fn(CREATE_ERROR("Failed to lstat %s: %s",
                                     sandboxDataDir.c_str(), strerror(errno)));
            }
        }
    }
    for (auto& label : volumeLabels) {
    for (auto& label : volumeLabels) {
        std::string mntSource = StringPrintf("/mnt/runtime/write/%s", label.c_str());
        std::string mntSource = StringPrintf("/mnt/runtime/write/%s", label.c_str());
        std::string mntTarget = StringPrintf("/storage/%s", label.c_str());
        std::string mntTarget = StringPrintf("/storage/%s", label.c_str());