Source-Changes-HG archive

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

[src/trunk]: src Add lfs_checkword type for reading checksum data out of stru...



details:   https://anonhg.NetBSD.org/src/rev/45bd7cd96084
branches:  trunk
changeset: 810960:45bd7cd96084
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Oct 03 08:29:34 2015 +0000

description:
Add lfs_checkword type for reading checksum data out of structures.
This is always uint32_t, but having a name for it both makes things
clearer and avoids confusion about whether it should be 32 or 64 bit.

Note: deployed in only one place (that was erroneously tagged
ondisk32) so far.

diffstat:

 sbin/fsck_lfs/lfs.c |  11 +++++------
 sys/ufs/lfs/lfs.h   |   5 ++++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r d58f30bc7922 -r 45bd7cd96084 sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c       Sat Oct 03 08:29:21 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c       Sat Oct 03 08:29:34 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.65 2015/10/03 08:29:21 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.66 2015/10/03 08:29:34 dholland Exp $ */
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -764,7 +764,7 @@
        IINFO *iibase, *iip;
        struct ubuf *bp;
        int i, j, k, datac, len;
-       u_int32_t *datap;
+       lfs_checkword *datap;
        u_int32_t ccksum;
 
        /* We've already checked the sumsum, just do the data bounds and sum */
@@ -808,7 +808,7 @@
                while (j < howmany(lfs_ss_getninos(fs, sp), LFS_INOPB(fs)) && lfs_ii_getblock(fs, iip) == daddr) {
                        bread(devvp, LFS_FSBTODB(fs, daddr), lfs_sb_getibsize(fs),
                            0, &bp);
-                       datap[datac++] = ((u_int32_t *) (bp->b_data))[0];
+                       datap[datac++] = ((lfs_checkword *)bp->b_data)[0];
                        brelse(bp, 0);
 
                        ++j;
@@ -824,7 +824,7 @@
                                       : lfs_sb_getbsize(fs));
                                bread(devvp, LFS_FSBTODB(fs, daddr), len,
                                    0, &bp);
-                               datap[datac++] = ((u_int32_t *) (bp->b_data))[0];
+                               datap[datac++] = ((lfs_checkword *)bp->b_data)[0];
                                brelse(bp, 0);
                                daddr += lfs_btofsb(fs, len);
                        }
@@ -836,8 +836,7 @@
                pwarn("Partial segment at 0x%jx expected %d blocks counted %d\n",
                    (intmax_t)pseg_addr, nblocks, datac);
        }
-       /* XXX ondisk32 */
-       ccksum = cksum(datap, nblocks * sizeof(u_int32_t));
+       ccksum = cksum(datap, nblocks * sizeof(datap[0]));
        /* Check the data checksum */
        if (ccksum != lfs_ss_getdatasum(fs, sp)) {
                pwarn("Partial segment at 0x%jx data checksum"
diff -r d58f30bc7922 -r 45bd7cd96084 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Sat Oct 03 08:29:21 2015 +0000
+++ b/sys/ufs/lfs/lfs.h Sat Oct 03 08:29:34 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.193 2015/10/03 08:27:38 dholland Exp $       */
+/*     $NetBSD: lfs.h,v 1.194 2015/10/03 08:29:34 dholland Exp $       */
 
 /*  from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp  */
 /*  from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp  */
@@ -695,6 +695,9 @@
 #define        SS_RFW          0x08            /* written by the roll-forward agent */
 #define        SS_RECLAIM      0x10            /* written by the roll-forward agent */
 
+/* type used for reading checksum signatures from metadata structures */
+typedef uint32_t lfs_checkword;
+
 typedef struct segsum_v1 SEGSUM_V1;
 struct segsum_v1 {
        u_int32_t ss_sumsum;            /* 0: check sum of summary block */



Home | Main Index | Thread Index | Old Index