update_engine: Attempt to mount the ROOTFS as squashfs during postinst.
This patch extends utils::MountFilesystem() to attempt to mount
the device as ext3, ext2 and squashfs before failing.
BUG=chromium:432016
TEST=None
Change-Id: Ibad2f359968d7abe9f82f11c895cac95130d73c5
Reviewed-on: https://chromium-review.googlesource.com/229020
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/utils.cc b/utils.cc
index 99a02d3..f0bf6f7 100644
--- a/utils.cc
+++ b/utils.cc
@@ -625,15 +625,19 @@
bool MountFilesystem(const string& device,
const string& mountpoint,
unsigned long mountflags) { // NOLINT(runtime/int)
- int rc = mount(device.c_str(), mountpoint.c_str(), "ext3", mountflags,
- nullptr);
- if (rc < 0) {
- string msg = ErrnoNumberAsString(errno);
- LOG(ERROR) << "Unable to mount destination device: " << msg << ". "
- << device << " on " << mountpoint;
- return false;
+ // TODO(sosa): Remove "ext3" once crbug.com/208022 is resolved.
+ const vector<const char*> fstypes{"ext2", "ext3", "squashfs"};
+ for (const char* fstype : fstypes) {
+ int rc = mount(device.c_str(), mountpoint.c_str(), fstype, mountflags,
+ nullptr);
+ if (rc == 0)
+ return true;
+
+ PLOG(WARNING) << "Unable to mount destination device " << device
+ << " on " << mountpoint << " as " << fstype;
}
- return true;
+ LOG(ERROR) << "Unable to mount " << device << " with any supported type";
+ return false;
}
bool UnmountFilesystem(const string& mountpoint) {