Skip to content

Detect ext4 based on their superblock magic - #113

Merged
landerweit-phytec merged 5 commits into
mainfrom
wip-ext4-auto-detect
Jul 16, 2026
Merged

Detect ext4 based on their superblock magic#113
landerweit-phytec merged 5 commits into
mainfrom
wip-ext4-auto-detect

Conversation

@mschwan-phytec

Copy link
Copy Markdown
Collaborator

Add a helper function to check a file, whether it is an ext4 image.

Detect ext4 images not only based on their filename, but also based on whether they contain an actual ext4 filesystem. This is especially needed, as sometimes ext4 images do not have a reliable filename suffix to search for. The only reliable way is to check for the superblock magic.

Add a unit test for pu_is_ext4_image and check different files.

Depends on #112

@mschwan-phytec
mschwan-phytec force-pushed the wip-ext4-auto-detect branch 2 times, most recently from 6cff296 to 466eea5 Compare July 16, 2026 10:00
@mschwan-phytec
mschwan-phytec marked this pull request as ready for review July 16, 2026 10:01

@landerweit-phytec landerweit-phytec left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one question below.

Comment thread src/pu-utils.c Outdated
Add a helper function to check a file, whether it is an ext4 image.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Detect ext4 images not only based on their filename, but also based on
whether they contain an actual ext4 filesystem. This is especially
needed, as sometimes ext4 images do not have a reliable filename suffix
to search for. The only reliable way is to check for the superblock
magic.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add a unit test for pu_is_ext234_image and check different files.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Allow writing arbitrary binaries to partitions with filesystem specified
as null and where the input is not an ext4 image.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
When mounting or unmounting fails, print the return and status codes for
better debugging of the error.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
@landerweit-phytec
landerweit-phytec merged commit c622fd4 into main Jul 16, 2026
4 checks passed
@landerweit-phytec
landerweit-phytec deleted the wip-ext4-auto-detect branch July 16, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants