Module Name:src
Committed By: dholland
Date: Thu Oct 15 06:25:23 UTC 2015
Modified Files:
src/sbin/scan_ffs: scan_ffs.c
Log Message:
Teach scan_ffs about lfs64.
(and also about byte-swapped lfs volumes, which might or might not
actually work)
To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sbin/scan_ffs/scan_ffs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/scan_ffs/scan_ffs.c
diff -u src/sbin/scan_ffs/scan_ffs.c:1.31 src/sbin/scan_ffs/scan_ffs.c:1.32
--- src/sbin/scan_ffs/scan_ffs.c:1.31 Sun Aug 2 18:18:09 2015
+++ src/sbin/scan_ffs/scan_ffs.c Thu Oct 15 06:25:23 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: scan_ffs.c,v 1.31 2015/08/02 18:18:09 dholland Exp $ */
+/* $NetBSD: scan_ffs.c,v 1.32 2015/10/15 06:25:23 dholland Exp $ */
/*
* Copyright (c) 2005-2007 Juan Romero Pardines
@@ -33,7 +33,7 @@
#include
#ifndef lint
-__RCSID("$NetBSD: scan_ffs.c,v 1.31 2015/08/02 18:18:09 dholland Exp $");
+__RCSID("$NetBSD: scan_ffs.c,v 1.32 2015/10/15 06:25:23 dholland Exp $");
#endif /* not lint */
#include
@@ -259,13 +259,15 @@ lfs_printpart(struct sblockinfo *sbi, in
(lfs_sb_getsize(sbi->lfs) *
lfs_sb_getfsize(sbi->lfs) / 512));
(void)printf(" %9" PRIu64, sbi->lfs_off);
- (void)printf(" 4.4LFS %6d %5d %7d # %s [LFSv%d]\n",
+ (void)printf(" 4.4LFS %6d %5d %7d # %s [LFS%d v%d]\n",
lfs_sb_getfsize(sbi->lfs), lfs_sb_getbsize(sbi->lfs),
lfs_sb_getnseg(sbi->lfs), sbi->lfs_path,
+ sbi->lfs->lfs_is64 ? 64 : 32,
lfs_sb_getversion(sbi->lfs));
break;
case BLOCKS:
- (void)printf("LFSv%d", lfs_sb_getversion(sbi->lfs));
+ (void)printf("LFS%d v%d", sbi->lfs->lfs_is64 ? 64 : 32,
+ lfs_sb_getversion(sbi->lfs));
(void)printf(" sb at %" PRIu64, sbi->lfs_off + btodb(LFS_LABELPAD));
(void)printf(" fsid %" PRIx32, lfs_sb_getident(sbi->lfs));
(void)printf(" size %" PRIu64 ", last mounted on %s\n",
@@ -273,7 +275,8 @@ lfs_printpart(struct sblockinfo *sbi, in
lfs_sb_getfsize(sbi->lfs) / 512), sbi->lfs_path);
break;
default:
- (void)printf("LFSv%d ", lfs_sb_getversion(sbi->lfs));
+ (void)printf("LFS%d v%d ", sbi->lfs->lfs_is64 ? 64 : 32,
+ lfs_sb_getversion(sbi->lfs));
(void)printf("at %" PRIu64, sbi->lfs_off);
(void)printf(" size %" PRIu64 ", last mounted on %s\n",
(lfs_sb_getsize(sbi->lfs) *
@@ -345,6 +348,31 @@ lfs_scan(struct sblockinfo *sbi, int n)
}
static int
+lfs_checkmagic(struct sblockinfo *sbinfo)
+{
+ switch (sbinfo->lfs->lfs_dlfs_u.u_32.dlfs_magic) {
+ case LFS_MAGIC:
+ sbinfo->lfs->lfs_is64 = false;
+ sbinfo->lfs->lfs_dobyteswap = false;
+ return 1;
+ case LFS_MAGIC_SWAPPED:
+ sbinfo->lfs->lfs_is64 = false;
+ sbinfo->lfs->lfs_dobyteswap = true;
+ return 1;
+ case LFS64_MAGIC:
+ sbinfo->lfs->lfs_is64 = true;
+ sbinfo->lfs->lfs_dobyteswap = false;
+ return 1;
+ case LFS64_MAGIC_SWAPPED:
+ sbinfo->lfs->lfs_is64 = true;
+ sbinfo->lfs->lfs_dobyteswap = true;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static int
scan_disk(int fd, daddr_t beg, daddr_t end, int fflags)
{
struct sblockinfo sbinfo;
@@ -382,7 +410,7 @@ scan_disk(int fd, daddr_t beg, daddr_t e
break;
case FSTYPE_NONE:
/* maybe LFS? */
-if (sbinfo.lfs->lfs_dlfs_u.u_32.dlfs_magic == LFS_MAGIC)
+if (lfs_checkmagic())
lfs_scan(, n);
break;
default: