Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Oct 2012 10:06:48 +0000 (UTC)
From:      Grzegorz Bernacki <gber@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r241157 - head/lib/libstand
Message-ID:  <201210031006.q93A6mZg005461@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gber
Date: Wed Oct  3 10:06:48 2012
New Revision: 241157
URL: http://svn.freebsd.org/changeset/base/241157

Log:
  Correct detection of a superblock.
  
  Obtained from:	Smartcom Bulgaria AD

Modified:
  head/lib/libstand/nandfs.c

Modified: head/lib/libstand/nandfs.c
==============================================================================
--- head/lib/libstand/nandfs.c	Wed Oct  3 05:42:15 2012	(r241156)
+++ head/lib/libstand/nandfs.c	Wed Oct  3 10:06:48 2012	(r241157)
@@ -175,7 +175,7 @@ static int
 nandfs_find_super_block(struct nandfs *fs, struct open_file *f)
 {
 	struct nandfs_super_block *sb;
-	int i, j, n;
+	int i, j, n, s;
 	int sectors_to_read, error;
 
 	sb = malloc(fs->nf_sectorsize);
@@ -196,23 +196,22 @@ nandfs_find_super_block(struct nandfs *f
 			continue;
 		}
 		n = fs->nf_sectorsize / sizeof(struct nandfs_super_block);
+		s = 0;
 		if ((i * fs->nf_sectorsize) % fs->nf_fsdata->f_erasesize == 0) {
 			if (fs->nf_sectorsize == sizeof(struct nandfs_fsdata))
 				continue;
 			else {
-				sb += (sizeof(struct nandfs_fsdata) /
-				    sizeof(struct nandfs_super_block));
-				n -= (sizeof(struct nandfs_fsdata) /
+				s += (sizeof(struct nandfs_fsdata) /
 				    sizeof(struct nandfs_super_block));
 			}
 		}
 
-		for (j = 0; j < n; j++) {
+		for (j = s; j < n; j++) {
 			if (!nandfs_check_superblock_crc(fs->nf_fsdata, &sb[j]))
 				continue;
-			NANDFS_DEBUG("magic %x wtime %jd\n", sb->s_magic,
-			    sb->s_wtime);
-			if (sb[j].s_wtime > fs->nf_sb->s_wtime)
+			NANDFS_DEBUG("magic %x wtime %jd, lastcp 0x%jx\n",
+			    sb[j].s_magic, sb[j].s_wtime, sb[j].s_last_cno);
+			if (sb[j].s_last_cno > fs->nf_sb->s_last_cno)
 				memcpy(fs->nf_sb, &sb[j], sizeof(*fs->nf_sb));
 		}
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210031006.q93A6mZg005461>