Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys/ufs/lfs Pull up following revision(s) (requested by d...



details:   https://anonhg.NetBSD.org/src/rev/efc2ec3ba64c
branches:  netbsd-6
changeset: 776999:efc2ec3ba64c
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Nov 15 16:49:37 2015 +0000

description:
Pull up following revision(s) (requested by dholland in ticket #1319):
        sys/ufs/lfs/lfs_segment.c: revision 1.247 via patch
Fix catastrophic bug in lfs_rewind() that changed segment numbers
(lfs_curseg/lfs_nextseg in the superblock) using the wrong units.
These fields are for whatever reason the start addresses of segments
(measured in frags) rather than the segment numbers 0..n.
This only apparently affects dumping from a mounted fs; however, it
trashes the fs.
I would really, really like to have a static analysis tool that can
keep track of the units things are measured in, since fs code is full
of conversion macros and the macros are named inscrutable things like
"sntod" whose letters don't necessarily even correspond to the units
they convert. It is surprising that more of these are not wrong.

diffstat:

 sys/ufs/lfs/lfs_segment.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 7ed16d1e51ae -r efc2ec3ba64c sys/ufs/lfs/lfs_segment.c
--- a/sys/ufs/lfs/lfs_segment.c Sun Nov 15 16:47:26 2015 +0000
+++ b/sys/ufs/lfs/lfs_segment.c Sun Nov 15 16:49:37 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_segment.c,v 1.223.2.1 2012/03/17 17:40:06 bouyer Exp $     */
+/*     $NetBSD: lfs_segment.c,v 1.223.2.2 2015/11/15 16:49:37 bouyer Exp $     */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.223.2.1 2012/03/17 17:40:06 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.223.2.2 2015/11/15 16:49:37 bouyer Exp $");
 
 #ifdef DEBUG
 # define vndebug(vp, str) do {                                         \
@@ -1700,7 +1700,7 @@
 }
 
 /*
- * Move lfs_offset to a segment earlier than sn.
+ * Move lfs_offset to a segment earlier than newsn.
  */
 int
 lfs_rewind(struct lfs *fs, int newsn)
@@ -1731,7 +1731,7 @@
                panic("lfs_rewind: no clean segments");
        if (newsn >= 0 && sn >= newsn)
                return ENOENT;
-       fs->lfs_nextseg = sn;
+       fs->lfs_nextseg = sntod(fs, sn);
        lfs_newseg(fs);
        fs->lfs_offset = fs->lfs_curseg;
 



Home | Main Index | Thread Index | Old Index