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

Commit c7619ba6 authored by Steve Kondik's avatar Steve Kondik Committed by Michael Bestas
Browse files

recovery: Puke out an /etc/fstab so stuff like busybox/toybox is happy

 * And disregard special mount flags on purpose because of certain
   dubious packages which "exec busybox mount".

Change-Id: I163702c9bd7fca3d40676fd6d8476e8deb13acc0
parent 90a3fde3
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -49,6 +49,16 @@ using android::fs_mgr::Fstab;
using android::fs_mgr::FstabEntry;
using android::fs_mgr::ReadDefaultFstab;

static void write_fstab_entry(const FstabEntry& entry, FILE* file) {
  if (entry.fs_type != "emmc" && !entry.fs_mgr_flags.vold_managed && !entry.blk_device.empty() &&
      entry.blk_device[0] == '/' && !entry.mount_point.empty() && entry.mount_point[0] == '/') {
    fprintf(file, "%s ", entry.blk_device.c_str());
    fprintf(file, "%s ", entry.mount_point.c_str());
    fprintf(file, "%s ", entry.fs_type.c_str());
    fprintf(file, "%s 0 0\n", entry.fs_options.empty() ? entry.fs_options.c_str() : "defaults");
  }
}

static Fstab fstab;

void load_volume_table() {
@@ -57,6 +67,12 @@ void load_volume_table() {
    return;
  }

  // Create a boring /etc/fstab so tools like Busybox work
  FILE* file = fopen("/etc/fstab", "w");
  if (!file) {
    LOG(ERROR) << "Unable to create /etc/fstab";
  }

  fstab.emplace_back(FstabEntry{
      .mount_point = "/tmp", .fs_type = "ramdisk", .blk_device = "ramdisk", .length = 0 });

@@ -66,8 +82,15 @@ void load_volume_table() {
    std::cout << "  " << i << " " << entry.mount_point << " "
              << " " << entry.fs_type << " " << entry.blk_device << " " << entry.length
              << std::endl;
    if (file) {
      write_fstab_entry(entry, file);
    }
  }
  std::cout << std::endl;

  if (file) {
    fclose(file);
  }
}

Volume* volume_for_mount_point(const std::string& mount_point) {