srlabs / extractor

Extractor: The Android firmware image extraction tool
Apache License 2.0
69 stars 16 forks source link

Update erofs_tool.py #12

Closed oznotes closed 1 week ago

oznotes commented 4 months ago

Cross-Platform Memory Mapping Compatibility

Problem:

The original implementation of memory-mapped files in the Erofs class used parameters specific to POSIX-compliant systems, causing compatibility issues on Windows. This resulted in an AttributeError because mmap.MAP_SHARED and mmap.PROT_READ are not available on Windows.

Solution:

Implemented a conditional check within the Erofs class constructor to determine the operating system at runtime. Based on the OS, it now selects the appropriate parameters for the mmap.mmap() function. This update ensures that the memory mapping functionality works seamlessly across Windows, Linux, and macOS.

Changes:

This update enhances the portability of the Erofs filesystem extractor tool, making it more robust and user-friendly across different development environments.