From 3e7f0f50cad61a30884dabe3fe66198a39888a2b Mon Sep 17 00:00:00 2001 From: mlelstv Date: Tue, 24 Jan 2023 08:05:07 +0000 Subject: [PATCH] Work on swapped-endian FFS. --- sbin/scan_ffs/Makefile | 6 +++--- sbin/scan_ffs/scan_ffs.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sbin/scan_ffs/Makefile b/sbin/scan_ffs/Makefile index 37b48d6d6a77..ac73e0afcb64 100644 --- a/sbin/scan_ffs/Makefile +++ b/sbin/scan_ffs/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.10 2020/09/07 03:09:53 mrg Exp $ +# $NetBSD: Makefile,v 1.11 2023/01/24 08:05:07 mlelstv Exp $ .include @@ -10,9 +10,9 @@ MLINKS= scan_ffs.8 scan_lfs.8 LDADD= -lutil DPADD= ${LIBUTIL} -SRCS= scan_ffs.c lfs_cksum.c +SRCS= scan_ffs.c ffs_bswap.c lfs_cksum.c SCAN_FFS=${NETBSDSRCDIR}/sbin/scan_ffs -.PATH: ${NETBSDSRCDIR}/sys/ufs/lfs ${SCAN_FFS} +.PATH: ${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/sys/ufs/lfs ${SCAN_FFS} MAN= scan_ffs.8 diff --git a/sbin/scan_ffs/scan_ffs.c b/sbin/scan_ffs/scan_ffs.c index 4a4b0f21d547..8fbedfea2afa 100644 --- a/sbin/scan_ffs/scan_ffs.c +++ b/sbin/scan_ffs/scan_ffs.c @@ -1,4 +1,4 @@ -/* $NetBSD: scan_ffs.c,v 1.36 2022/11/17 06:40:39 chs Exp $ */ +/* $NetBSD: scan_ffs.c,v 1.37 2023/01/24 08:05:07 mlelstv Exp $ */ /* * Copyright (c) 2005-2007 Juan Romero Pardines @@ -33,7 +33,7 @@ #include #ifndef lint -__RCSID("$NetBSD: scan_ffs.c,v 1.36 2022/11/17 06:40:39 chs Exp $"); +__RCSID("$NetBSD: scan_ffs.c,v 1.37 2023/01/24 08:05:07 mlelstv Exp $"); #endif /* not lint */ #include @@ -50,6 +50,7 @@ __RCSID("$NetBSD: scan_ffs.c,v 1.36 2022/11/17 06:40:39 chs Exp $"); #include #include +#include #include #include @@ -122,6 +123,14 @@ got_siginfo(int signo) static int ffs_checkver(struct sblockinfo *sbi) { + switch (sbi->ffs->fs_magic) { + case FS_UFS1_MAGIC_SWAPPED: + case FS_UFS2_MAGIC_SWAPPED: + case FS_UFS2EA_MAGIC_SWAPPED: + ffs_sb_swap(sbi->ffs, sbi->ffs); + break; + } + switch (sbi->ffs->fs_magic) { case FS_UFS1_MAGIC: case FS_UFS1_MAGIC_SWAPPED: