[File] Detect YAFFS images
Fabian Zaremba
fabian at youremail.eu
Mon Jan 23 21:49:57 UTC 2023
Hello everyone,
the attached patch allows file to detect YAFFS filesystem image root
signatures.
Unfortunately, the YAFFS on-disk format is poorly documented and mainly
defined by the memory layout of the reference implementation found here:
http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blob;f=yaffs_guts.h;h=74ded0be526f1f44c91ce90a6d54cc52bb338cf0;hb=HEAD#l329
I propose adding the signatures in the attached patch, where we
recognize the start of an object header defined by yaffs_obj_hdr, with
the values being encoded depending on platform endianess:
u32 type /* enum yaffs_obj_type, valid 1-5 */
u32 parent_obj_id; /* 1 for root objects we recognize */
u16 sum_no_longer_used; /* checksum of name. Not used by YAFFS and
memset to 0xFF */
YCHAR name[YAFFS_MAX_NAME_LENGTH + 1];
Notes:
- mkyaffsimage always writes a root directory with empty name, then
processing the target directory contents.
- mkyaffs2image directly proceeds to writing entries with the
appropriate u32 YAFFS_OBJECT_TYPE (1-5 valid), each with parent id
From a test set of 9 images generated with different contents and
versions of the reference implementation, the implemented signature
recognized all images and displayed additional data where appropriate
(root object name). Attached for reference are the test images, as well
as the output generated when running file with the new magic signatures.
Various remaining parameters (NAND layout, ECC, etc.) do not seem to
have an effect on the object header examined here.
Display is as follows, complete output and test data attached:
"YAFFS filesystem root entry, [big|little] endian" along with type
information and root file / directory names if applicable (YAFFS2).
Thanks for your efforts!
Best regards,
Fabian Zaremba
-------------- next part --------------
A non-text attachment was scrubbed...
Name: yaffs_magic.patch
Type: text/x-patch
Size: 3176 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20230123/9733ba27/attachment.bin>
-------------- next part --------------
/tmp/demo/images/testimage-yaff2s-file-be: YAFFS filesystem root entry, big endian, type file, object entry (name: "testfile")
/tmp/demo/images/testimage-yaffs2-file: YAFFS filesystem root entry, little endian, type file, object entry (name: "testfile")
/tmp/demo/images/testimage-yaffs2-folder: YAFFS filesystem root entry, little endian, type root or directory, object entry (name: "testfolder")
/tmp/demo/images/testimage-yaffs2-folder-be: YAFFS filesystem root entry, big endian, type root or directory, object entry (name: "testfolder")
/tmp/demo/images/testimage-yaffs2-hierarchy: YAFFS filesystem root entry, little endian, type root or directory, v1 root directory
/tmp/demo/images/testimage-yaffs-file: YAFFS filesystem root entry, little endian, type root or directory, v1 root directory
/tmp/demo/images/testimage-yaffs-file-be: YAFFS filesystem root entry, big endian, type root or directory, v1 root directory
/tmp/demo/images/testimage-yaffs-folder: YAFFS filesystem root entry, little endian, type root or directory, v1 root directory
/tmp/demo/images/testimage-yaffs-folder-be: YAFFS filesystem root entry, big endian, type root or directory, v1 root directory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testimages.tar.gz
Type: application/gzip
Size: 2328 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20230123/9733ba27/attachment-0001.bin>
More information about the File
mailing list