Bug 210715 - fstyp: ext[234] and ntfs detection is little endian specific
Summary: fstyp: ext[234] and ntfs detection is little endian specific
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-30 00:50 UTC by Brooks Davis
Modified: 2019-01-21 22:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brooks Davis freebsd_committer freebsd_triage 2016-06-30 00:50:48 UTC
The tests to ext2, ext3, ext4, and ntfs all fail on mips64 (presumably also sparc64).  A quick glance at the code shows no attempt to adjust the endianness of constants before comparison.  For example this bit from ntfs.c:

#define NTFS_FILEMAGIC          ((uint32_t)(0x454C4946))
...
       if (fr->fr_hdrmagic != NTFS_FILEMAGIC)
                goto fail;
Comment 1 Edward Tomasz Napierala freebsd_committer freebsd_triage 2016-06-30 16:41:25 UTC
It's certainly unintentional, but I'm split on whether it's a bug, or a feature :-)

Basically, the intent of fstyp is to return filesystem type, when it finds a mountable filesystem.  Do we support endianess-independent ext[234] and NTFS?  If not, then the filesystems are not mountable.
Comment 2 Brooks Davis freebsd_committer freebsd_triage 2016-07-05 18:40:27 UTC
As implemented it's a bug.  We could choose to not compile in support for these file systems on big endian systems, but we shouldn't match bogus byte-swapped filesystems that shouldn't exist and we definitely shouldn't run the tests since they make no sense.
Comment 3 Brooks Davis freebsd_committer freebsd_triage 2019-01-21 22:02:18 UTC
FWIW, ext#fs and NTFS are both pure little-endian filesystems.  The fstyp implementation would find totally bogus byte swapped filesystems which should never be supported, but fail to find valid ones.