EXT packer#709
Conversation
|
Before I get a chance to review this, how does it compare to these other components that Albert worked on? Also, does it happen to address concerns I raised a long time ago, when the EXT unpacking components were introduced? Note that this would close #529. |
|
@rbs-jacob, mentioned some of this in the PR description but can elaborate a bit more.
|
| # a "lost+found" directory might be created when flushed to disk, but might also happen to be present in the filesystem, so ignore it: | ||
| if "lost+found" in old_files: | ||
| old_files.remove("lost+found") | ||
| if "lost+found" in new_files: | ||
| new_files.remove("lost+found") | ||
| assert len(old_files) == len(new_files) and set(old_files) == set( |
There was a problem hiding this comment.
This seems suspect? I don't think we want our packer to introduce files like this. Are we sure this is needed?
| "-h", | ||
| temp_path, | ||
| stdout=asyncio.subprocess.PIPE, | ||
| stderr=asyncio.subprocess.DEVNULL, |
There was a problem hiding this comment.
We should probably capture stderr to attach to an exception if this fails.
| if ext_view.blocks_per_group: | ||
| cmd.extend(["-g", str(ext_view.blocks_per_group)]) | ||
| if ext_view.inode_size: | ||
| cmd.extend(["-I", str(ext_view.inode_size)]) | ||
| if ext_view.number_of_inodes: | ||
| cmd.extend(["-N", str(ext_view.number_of_inodes)]) | ||
| if ext_view.reserved_block_count and ext_view.block_count > 0: | ||
| percentage = round(ext_view.reserved_block_count / ext_view.block_count * 100) | ||
| cmd.extend(["-m", str(percentage)]) | ||
| if ext_view.creator_os: | ||
| cmd.extend(["-o", ext_view.creator_os]) | ||
| if ext_view.filesystem_features: | ||
| features = "none," + ext_view.filesystem_features.replace(" ", ",") | ||
| cmd.extend(["-O", features]) | ||
| if ext_view.filesystem_revision: | ||
| cmd.extend(["-r", str(ext_view.filesystem_revision)]) | ||
| if ext_view.volume_label: | ||
| cmd.extend(["-L", ext_view.volume_label]) | ||
| if ext_view.last_mounted_directory: | ||
| cmd.extend(["-M", ext_view.last_mounted_directory]) | ||
| if ext_view.uuid: | ||
| cmd.extend(["-U", ext_view.uuid]) |
There was a problem hiding this comment.
If any of these values are zero, they will not be set. These checks should probably be explicit about confirming is not None.
| for item in os.listdir(temp_dir): | ||
| src = os.path.join(temp_dir, item) | ||
| dst = os.path.join(str(extract_dir), item) | ||
| if os.path.isdir(src): | ||
| shutil.copytree(src, dst, symlinks=True) | ||
| else: | ||
| shutil.copy2(src, dst) |
There was a problem hiding this comment.
Why do this instead of extracting directly to the extract dir?
One sentence summary of this PR (This should go in the CHANGELOG!)
Add EXT packer, analyzer and tests.
Link to Related Issue(s)
#529
Please describe the changes in your request.
ExtAnalyzerthat uses thedumpe2fscommand to determine all the EXT attributes.ExtPackerthat uses themke2fscommand and the analysis from theExtAnalyzerto create an EXT2/3/4 filesystem without having to mount anything or use loop devices.FilesystemPackUnpackVerifyPatternand a round trip test to make sure attributes are preserved_validate_folder_equalitymethod inpytest_ofrak/src/pytest_ofrak/patterns/pack_unpack_filesystem.pybecause linux will sometimes create alost+founddirectory when extracting the filesystem. But it could also be present in the original filesystem. So I just removed that from the equality comparison.Compared to #558 PR, this merge request is more compact and less complex (no need to write a debugfs script, etc).
Anyone you think should look at this, specifically?
No