update_engine: Introduce FilesystemInterface abstraction.
The interaction with the filesystem in the payload generation process
is hard-coded in several places, making it hard to mock out or use a
different filesystem like squashfs for delta generation. For example,
the metadata, regular file data and non-file data are handled by three
different functions in a similar way, but with different code.
This patch introcudes a filesystem abstraction to map files or
pseudo-files (like the metadata, free-space, etc) into the same interface.
The interface includes three implementations: for parsing ext2 filesystems
using ext2fs (already used by the metadata parsing but not by the file
data processing), a raw one for monolitic partitions like the kernel
and a fake one used for testing without requiring to build/parse a real
ext2 filesystem.
BUG=chromium:331965
TEST=FEATURES=test emerge-link update_engine
Change-Id: I1e14cf8f3883c8e9a1d471c8193c8da60776aa7c
Reviewed-on: https://chromium-review.googlesource.com/275803
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/update_engine.gyp b/update_engine.gyp
index b1ee122..1731757 100644
--- a/update_engine.gyp
+++ b/update_engine.gyp
@@ -279,6 +279,7 @@
'payload_generator/annotated_operation.cc',
'payload_generator/cycle_breaker.cc',
'payload_generator/delta_diff_generator.cc',
+ 'payload_generator/ext2_filesystem.cc',
'payload_generator/extent_mapper.cc',
'payload_generator/extent_utils.cc',
'payload_generator/filesystem_iterator.cc',
@@ -289,6 +290,7 @@
'payload_generator/metadata.cc',
'payload_generator/payload_generation_config.cc',
'payload_generator/payload_signer.cc',
+ 'payload_generator/raw_filesystem.cc',
'payload_generator/tarjan.cc',
'payload_generator/topological_sort.cc',
'payload_generator/verity_utils.cc',
@@ -329,6 +331,19 @@
],
'includes': ['../common-mk/openssl_pem.gypi'],
},
+ # Sample images used for testing.
+ {
+ 'target_name': 'update_engine-test_images',
+ 'type': 'none',
+ 'variables': {
+ 'image_out_dir': '.',
+ },
+ 'sources': [
+ 'sample_images/disk_ext2_1k.txt',
+ 'sample_images/disk_ext2_4k.txt',
+ ],
+ 'includes': ['generate_image.gypi'],
+ },
# Test HTTP Server.
{
'target_name': 'test_http_server',
@@ -373,8 +388,10 @@
'p2p_manager_unittest.cc',
'payload_generator/cycle_breaker_unittest.cc',
'payload_generator/delta_diff_generator_unittest.cc',
+ 'payload_generator/ext2_filesystem_unittest.cc',
'payload_generator/extent_mapper_unittest.cc',
'payload_generator/extent_utils_unittest.cc',
+ 'payload_generator/fake_filesystem.cc',
'payload_generator/filesystem_iterator_unittest.cc',
'payload_generator/full_update_generator_unittest.cc',
'payload_generator/graph_utils_unittest.cc',