update_engine: Generate valid delta files for squashfs.
This patch generates a valid (but inefficient) payload when a delta
payload is requested for a squashfs filesystem.
Since we are reusing the full payload generator for this purpose, this
patch relaxes the requirement of chunk_size to be positive in the
full_update_generator.cc code, replacing it by the default value of
1 MiB when nothing is passed.
BUG=chromium:430950
TEST=FEATURES=test emerge-link update_engine
TEST=cros_generate_update_payload for a delta payload works with
squashfs
TEST=`cros flash` a squashfs device with a delta payload works.
Change-Id: I88c7a571874c4c4697f528d44c52091aa1aed0c5
Reviewed-on: https://chromium-review.googlesource.com/260444
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/utils.cc b/utils.cc
index 7b3c6d0..c076682 100644
--- a/utils.cc
+++ b/utils.cc
@@ -811,6 +811,24 @@
return true;
}
+bool IsExtFilesystem(const std::string& device) {
+ chromeos::Blob header;
+ // The first 2 KiB is enough to read the ext2 superblock (located at offset
+ // 1024).
+ if (!ReadFileChunk(device, 0, 2048, &header))
+ return false;
+ return GetExt3Size(header.data(), header.size(), nullptr, nullptr);
+}
+
+bool IsSquashfsFilesystem(const std::string& device) {
+ chromeos::Blob header;
+ // The first 96 is enough to read the squashfs superblock.
+ const ssize_t kSquashfsSuperBlockSize = 96;
+ if (!ReadFileChunk(device, 0, kSquashfsSuperBlockSize, &header))
+ return false;
+ return GetSquashfs4Size(header.data(), header.size(), nullptr, nullptr);
+}
+
string GetPathOnBoard(const string& command) {
int return_code = 0;
string command_path;