CVS commit: src/sbin/scan_ffs

2015-10-15 Thread David A. Holland
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:



CVS commit: src/sbin/scan_ffs

2009-04-11 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Apr 11 06:52:59 UTC 2009

Modified Files:
src/sbin/scan_ffs: scan_ffs.c

Log Message:
fix sign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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.20 src/sbin/scan_ffs/scan_ffs.c:1.21
--- src/sbin/scan_ffs/scan_ffs.c:1.20	Sat Dec 15 19:44:47 2007
+++ src/sbin/scan_ffs/scan_ffs.c	Sat Apr 11 06:52:59 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: scan_ffs.c,v 1.20 2007/12/15 19:44:47 perry Exp $ */
+/* $NetBSD: scan_ffs.c,v 1.21 2009/04/11 06:52:59 lukem Exp $ */
 
 /*
  * Copyright (c) 2005-2007 Juan Romero Pardines
@@ -33,7 +33,7 @@
  
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: scan_ffs.c,v 1.20 2007/12/15 19:44:47 perry Exp $);
+__RCSID($NetBSD: scan_ffs.c,v 1.21 2009/04/11 06:52:59 lukem Exp $);
 #endif /* not lint */
 
 #include sys/types.h
@@ -273,7 +273,7 @@
 		 * Really enough for now.
 		 */
 		for (i = 1; i  16; i = 1)
-			if ((BLK_CNT - lastblk) == (i * SBLOCKSIZE / 512)) {
+			if ((BLK_CNT - lastblk) == (daddr_t)(i * SBLOCKSIZE / 512)) {
 if (flags  LABELS)
 	ffs_printpart(sbi, LABELS, i, n);
 else
@@ -348,7 +348,7 @@
 	 */
 	case FIRST_SBLOCK_ADDRESS:
 		/* copy partition offset */
-		if (sbi-lfs_off != lastblk)
+		if ((daddr_t)sbi-lfs_off != lastblk)
 			sbi-lfs_off = BLK_CNT - (LFS_LABELPAD / 512);
 		break;
 	case SECOND_SBLOCK_ADDRESS: