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

Commit b9100a9a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13222886 from 53522470 to 25Q3-release

Change-Id: I868e1e264bd56279175c8e3bd1b741cb64f0dd53
parents d7547257 53522470
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -780,6 +780,19 @@ bool SetupPackageMount(const std::string& package_path, bool* should_use_fuse) {
      LOG(ERROR) << "Failed to mount " << block_map_path;
      return false;
    }
    auto block_map_data = BlockMapData::ParseBlockMapFile(block_map_path);
    if (!CheckPathCanonical(block_map_data.path())) {
      LOG(ERROR) << "Block map " << package_path << " contains non-canonical path "
                 << block_map_data.path() << " abort installation.";
      return false;
    }
    if (!BlockDevHasFstab(block_map_data.path())) {
      LOG(ERROR) << "Block device " << block_map_path
                 << " does not have corresponding fstab. This might be an external device, "
                    "aborting installation.";
      return false;
    }

    // uncrypt only produces block map only if the package stays on /data.
    *should_use_fuse = false;
    return true;
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ Volume* volume_for_mount_point(const std::string& mount_point);
// success (volume is mounted).
int ensure_path_mounted(const std::string& path);

// Return true if the block device has a corresponding entry
// in fstab
bool BlockDevHasFstab(const std::string& path);

// Similar to ensure_path_mounted, but allows one to specify the mount_point.
int ensure_path_mounted_at(const std::string& path, const std::string& mount_point);

+20 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <string>
#include <vector>

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
@@ -90,6 +91,25 @@ int ensure_path_unmounted(const std::string& path) {
  return android::fs_mgr::EnsurePathUnmounted(&fstab, path) ? 0 : -1;
}

bool BlockDevHasFstab(const std::string& path) {
  std::string bdev_path;
  if (!android::base::Realpath(path, &bdev_path)) {
    PLOG(ERROR) << "Failed to get realpath for " << path;
    return false;
  }
  for (const auto& entry : fstab) {
    std::string fstab_bdev_path;
    if (!android::base::Realpath(entry.blk_device, &fstab_bdev_path)) {
      PLOG(ERROR) << "Failed to get realpath for " << entry.blk_device;
      return false;
    }
    if (fstab_bdev_path == bdev_path) {
      return true;
    }
  }
  return false;
}

static int exec_cmd(const std::vector<std::string>& args) {
  CHECK(!args.empty());
  auto argv = StringVectorToNullTerminatedArray(args);