Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin Use daddr_t, not ulfs_daddr_t, as the latter's 32 bits ...
details: https://anonhg.NetBSD.org/src/rev/8e6adb4d73e1
branches: trunk
changeset: 340342:8e6adb4d73e1
user: dholland <dholland%NetBSD.org@localhost>
date: Tue Sep 01 06:15:02 2015 +0000
description:
Use daddr_t, not ulfs_daddr_t, as the latter's 32 bits wide.
Don't use either for on-disk items.
Declare external data in header files.
Part 3 of 3.
diffstat:
sbin/fsck_lfs/fsck_vars.h | 8 +++++++-
sbin/fsck_lfs/inode.c | 32 ++++++++++++++++----------------
sbin/fsck_lfs/lfs.c | 6 +++---
sbin/fsck_lfs/pass1.c | 19 ++++++++-----------
sbin/fsck_lfs/pass4.c | 4 +---
sbin/fsck_lfs/pass5.c | 3 +--
sbin/fsck_lfs/pass6.c | 13 +++++--------
sbin/fsck_lfs/segwrite.c | 20 ++++++++++----------
sbin/fsck_lfs/segwrite.h | 6 ++----
sbin/fsck_lfs/setup.c | 4 ++--
sbin/newfs_lfs/make_lfs.c | 9 +++++----
11 files changed, 60 insertions(+), 64 deletions(-)
diffs (truncated from 436 to 300 lines):
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/fsck_vars.h
--- a/sbin/fsck_lfs/fsck_vars.h Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/fsck_vars.h Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fsck_vars.h,v 1.14 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: fsck_vars.h,v 1.15 2015/09/01 06:15:02 dholland Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -77,3 +77,9 @@
extern ino_t n_files; /* number of files in use */
extern int no_roll_forward; /* Don't roll forward */
+
+blkcnt_t badblkcount; /* count of "bad" blocks */
+
+/* from setup.c */
+extern SEGUSE *seg_table;
+extern daddr_t *din_table;
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/inode.c Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inode.c,v 1.61 2015/09/01 06:08:37 dholland Exp $ */
+/* $NetBSD: inode.c,v 1.62 2015/09/01 06:15:02 dholland Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -87,9 +87,6 @@
#include "fsutil.h"
#include "extern.h"
-extern SEGUSE *seg_table;
-extern ulfs_daddr_t *din_table;
-
static int iblock(struct inodesc *, long, u_int64_t);
int blksreqd(struct lfs *, int);
int lfs_maxino(void);
@@ -128,7 +125,7 @@
int
ckinode(union lfs_dinode *dp, struct inodesc *idesc)
{
- ulfs_daddr_t lbn, pbn;
+ daddr_t lbn, pbn;
long ret, n, ndb, offset;
union lfs_dinode dino;
u_int64_t remsize, sizepb;
@@ -234,7 +231,8 @@
static int
iblock(struct inodesc *idesc, long ilevel, u_int64_t isize)
{
- ulfs_daddr_t *ap, *aplim;
+ unsigned j, maxindir;
+ daddr_t found;
struct ubuf *bp;
int i, n, (*func) (struct inodesc *), nif;
u_int64_t sizepb;
@@ -263,23 +261,25 @@
else
nif = howmany(isize, sizepb);
if (idesc->id_func == pass1check && nif < LFS_NINDIR(fs)) {
- aplim = ((ulfs_daddr_t *) bp->b_data) + LFS_NINDIR(fs);
- for (ap = ((ulfs_daddr_t *) bp->b_data) + nif; ap < aplim; ap++) {
- if (*ap == 0)
+ maxindir = LFS_NINDIR(fs);
+ for (j = nif; j < maxindir; j++) {
+ found = lfs_iblock_get(fs, bp->b_data, j);
+ if (found == 0)
continue;
(void)snprintf(buf, sizeof(buf),
"PARTIALLY TRUNCATED INODE I=%llu",
(unsigned long long)idesc->id_number);
if (dofix(idesc, buf)) {
- *ap = 0;
+ lfs_iblock_set(fs, bp->b_data, j, 0);
++diddirty;
}
}
}
- aplim = ((ulfs_daddr_t *) bp->b_data) + nif;
- for (ap = ((ulfs_daddr_t *) bp->b_data); ap < aplim; ap++) {
- if (*ap) {
- idesc->id_blkno = *ap;
+ maxindir = nif;
+ for (j = 0; j < maxindir; j++) {
+ found = lfs_iblock_get(fs, bp->b_data, j);
+ if (found) {
+ idesc->id_blkno = found;
if (ilevel == 0) {
/*
* dirscan needs lfs_lblkno.
@@ -370,7 +370,7 @@
blks = howmany(lfs_dino_getsize(fs, dp), lfs_sb_getbsize(fs));
if (blks > ULFS_NDADDR)
blks = ULFS_NDADDR + ULFS_NIADDR;
- inp = emalloc(sizeof(*inp) + (blks - 1) * sizeof(ulfs_daddr_t));
+ inp = emalloc(sizeof(*inp) + (blks - 1) * sizeof(inp->i_blks[0]));
inpp = &inphead[inumber % numdirs];
inp->i_nexthash = *inpp;
*inpp = inp;
@@ -383,7 +383,7 @@
inp->i_number = inumber;
inp->i_isize = lfs_dino_getsize(fs, dp);
- inp->i_numblks = blks * sizeof(ulfs_daddr_t);
+ inp->i_numblks = blks * sizeof(inp->i_blks[0]);
for (i=0; i<blks && i<ULFS_NDADDR; i++) {
inp->i_blks[i] = lfs_dino_getdb(fs, dp, i);
}
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/lfs.c
--- a/sbin/fsck_lfs/lfs.c Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/lfs.c Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs.c,v 1.62 2015/09/01 06:13:57 dholland Exp $ */
+/* $NetBSD: lfs.c,v 1.63 2015/09/01 06:15:02 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -212,12 +212,12 @@
bp->b_flags |= B_READ;
VOP_STRATEGY(bp);
}
- daddr = ((ulfs_daddr_t *) bp->b_data)[xap->in_off];
+ daddr = lfs_iblock_get(fs, bp->b_data, xap->in_off);
}
if (bp)
brelse(bp, 0);
- daddr = LFS_FSBTODB(fs, (ulfs_daddr_t) daddr);
+ daddr = LFS_FSBTODB(fs, daddr);
*bnp = daddr == 0 ? -1 : daddr;
return (0);
}
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/pass1.c
--- a/sbin/fsck_lfs/pass1.c Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/pass1.c Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass1.c,v 1.43 2015/09/01 06:12:04 dholland Exp $ */
+/* $NetBSD: pass1.c,v 1.44 2015/09/01 06:15:02 dholland Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -55,16 +55,13 @@
#include "extern.h"
#include "fsutil.h"
-SEGUSE *seg_table;
-extern ulfs_daddr_t *din_table;
-
-ulfs_daddr_t badblk;
-static ulfs_daddr_t dupblk;
+blkcnt_t badblkcount;
+static blkcnt_t dupblkcount;
static int i_d_cmp(const void *, const void *);
struct ino_daddr {
ino_t ino;
- ulfs_daddr_t daddr;
+ daddr_t daddr;
};
static int
@@ -255,7 +252,7 @@
*/
if (lfs_dino_getsize(fs, dp) < lfs_sb_getmaxsymlinklen(fs) ||
(lfs_sb_getmaxsymlinklen(fs) == 0 && lfs_dino_getblocks(fs, dp) == 0)) {
- ndb = howmany(lfs_dino_getsize(fs, dp), sizeof(ulfs_daddr_t));
+ ndb = howmany(lfs_dino_getsize(fs, dp), LFS_BLKPTRSIZE(fs));
if (ndb > ULFS_NDADDR) {
j = ndb - ULFS_NDADDR;
for (ndb = 1; j > 1; j--)
@@ -324,7 +321,7 @@
/* XXX: why VTOD(vp) instead of dp here? */
typemap[inumber] = LFS_IFTODT(mode);
- badblk = dupblk = 0;
+ badblkcount = dupblkcount = 0;
idesc->id_number = inumber;
(void) ckinode(VTOD(vp), idesc);
if (lfs_dino_getblocks(fs, dp) != idesc->id_entryno) {
@@ -361,7 +358,7 @@
if ((anyout = chkrange(blkno, idesc->id_numfrags)) != 0) {
blkerror(idesc->id_number, "BAD", blkno);
- if (badblk++ >= MAXBAD) {
+ if (badblkcount++ >= MAXBAD) {
pwarn("EXCESSIVE BAD BLKS I=%llu",
(unsigned long long)idesc->id_number);
if (preen)
@@ -390,7 +387,7 @@
(long long)idesc->id_lblkno,
(long long)testbmap(blkno));
#endif
- if (dupblk++ >= MAXDUP) {
+ if (dupblkcount++ >= MAXDUP) {
pwarn("EXCESSIVE DUP BLKS I=%llu",
(unsigned long long)idesc->id_number);
if (preen)
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/pass4.c
--- a/sbin/fsck_lfs/pass4.c Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/pass4.c Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass4.c,v 1.26 2015/08/12 18:28:00 dholland Exp $ */
+/* $NetBSD: pass4.c,v 1.27 2015/09/01 06:15:02 dholland Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -52,8 +52,6 @@
#include "fsck.h"
#include "extern.h"
-extern SEGUSE *seg_table;
-
static int check_orphan(struct inodesc *idp);
static int
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/pass5.c
--- a/sbin/fsck_lfs/pass5.c Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/pass5.c Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass5.c,v 1.35 2015/08/03 04:16:10 dholland Exp $ */
+/* $NetBSD: pass5.c,v 1.36 2015/09/01 06:15:02 dholland Exp $ */
/*-
* Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@@ -51,7 +51,6 @@
#include "extern.h"
#include "fsutil.h"
-extern SEGUSE *seg_table;
extern off_t locked_queue_bytes;
void
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/pass6.c
--- a/sbin/fsck_lfs/pass6.c Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/pass6.c Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.47 2015/09/01 06:13:57 dholland Exp $ */
+/* $NetBSD: pass6.c,v 1.48 2015/09/01 06:15:02 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -62,9 +62,6 @@
extern u_int32_t cksum(void *, size_t);
extern u_int32_t lfs_sb_cksum(struct dlfs *);
-extern ulfs_daddr_t badblk;
-extern SEGUSE *seg_table;
-
static int nnewblocks;
/*
@@ -318,7 +315,7 @@
}
if (anyout) {
blkerror(idesc->id_number, "BAD", idesc->id_blkno);
- if (badblk++ >= MAXBAD) {
+ if (badblkcount++ >= MAXBAD) {
pwarn("EXCESSIVE BAD BLKS I=%llu",
(unsigned long long)idesc->id_number);
if (preen)
@@ -472,7 +469,7 @@
* Allocate the given inode from the free list.
*/
static void
-alloc_inode(ino_t thisino, ulfs_daddr_t daddr)
+alloc_inode(ino_t thisino, daddr_t daddr)
{
ino_t ino, nextfree, oldhead;
IFILE *ifp;
@@ -481,8 +478,8 @@
CLEANERINFO *cip;
if (debug)
- pwarn("allocating ino %d at 0x%x\n", (int)thisino,
- (unsigned)daddr);
+ pwarn("allocating ino %ju at 0x%jx\n", (uintmax_t)thisino,
+ (intmax_t)daddr);
while (thisino >= maxino) {
extend_ifile(fs);
}
diff -r 748587375c48 -r 8e6adb4d73e1 sbin/fsck_lfs/segwrite.c
--- a/sbin/fsck_lfs/segwrite.c Tue Sep 01 06:13:57 2015 +0000
+++ b/sbin/fsck_lfs/segwrite.c Tue Sep 01 06:15:02 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: segwrite.c,v 1.43 2015/09/01 06:08:37 dholland Exp $ */
+/* $NetBSD: segwrite.c,v 1.44 2015/09/01 06:15:02 dholland Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -264,7 +264,7 @@
sp->ibp == NULL) {
/* Allocate a new segment if necessary. */
if (sp->seg_bytes_left < lfs_sb_getibsize(fs) ||
- sp->sum_bytes_left < sizeof(ulfs_daddr_t))
+ sp->sum_bytes_left < LFS_BLKPTRSIZE(fs))
(void) lfs_writeseg(fs, sp);
/* Get next inode block. */
@@ -288,11 +288,11 @@
Home |
Main Index |
Thread Index |
Old Index