diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -382,6 +383,18 @@ prtmsg = ((flags & UFS_NOMSG) == 0); warnerr = (flags & UFS_NOWARNFAIL) == UFS_NOWARNFAIL ? 0 : ENOENT; wmsg = warnerr ? "" : " (Ignored)"; + + /* Guess endian mismatch between machine and filesystem */ + if ((fs->fs_magic != FS_UFS2_MAGIC) && + (bswap32(fs->fs_magic) == FS_UFS2_MAGIC)) { + MPRINT("UFS2 superblock failed: possible endian mismatch between machine and filesystem\n"); + return(ENOEXEC); + } else if ((fs->fs_magic != FS_UFS1_MAGIC) && + (bswap32(fs->fs_magic) == FS_UFS1_MAGIC)) { + MPRINT("UFS1 superblock failed: possible endian mismatch between machine and filesystem\n"); + return(ENOEXEC); + } + /* * If just validating for recovery, then do just the minimal * checks needed for the superblock fields needed to find