Page MenuHomeFreeBSD

D37675.id114058.diff
No OneTemporary

D37675.id114058.diff

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 <stdlib.h>
#include <time.h>
#include <sys/errno.h>
+#include <sys/endian.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -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

File Metadata

Mime Type
text/plain
Expires
Sat, May 2, 2:24 AM (14 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32605493
Default Alt Text
D37675.id114058.diff (1 KB)

Event Timeline