Sun Mar 29 19:35:58 2015 UTC ()
- Fix fallout for recent bread() change (removing cred arg).


(chopps)
diff -r1.23 -r1.24 src/libexec/lfs_cleanerd/coalesce.c
diff -r1.37 -r1.38 src/libexec/lfs_cleanerd/lfs_cleanerd.c
diff -r1.14 -r1.15 src/sbin/fsck_lfs/bufcache.c
diff -r1.11 -r1.12 src/sbin/fsck_lfs/bufcache.h
diff -r1.32 -r1.33 src/sbin/fsck_lfs/dir.c
diff -r1.32 -r1.33 src/sbin/fsck_lfs/pass6.c
diff -r1.52 -r1.53 src/sbin/fsck_lfs/inode.c
diff -r1.43 -r1.44 src/sbin/fsck_lfs/lfs.c
diff -r1.27 -r1.28 src/sbin/fsck_lfs/segwrite.c
diff -r1.44 -r1.45 src/sbin/fsck_lfs/setup.c
diff -r1.29 -r1.30 src/sbin/newfs_lfs/make_lfs.c

cvs diff -r1.23 -r1.24 src/libexec/lfs_cleanerd/coalesce.c (expand / switch to unified diff)

--- src/libexec/lfs_cleanerd/coalesce.c 2013/06/18 18:18:57 1.23
+++ src/libexec/lfs_cleanerd/coalesce.c 2015/03/29 19:35:58 1.24
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: coalesce.c,v 1.23 2013/06/18 18:18:57 christos Exp $ */ 1/* $NetBSD: coalesce.c,v 1.24 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002, 2005 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002, 2005 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -108,27 +108,27 @@ get_dinode(struct clfs *fs, ino_t ino) @@ -108,27 +108,27 @@ get_dinode(struct clfs *fs, ino_t ino)
108{ 108{
109 IFILE *ifp; 109 IFILE *ifp;
110 daddr_t daddr; 110 daddr_t daddr;
111 struct ubuf *bp; 111 struct ubuf *bp;
112 struct ulfs1_dinode *dip, *r; 112 struct ulfs1_dinode *dip, *r;
113 113
114 lfs_ientry(&ifp, fs, ino, &bp); 114 lfs_ientry(&ifp, fs, ino, &bp);
115 daddr = ifp->if_daddr; 115 daddr = ifp->if_daddr;
116 brelse(bp, 0); 116 brelse(bp, 0);
117 117
118 if (daddr == 0x0) 118 if (daddr == 0x0)
119 return NULL; 119 return NULL;
120 120
121 bread(fs->clfs_devvp, daddr, fs->lfs_ibsize, NOCRED, 0, &bp); 121 bread(fs->clfs_devvp, daddr, fs->lfs_ibsize, 0, &bp);
122 for (dip = (struct ulfs1_dinode *)bp->b_data; 122 for (dip = (struct ulfs1_dinode *)bp->b_data;
123 dip < (struct ulfs1_dinode *)(bp->b_data + fs->lfs_ibsize); dip++) 123 dip < (struct ulfs1_dinode *)(bp->b_data + fs->lfs_ibsize); dip++)
124 if (dip->di_inumber == ino) { 124 if (dip->di_inumber == ino) {
125 r = (struct ulfs1_dinode *)malloc(sizeof(*r)); 125 r = (struct ulfs1_dinode *)malloc(sizeof(*r));
126 if (r == NULL) 126 if (r == NULL)
127 break; 127 break;
128 memcpy(r, dip, sizeof(*r)); 128 memcpy(r, dip, sizeof(*r));
129 brelse(bp, 0); 129 brelse(bp, 0);
130 return r; 130 return r;
131 } 131 }
132 brelse(bp, 0); 132 brelse(bp, 0);
133 return NULL; 133 return NULL;
134} 134}
@@ -287,27 +287,27 @@ clean_inode(struct clfs *fs, ino_t ino) @@ -287,27 +287,27 @@ clean_inode(struct clfs *fs, ino_t ino)
287 } 287 }
288 if (debug) 288 if (debug)
289 syslog(LOG_DEBUG, "ino %llu markv %d blocks", 289 syslog(LOG_DEBUG, "ino %llu markv %d blocks",
290 (unsigned long long)ino, nb); 290 (unsigned long long)ino, nb);
291 291
292 /* 292 /*
293 * Write in segment-sized chunks. If at any point we'd write more 293 * Write in segment-sized chunks. If at any point we'd write more
294 * than half of the available segments, sleep until that's not 294 * than half of the available segments, sleep until that's not
295 * true any more. 295 * true any more.
296 */ 296 */
297 bps = lfs_segtod(fs, 1); 297 bps = lfs_segtod(fs, 1);
298 for (tbip = bip; tbip < bip + nb; tbip += bps) { 298 for (tbip = bip; tbip < bip + nb; tbip += bps) {
299 do { 299 do {
300 bread(fs->lfs_ivnode, 0, fs->lfs_bsize, NOCRED, 0, &bp); 300 bread(fs->lfs_ivnode, 0, fs->lfs_bsize, 0, &bp);
301 cip = *(CLEANERINFO *)bp->b_data; 301 cip = *(CLEANERINFO *)bp->b_data;
302 brelse(bp, B_INVAL); 302 brelse(bp, B_INVAL);
303 303
304 if (cip.clean < 4) /* XXX magic number 4 */ 304 if (cip.clean < 4) /* XXX magic number 4 */
305 kops.ko_fcntl(fs->clfs_ifilefd, 305 kops.ko_fcntl(fs->clfs_ifilefd,
306 LFCNSEGWAIT, NULL); 306 LFCNSEGWAIT, NULL);
307 } while(cip.clean < 4); 307 } while(cip.clean < 4);
308 308
309 lim.blkiov = tbip; 309 lim.blkiov = tbip;
310 lim.blkcnt = (tbip + bps < bip + nb ? bps : nb % bps); 310 lim.blkcnt = (tbip + bps < bip + nb ? bps : nb % bps);
311 if (kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim) < 0) { 311 if (kops.ko_fcntl(fs->clfs_ifilefd, LFCNMARKV, &lim) < 0) {
312 retval = COALESCE_BADMARKV; 312 retval = COALESCE_BADMARKV;
313 goto out; 313 goto out;

cvs diff -r1.37 -r1.38 src/libexec/lfs_cleanerd/lfs_cleanerd.c (expand / switch to unified diff)

--- src/libexec/lfs_cleanerd/lfs_cleanerd.c 2013/10/19 17:19:30 1.37
+++ src/libexec/lfs_cleanerd/lfs_cleanerd.c 2015/03/29 19:35:58 1.38
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lfs_cleanerd.c,v 1.37 2013/10/19 17:19:30 christos Exp $ */ 1/* $NetBSD: lfs_cleanerd.c,v 1.38 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2005 The NetBSD Foundation, Inc. 4 * Copyright (c) 2005 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -321,27 +321,27 @@ reload_ifile(struct clfs *fs) @@ -321,27 +321,27 @@ reload_ifile(struct clfs *fs)
321} 321}
322 322
323/* 323/*
324 * Get IFILE entry for the given inode, store in ifpp. The buffer 324 * Get IFILE entry for the given inode, store in ifpp. The buffer
325 * which contains that data is returned in bpp, and must be brelse()d 325 * which contains that data is returned in bpp, and must be brelse()d
326 * by the caller. 326 * by the caller.
327 */ 327 */
328void 328void
329lfs_ientry(IFILE **ifpp, struct clfs *fs, ino_t ino, struct ubuf **bpp) 329lfs_ientry(IFILE **ifpp, struct clfs *fs, ino_t ino, struct ubuf **bpp)
330{ 330{
331 int error; 331 int error;
332 332
333 error = bread(fs->lfs_ivnode, ino / fs->lfs_ifpb + fs->lfs_cleansz + 333 error = bread(fs->lfs_ivnode, ino / fs->lfs_ifpb + fs->lfs_cleansz +
334 fs->lfs_segtabsz, fs->lfs_bsize, NOCRED, 0, bpp); 334 fs->lfs_segtabsz, fs->lfs_bsize, 0, bpp);
335 if (error) 335 if (error)
336 syslog(LOG_ERR, "%s: ientry failed for ino %d", 336 syslog(LOG_ERR, "%s: ientry failed for ino %d",
337 fs->lfs_fsmnt, (int)ino); 337 fs->lfs_fsmnt, (int)ino);
338 *ifpp = (IFILE *)(*bpp)->b_data + ino % fs->lfs_ifpb; 338 *ifpp = (IFILE *)(*bpp)->b_data + ino % fs->lfs_ifpb;
339 return; 339 return;
340} 340}
341 341
342#ifdef TEST_PATTERN 342#ifdef TEST_PATTERN
343/* 343/*
344 * Check ULFS_ROOTINO for file data. The assumption is that we are running 344 * Check ULFS_ROOTINO for file data. The assumption is that we are running
345 * the "twofiles" test with the rest of the filesystem empty. Files 345 * the "twofiles" test with the rest of the filesystem empty. Files
346 * created by "twofiles" match the test pattern, but ULFS_ROOTINO and the 346 * created by "twofiles" match the test pattern, but ULFS_ROOTINO and the
347 * executable itself (assumed to be inode 3) should not match. 347 * executable itself (assumed to be inode 3) should not match.
@@ -504,27 +504,27 @@ parse_pseg(struct clfs *fs, daddr_t dadd @@ -504,27 +504,27 @@ parse_pseg(struct clfs *fs, daddr_t dadd
504 /* 504 /*
505 * If this finfo has nblocks==0, it was written wrong. 505 * If this finfo has nblocks==0, it was written wrong.
506 * Kernels with this problem always wrote this zero-sized 506 * Kernels with this problem always wrote this zero-sized
507 * finfo last, so just ignore it. 507 * finfo last, so just ignore it.
508 */ 508 */
509 if (fip->fi_nblocks == 0) { 509 if (fip->fi_nblocks == 0) {
510#ifdef REPAIR_ZERO_FINFO 510#ifdef REPAIR_ZERO_FINFO
511 struct ubuf *nbp; 511 struct ubuf *nbp;
512 SEGSUM *nssp; 512 SEGSUM *nssp;
513 513
514 syslog(LOG_WARNING, "fixing short FINFO at %x (seg %d)", 514 syslog(LOG_WARNING, "fixing short FINFO at %x (seg %d)",
515 odaddr, lfs_dtosn(fs, odaddr)); 515 odaddr, lfs_dtosn(fs, odaddr));
516 bread(fs->clfs_devvp, odaddr, fs->lfs_fsize, 516 bread(fs->clfs_devvp, odaddr, fs->lfs_fsize,
517 NOCRED, 0, &nbp); 517 0, &nbp);
518 nssp = (SEGSUM *)nbp->b_data; 518 nssp = (SEGSUM *)nbp->b_data;
519 --nssp->ss_nfinfo; 519 --nssp->ss_nfinfo;
520 nssp->ss_sumsum = cksum(&nssp->ss_datasum, 520 nssp->ss_sumsum = cksum(&nssp->ss_datasum,
521 fs->lfs_sumsize - sizeof(nssp->ss_sumsum)); 521 fs->lfs_sumsize - sizeof(nssp->ss_sumsum));
522 bwrite(nbp); 522 bwrite(nbp);
523#endif 523#endif
524 syslog(LOG_WARNING, "zero-length FINFO at %x (seg %d)", 524 syslog(LOG_WARNING, "zero-length FINFO at %x (seg %d)",
525 odaddr, lfs_dtosn(fs, odaddr)); 525 odaddr, lfs_dtosn(fs, odaddr));
526 continue; 526 continue;
527 } 527 }
528 528
529 /* 529 /*
530 * Check currency before adding blocks 530 * Check currency before adding blocks
@@ -1004,27 +1004,27 @@ clean_fs(struct clfs *fs, CLEANERINFO *c @@ -1004,27 +1004,27 @@ clean_fs(struct clfs *fs, CLEANERINFO *c
1004 } */ lim; 1004 } */ lim;
1005 int mc; 1005 int mc;
1006 BLOCK_INFO *mbip; 1006 BLOCK_INFO *mbip;
1007 int inc; 1007 int inc;
1008 off_t nb; 1008 off_t nb;
1009 off_t goal; 1009 off_t goal;
1010 off_t extra, if_extra; 1010 off_t extra, if_extra;
1011 double util; 1011 double util;
1012 1012
1013 /* Read the segment table into our private structure */ 1013 /* Read the segment table into our private structure */
1014 npos = 0; 1014 npos = 0;
1015 for (i = 0; i < fs->lfs_nseg; i+= fs->lfs_sepb) { 1015 for (i = 0; i < fs->lfs_nseg; i+= fs->lfs_sepb) {
1016 bread(fs->lfs_ivnode, fs->lfs_cleansz + i / fs->lfs_sepb, 1016 bread(fs->lfs_ivnode, fs->lfs_cleansz + i / fs->lfs_sepb,
1017 fs->lfs_bsize, NOCRED, 0, &bp); 1017 fs->lfs_bsize, 0, &bp);
1018 for (j = 0; j < fs->lfs_sepb && i + j < fs->lfs_nseg; j++) { 1018 for (j = 0; j < fs->lfs_sepb && i + j < fs->lfs_nseg; j++) {
1019 sup = ((SEGUSE *)bp->b_data) + j; 1019 sup = ((SEGUSE *)bp->b_data) + j;
1020 fs->clfs_segtab[i + j].nbytes = sup->su_nbytes; 1020 fs->clfs_segtab[i + j].nbytes = sup->su_nbytes;
1021 fs->clfs_segtab[i + j].nsums = sup->su_nsums; 1021 fs->clfs_segtab[i + j].nsums = sup->su_nsums;
1022 fs->clfs_segtab[i + j].lastmod = sup->su_lastmod; 1022 fs->clfs_segtab[i + j].lastmod = sup->su_lastmod;
1023 /* Keep error status but renew other flags */ 1023 /* Keep error status but renew other flags */
1024 fs->clfs_segtab[i + j].flags &= SEGUSE_ERROR; 1024 fs->clfs_segtab[i + j].flags &= SEGUSE_ERROR;
1025 fs->clfs_segtab[i + j].flags |= sup->su_flags; 1025 fs->clfs_segtab[i + j].flags |= sup->su_flags;
1026 1026
1027 /* Compute cost-benefit coefficient */ 1027 /* Compute cost-benefit coefficient */
1028 calc_cb(fs, i + j, fs->clfs_segtab + i + j); 1028 calc_cb(fs, i + j, fs->clfs_segtab + i + j);
1029 if (fs->clfs_segtab[i + j].priority > 0) 1029 if (fs->clfs_segtab[i + j].priority > 0)
1030 ++npos; 1030 ++npos;
@@ -1204,27 +1204,27 @@ needs_cleaning(struct clfs *fs, CLEANERI @@ -1204,27 +1204,27 @@ needs_cleaning(struct clfs *fs, CLEANERI
1204 daddr_t fsb_per_seg, max_free_segs; 1204 daddr_t fsb_per_seg, max_free_segs;
1205 time_t now; 1205 time_t now;
1206 double loadavg; 1206 double loadavg;
1207 1207
1208 /* If this fs is "on hold", don't clean it. */ 1208 /* If this fs is "on hold", don't clean it. */
1209 if (fs->clfs_onhold) 1209 if (fs->clfs_onhold)
1210 return 0; 1210 return 0;
1211 1211
1212 /* 1212 /*
1213 * Read the cleanerinfo block from the Ifile. We don't want 1213 * Read the cleanerinfo block from the Ifile. We don't want
1214 * the cached information, so invalidate the buffer before 1214 * the cached information, so invalidate the buffer before
1215 * handing it back. 1215 * handing it back.
1216 */ 1216 */
1217 if (bread(fs->lfs_ivnode, 0, fs->lfs_bsize, NOCRED, 0, &bp)) { 1217 if (bread(fs->lfs_ivnode, 0, fs->lfs_bsize, 0, &bp)) {
1218 syslog(LOG_ERR, "%s: can't read inode", fs->lfs_fsmnt); 1218 syslog(LOG_ERR, "%s: can't read inode", fs->lfs_fsmnt);
1219 return -1; 1219 return -1;
1220 } 1220 }
1221 *cip = *(CLEANERINFO *)bp->b_data; /* Structure copy */ 1221 *cip = *(CLEANERINFO *)bp->b_data; /* Structure copy */
1222 brelse(bp, B_INVAL); 1222 brelse(bp, B_INVAL);
1223 cleaner_stats.bytes_read += fs->lfs_bsize; 1223 cleaner_stats.bytes_read += fs->lfs_bsize;
1224 1224
1225 /* 1225 /*
1226 * If the number of segments changed under us, reinit. 1226 * If the number of segments changed under us, reinit.
1227 * We don't have to start over from scratch, however, 1227 * We don't have to start over from scratch, however,
1228 * since we don't hold any buffers. 1228 * since we don't hold any buffers.
1229 */ 1229 */
1230 if (fs->lfs_nseg != cip->clean + cip->dirty) { 1230 if (fs->lfs_nseg != cip->clean + cip->dirty) {

cvs diff -r1.14 -r1.15 src/sbin/fsck_lfs/bufcache.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/bufcache.c 2013/10/19 01:09:58 1.14
+++ src/sbin/fsck_lfs/bufcache.c 2015/03/29 19:35:58 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bufcache.c,v 1.14 2013/10/19 01:09:58 christos Exp $ */ 1/* $NetBSD: bufcache.c,v 1.15 2015/03/29 19:35:58 chopps Exp $ */
2/*- 2/*-
3 * Copyright (c) 2003 The NetBSD Foundation, Inc. 3 * Copyright (c) 2003 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Konrad E. Schroder <perseant@hhhh.org>. 7 * by Konrad E. Schroder <perseant@hhhh.org>.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -329,28 +329,27 @@ brelse(struct ubuf * bp, int set) @@ -329,28 +329,27 @@ brelse(struct ubuf * bp, int set)
329 TAILQ_INSERT_TAIL(&bufqueues[BQ_LRU], bp, b_freelist); 329 TAILQ_INSERT_TAIL(&bufqueues[BQ_LRU], bp, b_freelist);
330 } 330 }
331 --bp->b_vp->v_usecount; 331 --bp->b_vp->v_usecount;
332 332
333 /* Move to the front of the hash chain */ 333 /* Move to the front of the hash chain */
334 if (LIST_FIRST(&bufhash[bp->b_hashval]) != bp) { 334 if (LIST_FIRST(&bufhash[bp->b_hashval]) != bp) {
335 LIST_REMOVE(bp, b_hash); 335 LIST_REMOVE(bp, b_hash);
336 LIST_INSERT_HEAD(&bufhash[bp->b_hashval], bp, b_hash); 336 LIST_INSERT_HEAD(&bufhash[bp->b_hashval], bp, b_hash);
337 } 337 }
338} 338}
339 339
340/* Read the given block from disk, return it B_BUSY. */ 340/* Read the given block from disk, return it B_BUSY. */
341int 341int
342bread(struct uvnode * vp, daddr_t lbn, int size, void * unused, 342bread(struct uvnode * vp, daddr_t lbn, int size, int flags, struct ubuf ** bpp)
343 int flags, struct ubuf ** bpp) 
344{ 343{
345 struct ubuf *bp; 344 struct ubuf *bp;
346 daddr_t daddr; 345 daddr_t daddr;
347 346
348 bp = getblk(vp, lbn, size); 347 bp = getblk(vp, lbn, size);
349 *bpp = bp; 348 *bpp = bp;
350 if (bp->b_flags & (B_DELWRI | B_DONE)) { 349 if (bp->b_flags & (B_DELWRI | B_DONE)) {
351 ++cachehits; 350 ++cachehits;
352 return 0; 351 return 0;
353 } 352 }
354 ++cachemisses; 353 ++cachemisses;
355 354
356 /* 355 /*

cvs diff -r1.11 -r1.12 src/sbin/fsck_lfs/bufcache.h (expand / switch to unified diff)

--- src/sbin/fsck_lfs/bufcache.h 2008/05/16 09:21:59 1.11
+++ src/sbin/fsck_lfs/bufcache.h 2015/03/29 19:35:58 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bufcache.h,v 1.11 2008/05/16 09:21:59 hannken Exp $ */ 1/* $NetBSD: bufcache.h,v 1.12 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -110,16 +110,16 @@ LIST_HEAD(bufhash_struct, ubuf); @@ -110,16 +110,16 @@ LIST_HEAD(bufhash_struct, ubuf);
110#if !defined(NOCRED) 110#if !defined(NOCRED)
111#define NOCRED ((void *)-1) /* dummy; not actually used */ 111#define NOCRED ((void *)-1) /* dummy; not actually used */
112#endif /* !defined(NOCRED) */ 112#endif /* !defined(NOCRED) */
113 113
114void bufinit(int); 114void bufinit(int);
115void bufrehash(int); 115void bufrehash(int);
116void bufstats(void); 116void bufstats(void);
117void buf_destroy(struct ubuf *); 117void buf_destroy(struct ubuf *);
118void bremfree(struct ubuf *); 118void bremfree(struct ubuf *);
119struct ubuf *incore(struct uvnode *, int); 119struct ubuf *incore(struct uvnode *, int);
120struct ubuf *getblk(struct uvnode *, daddr_t, int); 120struct ubuf *getblk(struct uvnode *, daddr_t, int);
121void bwrite(struct ubuf *); 121void bwrite(struct ubuf *);
122void brelse(struct ubuf *, int); 122void brelse(struct ubuf *, int);
123int bread(struct uvnode *, daddr_t, int, void *, int, struct ubuf **); 123int bread(struct uvnode *, daddr_t, int, int, struct ubuf **);
124void reassignbuf(struct ubuf *, struct uvnode *); 124void reassignbuf(struct ubuf *, struct uvnode *);
125void dump_free_lists(void); 125void dump_free_lists(void);

cvs diff -r1.32 -r1.33 src/sbin/fsck_lfs/dir.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/dir.c 2013/06/18 18:18:58 1.32
+++ src/sbin/fsck_lfs/dir.c 2015/03/29 19:35:58 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dir.c,v 1.32 2013/06/18 18:18:58 christos Exp $ */ 1/* $NetBSD: dir.c,v 1.33 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1986, 1993 4 * Copyright (c) 1980, 1986, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -145,60 +145,60 @@ dirscan(struct inodesc *idesc) @@ -145,60 +145,60 @@ dirscan(struct inodesc *idesc)
145 if (chkrange(idesc->id_blkno, idesc->id_numfrags)) { 145 if (chkrange(idesc->id_blkno, idesc->id_numfrags)) {
146 idesc->id_filesize -= blksiz; 146 idesc->id_filesize -= blksiz;
147 return (SKIP); 147 return (SKIP);
148 } 148 }
149 idesc->id_loc = 0; 149 idesc->id_loc = 0;
150 150
151 vp = vget(fs, idesc->id_number); 151 vp = vget(fs, idesc->id_number);
152 for (dp = fsck_readdir(vp, idesc); dp != NULL; 152 for (dp = fsck_readdir(vp, idesc); dp != NULL;
153 dp = fsck_readdir(vp, idesc)) { 153 dp = fsck_readdir(vp, idesc)) {
154 dsize = dp->d_reclen; 154 dsize = dp->d_reclen;
155 memcpy(dbuf, dp, (size_t) dsize); 155 memcpy(dbuf, dp, (size_t) dsize);
156 idesc->id_dirp = (struct lfs_direct *) dbuf; 156 idesc->id_dirp = (struct lfs_direct *) dbuf;
157 if ((n = (*idesc->id_func) (idesc)) & ALTERED) { 157 if ((n = (*idesc->id_func) (idesc)) & ALTERED) {
158 bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); 158 bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
159 memcpy(bp->b_data + idesc->id_loc - dsize, dbuf, 159 memcpy(bp->b_data + idesc->id_loc - dsize, dbuf,
160 (size_t) dsize); 160 (size_t) dsize);
161 VOP_BWRITE(bp); 161 VOP_BWRITE(bp);
162 sbdirty(); 162 sbdirty();
163 } 163 }
164 if (n & STOP) 164 if (n & STOP)
165 return (n); 165 return (n);
166 } 166 }
167 return (idesc->id_filesize > 0 ? KEEPON : STOP); 167 return (idesc->id_filesize > 0 ? KEEPON : STOP);
168} 168}
169 169
170/* 170/*
171 * get next entry in a directory. 171 * get next entry in a directory.
172 */ 172 */
173static struct lfs_direct * 173static struct lfs_direct *
174fsck_readdir(struct uvnode *vp, struct inodesc *idesc) 174fsck_readdir(struct uvnode *vp, struct inodesc *idesc)
175{ 175{
176 struct lfs_direct *dp, *ndp; 176 struct lfs_direct *dp, *ndp;
177 struct ubuf *bp; 177 struct ubuf *bp;
178 long size, blksiz, fix, dploc; 178 long size, blksiz, fix, dploc;
179 179
180 blksiz = idesc->id_numfrags * fs->lfs_fsize; 180 blksiz = idesc->id_numfrags * fs->lfs_fsize;
181 bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); 181 bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
182 if (idesc->id_loc % LFS_DIRBLKSIZ == 0 && idesc->id_filesize > 0 && 182 if (idesc->id_loc % LFS_DIRBLKSIZ == 0 && idesc->id_filesize > 0 &&
183 idesc->id_loc < blksiz) { 183 idesc->id_loc < blksiz) {
184 dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); 184 dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc);
185 if (dircheck(idesc, dp)) 185 if (dircheck(idesc, dp))
186 goto dpok; 186 goto dpok;
187 brelse(bp, 0); 187 brelse(bp, 0);
188 if (idesc->id_fix == IGNORE) 188 if (idesc->id_fix == IGNORE)
189 return (0); 189 return (0);
190 fix = dofix(idesc, "DIRECTORY CORRUPTED"); 190 fix = dofix(idesc, "DIRECTORY CORRUPTED");
191 bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); 191 bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
192 dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); 192 dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc);
193 dp->d_reclen = LFS_DIRBLKSIZ; 193 dp->d_reclen = LFS_DIRBLKSIZ;
194 dp->d_ino = 0; 194 dp->d_ino = 0;
195 dp->d_type = 0; 195 dp->d_type = 0;
196 dp->d_namlen = 0; 196 dp->d_namlen = 0;
197 dp->d_name[0] = '\0'; 197 dp->d_name[0] = '\0';
198 if (fix) 198 if (fix)
199 VOP_BWRITE(bp); 199 VOP_BWRITE(bp);
200 else 200 else
201 brelse(bp, 0); 201 brelse(bp, 0);
202 idesc->id_loc += LFS_DIRBLKSIZ; 202 idesc->id_loc += LFS_DIRBLKSIZ;
203 idesc->id_filesize -= LFS_DIRBLKSIZ; 203 idesc->id_filesize -= LFS_DIRBLKSIZ;
204 return (dp); 204 return (dp);
@@ -216,27 +216,27 @@ dpok: @@ -216,27 +216,27 @@ dpok:
216 brelse(bp, 0); 216 brelse(bp, 0);
217 return dp; 217 return dp;
218 } 218 }
219 ndp = (struct lfs_direct *) (bp->b_data + idesc->id_loc); 219 ndp = (struct lfs_direct *) (bp->b_data + idesc->id_loc);
220 if (idesc->id_loc < blksiz && idesc->id_filesize > 0 && 220 if (idesc->id_loc < blksiz && idesc->id_filesize > 0 &&
221 dircheck(idesc, ndp) == 0) { 221 dircheck(idesc, ndp) == 0) {
222 brelse(bp, 0); 222 brelse(bp, 0);
223 size = LFS_DIRBLKSIZ - (idesc->id_loc % LFS_DIRBLKSIZ); 223 size = LFS_DIRBLKSIZ - (idesc->id_loc % LFS_DIRBLKSIZ);
224 idesc->id_loc += size; 224 idesc->id_loc += size;
225 idesc->id_filesize -= size; 225 idesc->id_filesize -= size;
226 if (idesc->id_fix == IGNORE) 226 if (idesc->id_fix == IGNORE)
227 return 0; 227 return 0;
228 fix = dofix(idesc, "DIRECTORY CORRUPTED"); 228 fix = dofix(idesc, "DIRECTORY CORRUPTED");
229 bread(vp, idesc->id_lblkno, blksiz, NOCRED, 0, &bp); 229 bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
230 dp = (struct lfs_direct *) (bp->b_data + dploc); 230 dp = (struct lfs_direct *) (bp->b_data + dploc);
231 dp->d_reclen += size; 231 dp->d_reclen += size;
232 if (fix) 232 if (fix)
233 VOP_BWRITE(bp); 233 VOP_BWRITE(bp);
234 else 234 else
235 brelse(bp, 0); 235 brelse(bp, 0);
236 } else 236 } else
237 brelse(bp, 0); 237 brelse(bp, 0);
238 238
239 return (dp); 239 return (dp);
240} 240}
241 241
242/* 242/*
@@ -563,41 +563,41 @@ expanddir(struct uvnode *vp, struct ulfs @@ -563,41 +563,41 @@ expanddir(struct uvnode *vp, struct ulfs
563 struct ubuf *bp; 563 struct ubuf *bp;
564 char *cp, firstblk[LFS_DIRBLKSIZ]; 564 char *cp, firstblk[LFS_DIRBLKSIZ];
565 565
566 lastbn = lfs_lblkno(fs, dp->di_size); 566 lastbn = lfs_lblkno(fs, dp->di_size);
567 if (lastbn >= ULFS_NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0) 567 if (lastbn >= ULFS_NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0)
568 return (0); 568 return (0);
569 dp->di_db[lastbn + 1] = dp->di_db[lastbn]; 569 dp->di_db[lastbn + 1] = dp->di_db[lastbn];
570 dp->di_db[lastbn] = 0; 570 dp->di_db[lastbn] = 0;
571 bp = getblk(vp, lastbn, fs->lfs_bsize); 571 bp = getblk(vp, lastbn, fs->lfs_bsize);
572 VOP_BWRITE(bp); 572 VOP_BWRITE(bp);
573 dp->di_size += fs->lfs_bsize; 573 dp->di_size += fs->lfs_bsize;
574 dp->di_blocks += lfs_btofsb(fs, fs->lfs_bsize); 574 dp->di_blocks += lfs_btofsb(fs, fs->lfs_bsize);
575 bread(vp, dp->di_db[lastbn + 1], 575 bread(vp, dp->di_db[lastbn + 1],
576 (long) lfs_dblksize(fs, dp, lastbn + 1), NOCRED, 0, &bp); 576 (long) lfs_dblksize(fs, dp, lastbn + 1), 0, &bp);
577 if (bp->b_flags & B_ERROR) 577 if (bp->b_flags & B_ERROR)
578 goto bad; 578 goto bad;
579 memcpy(firstblk, bp->b_data, LFS_DIRBLKSIZ); 579 memcpy(firstblk, bp->b_data, LFS_DIRBLKSIZ);
580 bread(vp, lastbn, fs->lfs_bsize, NOCRED, 0, &bp); 580 bread(vp, lastbn, fs->lfs_bsize, 0, &bp);
581 if (bp->b_flags & B_ERROR) 581 if (bp->b_flags & B_ERROR)
582 goto bad; 582 goto bad;
583 memcpy(bp->b_data, firstblk, LFS_DIRBLKSIZ); 583 memcpy(bp->b_data, firstblk, LFS_DIRBLKSIZ);
584 for (cp = &bp->b_data[LFS_DIRBLKSIZ]; 584 for (cp = &bp->b_data[LFS_DIRBLKSIZ];
585 cp < &bp->b_data[fs->lfs_bsize]; 585 cp < &bp->b_data[fs->lfs_bsize];
586 cp += LFS_DIRBLKSIZ) 586 cp += LFS_DIRBLKSIZ)
587 memcpy(cp, &emptydir, sizeof emptydir); 587 memcpy(cp, &emptydir, sizeof emptydir);
588 VOP_BWRITE(bp); 588 VOP_BWRITE(bp);
589 bread(vp, dp->di_db[lastbn + 1], 589 bread(vp, dp->di_db[lastbn + 1],
590 (long) lfs_dblksize(fs, dp, lastbn + 1), NOCRED, 0, &bp); 590 (long) lfs_dblksize(fs, dp, lastbn + 1), 0, &bp);
591 if (bp->b_flags & B_ERROR) 591 if (bp->b_flags & B_ERROR)
592 goto bad; 592 goto bad;
593 memcpy(bp->b_data, &emptydir, sizeof emptydir); 593 memcpy(bp->b_data, &emptydir, sizeof emptydir);
594 pwarn("NO SPACE LEFT IN %s", name); 594 pwarn("NO SPACE LEFT IN %s", name);
595 if (preen) 595 if (preen)
596 printf(" (EXPANDED)\n"); 596 printf(" (EXPANDED)\n");
597 else if (reply("EXPAND") == 0) 597 else if (reply("EXPAND") == 0)
598 goto bad; 598 goto bad;
599 VOP_BWRITE(bp); 599 VOP_BWRITE(bp);
600 inodirty(VTOI(vp)); 600 inodirty(VTOI(vp));
601 return (1); 601 return (1);
602bad: 602bad:
603 dp->di_db[lastbn] = dp->di_db[lastbn + 1]; 603 dp->di_db[lastbn] = dp->di_db[lastbn + 1];
@@ -616,27 +616,27 @@ allocdir(ino_t parent, ino_t request, in @@ -616,27 +616,27 @@ allocdir(ino_t parent, ino_t request, in
616 ino_t ino; 616 ino_t ino;
617 char *cp; 617 char *cp;
618 struct ulfs1_dinode *dp; 618 struct ulfs1_dinode *dp;
619 struct ubuf *bp; 619 struct ubuf *bp;
620 struct lfs_dirtemplate *dirp; 620 struct lfs_dirtemplate *dirp;
621 struct uvnode *vp; 621 struct uvnode *vp;
622 622
623 ino = allocino(request, LFS_IFDIR | mode); 623 ino = allocino(request, LFS_IFDIR | mode);
624 dirp = &dirhead; 624 dirp = &dirhead;
625 dirp->dot_ino = ino; 625 dirp->dot_ino = ino;
626 dirp->dotdot_ino = parent; 626 dirp->dotdot_ino = parent;
627 vp = vget(fs, ino); 627 vp = vget(fs, ino);
628 dp = VTOD(vp); 628 dp = VTOD(vp);
629 bread(vp, dp->di_db[0], fs->lfs_fsize, NOCRED, 0, &bp); 629 bread(vp, dp->di_db[0], fs->lfs_fsize, 0, &bp);
630 if (bp->b_flags & B_ERROR) { 630 if (bp->b_flags & B_ERROR) {
631 brelse(bp, 0); 631 brelse(bp, 0);
632 freeino(ino); 632 freeino(ino);
633 return (0); 633 return (0);
634 } 634 }
635 memcpy(bp->b_data, dirp, sizeof(struct lfs_dirtemplate)); 635 memcpy(bp->b_data, dirp, sizeof(struct lfs_dirtemplate));
636 for (cp = &bp->b_data[LFS_DIRBLKSIZ]; 636 for (cp = &bp->b_data[LFS_DIRBLKSIZ];
637 cp < &bp->b_data[fs->lfs_fsize]; 637 cp < &bp->b_data[fs->lfs_fsize];
638 cp += LFS_DIRBLKSIZ) 638 cp += LFS_DIRBLKSIZ)
639 memcpy(cp, &emptydir, sizeof emptydir); 639 memcpy(cp, &emptydir, sizeof emptydir);
640 VOP_BWRITE(bp); 640 VOP_BWRITE(bp);
641 dp->di_nlink = 2; 641 dp->di_nlink = 2;
642 inodirty(VTOI(vp)); 642 inodirty(VTOI(vp));

cvs diff -r1.32 -r1.33 src/sbin/fsck_lfs/pass6.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/pass6.c 2013/10/19 01:09:58 1.32
+++ src/sbin/fsck_lfs/pass6.c 2015/03/29 19:35:58 1.33
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pass6.c,v 1.32 2013/10/19 01:09:58 christos Exp $ */ 1/* $NetBSD: pass6.c,v 1.33 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -110,27 +110,27 @@ rfw_update_single(struct uvnode *vp, dad @@ -110,27 +110,27 @@ rfw_update_single(struct uvnode *vp, dad
110 ofrags = lfs_numfrags(fs, ip->i_lfs_fragsize[lbn]); 110 ofrags = lfs_numfrags(fs, ip->i_lfs_fragsize[lbn]);
111 ip->i_ffs1_blocks += (frags - ofrags); 111 ip->i_ffs1_blocks += (frags - ofrags);
112 } 112 }
113 ip->i_ffs1_db[lbn] = ndaddr; 113 ip->i_ffs1_db[lbn] = ndaddr;
114 break; 114 break;
115 case 1: 115 case 1:
116 ooff = ip->i_ffs1_ib[a[0].in_off]; 116 ooff = ip->i_ffs1_ib[a[0].in_off];
117 if (ooff <= 0) 117 if (ooff <= 0)
118 ip->i_ffs1_blocks += frags; 118 ip->i_ffs1_blocks += frags;
119 ip->i_ffs1_ib[a[0].in_off] = ndaddr; 119 ip->i_ffs1_ib[a[0].in_off] = ndaddr;
120 break; 120 break;
121 default: 121 default:
122 ap = &a[num - 1]; 122 ap = &a[num - 1];
123 if (bread(vp, ap->in_lbn, fs->lfs_bsize, NULL, 0, &bp)) 123 if (bread(vp, ap->in_lbn, fs->lfs_bsize, 0, &bp))
124 errx(1, "lfs_updatemeta: bread bno %" PRId64, 124 errx(1, "lfs_updatemeta: bread bno %" PRId64,
125 ap->in_lbn); 125 ap->in_lbn);
126 126
127 ooff = ((ulfs_daddr_t *) bp->b_data)[ap->in_off]; 127 ooff = ((ulfs_daddr_t *) bp->b_data)[ap->in_off];
128 if (ooff <= 0) 128 if (ooff <= 0)
129 ip->i_ffs1_blocks += frags; 129 ip->i_ffs1_blocks += frags;
130 ((ulfs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr; 130 ((ulfs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr;
131 (void) VOP_BWRITE(bp); 131 (void) VOP_BWRITE(bp);
132 } 132 }
133 133
134 /* 134 /*
135 * Update segment usage information, based on old size 135 * Update segment usage information, based on old size
136 * and location. 136 * and location.
@@ -326,34 +326,34 @@ pass6check(struct inodesc * idesc) @@ -326,34 +326,34 @@ pass6check(struct inodesc * idesc)
326} 326}
327 327
328static void 328static void
329account_indir(struct uvnode *vp, struct ulfs1_dinode *dp, daddr_t ilbn, daddr_t daddr, int lvl) 329account_indir(struct uvnode *vp, struct ulfs1_dinode *dp, daddr_t ilbn, daddr_t daddr, int lvl)
330{ 330{
331 struct ubuf *bp; 331 struct ubuf *bp;
332 int32_t *dap, *odap, *buf, *obuf; 332 int32_t *dap, *odap, *buf, *obuf;
333 daddr_t lbn; 333 daddr_t lbn;
334 334
335 if (lvl == 0) 335 if (lvl == 0)
336 lbn = -ilbn; 336 lbn = -ilbn;
337 else 337 else
338 lbn = ilbn + 1; 338 lbn = ilbn + 1;
339 bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_bsize, NULL, 0, &bp); 339 bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_bsize, 0, &bp);
340 buf = emalloc(fs->lfs_bsize); 340 buf = emalloc(fs->lfs_bsize);
341 memcpy(buf, bp->b_data, fs->lfs_bsize); 341 memcpy(buf, bp->b_data, fs->lfs_bsize);
342 brelse(bp, 0); 342 brelse(bp, 0);
343 343
344 obuf = emalloc(fs->lfs_bsize); 344 obuf = emalloc(fs->lfs_bsize);
345 if (vp) { 345 if (vp) {
346 bread(vp, ilbn, fs->lfs_bsize, NULL, 0, &bp); 346 bread(vp, ilbn, fs->lfs_bsize, 0, &bp);
347 memcpy(obuf, bp->b_data, fs->lfs_bsize); 347 memcpy(obuf, bp->b_data, fs->lfs_bsize);
348 brelse(bp, 0); 348 brelse(bp, 0);
349 } else 349 } else
350 memset(obuf, 0, fs->lfs_bsize); 350 memset(obuf, 0, fs->lfs_bsize);
351 351
352 for (dap = buf, odap = obuf; 352 for (dap = buf, odap = obuf;
353 dap < (int32_t *)((char *)buf + fs->lfs_bsize); 353 dap < (int32_t *)((char *)buf + fs->lfs_bsize);
354 ++dap, ++odap) { 354 ++dap, ++odap) {
355 if (*dap > 0 && *dap != *odap) { 355 if (*dap > 0 && *dap != *odap) {
356 rfw_update_single(vp, lbn, *dap, lfs_dblksize(fs, dp, lbn)); 356 rfw_update_single(vp, lbn, *dap, lfs_dblksize(fs, dp, lbn));
357 if (lvl > 0) 357 if (lvl > 0)
358 account_indir(vp, dp, lbn, *dap, lvl - 1); 358 account_indir(vp, dp, lbn, *dap, lvl - 1);
359 } 359 }
@@ -601,27 +601,27 @@ pass6(void) @@ -601,27 +601,27 @@ pass6(void)
601 daddr += lfs_btofsb(fs, LFS_LABELPAD); 601 daddr += lfs_btofsb(fs, LFS_LABELPAD);
602 } 602 }
603 for (i = 0; i < LFS_MAXNUMSB; i++) { 603 for (i = 0; i < LFS_MAXNUMSB; i++) {
604 if (daddr == fs->lfs_sboffs[i]) { 604 if (daddr == fs->lfs_sboffs[i]) {
605 ++hassuper; 605 ++hassuper;
606 daddr += lfs_btofsb(fs, LFS_SBPAD);  606 daddr += lfs_btofsb(fs, LFS_SBPAD);
607 } 607 }
608 if (daddr < fs->lfs_sboffs[i]) 608 if (daddr < fs->lfs_sboffs[i])
609 break; 609 break;
610 } 610 }
611 } 611 }
612  612
613 /* Read in summary block */ 613 /* Read in summary block */
614 bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, NULL, 0, &bp); 614 bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, 0, &bp);
615 sp = (SEGSUM *)bp->b_data; 615 sp = (SEGSUM *)bp->b_data;
616 if (debug) 616 if (debug)
617 pwarn("sum at 0x%x: ninos=%d nfinfo=%d\n", 617 pwarn("sum at 0x%x: ninos=%d nfinfo=%d\n",
618 (unsigned)daddr, (int)sp->ss_ninos, 618 (unsigned)daddr, (int)sp->ss_ninos,
619 (int)sp->ss_nfinfo); 619 (int)sp->ss_nfinfo);
620 620
621 /* We have verified that this is a good summary. */ 621 /* We have verified that this is a good summary. */
622 LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp); 622 LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, daddr), sbp);
623 ++sup->su_nsums; 623 ++sup->su_nsums;
624 VOP_BWRITE(sbp); 624 VOP_BWRITE(sbp);
625 fs->lfs_bfree -= lfs_btofsb(fs, fs->lfs_sumsize); 625 fs->lfs_bfree -= lfs_btofsb(fs, fs->lfs_sumsize);
626 fs->lfs_dmeta += lfs_btofsb(fs, fs->lfs_sumsize); 626 fs->lfs_dmeta += lfs_btofsb(fs, fs->lfs_sumsize);
627 sbdirty(); 627 sbdirty();
@@ -640,27 +640,27 @@ pass6(void) @@ -640,27 +640,27 @@ pass6(void)
640 fs->lfs_dmeta += lfs_btofsb(fs, howmany(sp->ss_ninos, 640 fs->lfs_dmeta += lfs_btofsb(fs, howmany(sp->ss_ninos,
641 LFS_INOPB(fs)) * 641 LFS_INOPB(fs)) *
642 fs->lfs_ibsize); 642 fs->lfs_ibsize);
643 } 643 }
644 idaddrp = ((ulfs_daddr_t *)((char *)bp->b_data + fs->lfs_sumsize)); 644 idaddrp = ((ulfs_daddr_t *)((char *)bp->b_data + fs->lfs_sumsize));
645 for (i = 0; i < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) { 645 for (i = 0; i < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) {
646 ino_t *inums; 646 ino_t *inums;
647  647
648 inums = ecalloc(LFS_INOPB(fs) + 1, sizeof(*inums)); 648 inums = ecalloc(LFS_INOPB(fs) + 1, sizeof(*inums));
649 ibdaddr = *--idaddrp; 649 ibdaddr = *--idaddrp;
650 fs->lfs_bfree -= lfs_btofsb(fs, fs->lfs_ibsize); 650 fs->lfs_bfree -= lfs_btofsb(fs, fs->lfs_ibsize);
651 sbdirty(); 651 sbdirty();
652 bread(devvp, LFS_FSBTODB(fs, ibdaddr), fs->lfs_ibsize, 652 bread(devvp, LFS_FSBTODB(fs, ibdaddr), fs->lfs_ibsize,
653 NOCRED, 0, &ibp); 653 0, &ibp);
654 memcpy(ibbuf, ibp->b_data, fs->lfs_ibsize); 654 memcpy(ibbuf, ibp->b_data, fs->lfs_ibsize);
655 brelse(ibp, 0); 655 brelse(ibp, 0);
656 656
657 j = 0; 657 j = 0;
658 for (dp = (struct ulfs1_dinode *)ibbuf; 658 for (dp = (struct ulfs1_dinode *)ibbuf;
659 dp < (struct ulfs1_dinode *)ibbuf + LFS_INOPB(fs); 659 dp < (struct ulfs1_dinode *)ibbuf + LFS_INOPB(fs);
660 ++dp) { 660 ++dp) {
661 if (dp->di_inumber == 0 || 661 if (dp->di_inumber == 0 ||
662 dp->di_inumber == fs->lfs_ifile) 662 dp->di_inumber == fs->lfs_ifile)
663 continue; 663 continue;
664 /* Basic sanity checks */ 664 /* Basic sanity checks */
665 if (dp->di_nlink < 0  665 if (dp->di_nlink < 0
666#if 0 666#if 0
@@ -827,27 +827,27 @@ pass6(void) @@ -827,27 +827,27 @@ pass6(void)
827 if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr) { 827 if (lfs_sntod(fs, lfs_dtosn(fs, daddr)) == daddr) {
828 if (daddr == fs->lfs_start) 828 if (daddr == fs->lfs_start)
829 daddr += lfs_btofsb(fs, LFS_LABELPAD); 829 daddr += lfs_btofsb(fs, LFS_LABELPAD);
830 for (i = 0; i < LFS_MAXNUMSB; i++) { 830 for (i = 0; i < LFS_MAXNUMSB; i++) {
831 if (daddr == fs->lfs_sboffs[i]) { 831 if (daddr == fs->lfs_sboffs[i]) {
832 daddr += lfs_btofsb(fs, LFS_SBPAD);  832 daddr += lfs_btofsb(fs, LFS_SBPAD);
833 } 833 }
834 if (daddr < fs->lfs_sboffs[i]) 834 if (daddr < fs->lfs_sboffs[i])
835 break; 835 break;
836 } 836 }
837 } 837 }
838  838
839 /* Read in summary block */ 839 /* Read in summary block */
840 bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, NULL, 0, &bp); 840 bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_sumsize, 0, &bp);
841 sp = (SEGSUM *)bp->b_data; 841 sp = (SEGSUM *)bp->b_data;
842 bc = check_summary(fs, sp, daddr, debug, devvp, pass6harvest); 842 bc = check_summary(fs, sp, daddr, debug, devvp, pass6harvest);
843 if (bc == 0) { 843 if (bc == 0) {
844 pwarn("unexpected bad seg ptr [2] at 0x%x with serial=%d\n", 844 pwarn("unexpected bad seg ptr [2] at 0x%x with serial=%d\n",
845 (int)daddr, (int)sp->ss_serial); 845 (int)daddr, (int)sp->ss_serial);
846 brelse(bp, 0); 846 brelse(bp, 0);
847 break; 847 break;
848 } 848 }
849 odaddr = daddr; 849 odaddr = daddr;
850 daddr += lfs_btofsb(fs, fs->lfs_sumsize + bc); 850 daddr += lfs_btofsb(fs, fs->lfs_sumsize + bc);
851 fs->lfs_avail -= lfs_btofsb(fs, fs->lfs_sumsize + bc); 851 fs->lfs_avail -= lfs_btofsb(fs, fs->lfs_sumsize + bc);
852 if (lfs_dtosn(fs, odaddr) != lfs_dtosn(fs, daddr) || 852 if (lfs_dtosn(fs, odaddr) != lfs_dtosn(fs, daddr) ||
853 lfs_dtosn(fs, daddr) != lfs_dtosn(fs, daddr + 853 lfs_dtosn(fs, daddr) != lfs_dtosn(fs, daddr +

cvs diff -r1.52 -r1.53 src/sbin/fsck_lfs/inode.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/inode.c 2014/03/23 05:39:32 1.52
+++ src/sbin/fsck_lfs/inode.c 2015/03/29 19:35:58 1.53
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: inode.c,v 1.52 2014/03/23 05:39:32 dholland Exp $ */ 1/* $NetBSD: inode.c,v 1.53 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -236,27 +236,27 @@ iblock(struct inodesc *idesc, long ileve @@ -236,27 +236,27 @@ iblock(struct inodesc *idesc, long ileve
236 236
237 if (idesc->id_type == ADDR) { 237 if (idesc->id_type == ADDR) {
238 func = idesc->id_func; 238 func = idesc->id_func;
239 n = (*func) (idesc); 239 n = (*func) (idesc);
240 if ((n & KEEPON) == 0) 240 if ((n & KEEPON) == 0)
241 return (n); 241 return (n);
242 } else 242 } else
243 func = dirscan; 243 func = dirscan;
244 if (chkrange(idesc->id_blkno, idesc->id_numfrags)) 244 if (chkrange(idesc->id_blkno, idesc->id_numfrags))
245 return (SKIP); 245 return (SKIP);
246 246
247 devvp = fs->lfs_devvp; 247 devvp = fs->lfs_devvp;
248 bread(devvp, LFS_FSBTODB(fs, idesc->id_blkno), fs->lfs_bsize, 248 bread(devvp, LFS_FSBTODB(fs, idesc->id_blkno), fs->lfs_bsize,
249 NOCRED, 0, &bp); 249 0, &bp);
250 ilevel--; 250 ilevel--;
251 for (sizepb = fs->lfs_bsize, i = 0; i < ilevel; i++) 251 for (sizepb = fs->lfs_bsize, i = 0; i < ilevel; i++)
252 sizepb *= LFS_NINDIR(fs); 252 sizepb *= LFS_NINDIR(fs);
253 if (isize > sizepb * LFS_NINDIR(fs)) 253 if (isize > sizepb * LFS_NINDIR(fs))
254 nif = LFS_NINDIR(fs); 254 nif = LFS_NINDIR(fs);
255 else 255 else
256 nif = howmany(isize, sizepb); 256 nif = howmany(isize, sizepb);
257 if (idesc->id_func == pass1check && nif < LFS_NINDIR(fs)) { 257 if (idesc->id_func == pass1check && nif < LFS_NINDIR(fs)) {
258 aplim = ((ulfs_daddr_t *) bp->b_data) + LFS_NINDIR(fs); 258 aplim = ((ulfs_daddr_t *) bp->b_data) + LFS_NINDIR(fs);
259 for (ap = ((ulfs_daddr_t *) bp->b_data) + nif; ap < aplim; ap++) { 259 for (ap = ((ulfs_daddr_t *) bp->b_data) + nif; ap < aplim; ap++) {
260 if (*ap == 0) 260 if (*ap == 0)
261 continue; 261 continue;
262 (void)snprintf(buf, sizeof(buf), 262 (void)snprintf(buf, sizeof(buf),

cvs diff -r1.43 -r1.44 src/sbin/fsck_lfs/lfs.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/lfs.c 2014/07/13 02:44:21 1.43
+++ src/sbin/fsck_lfs/lfs.c 2015/03/29 19:35:58 1.44
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lfs.c,v 1.43 2014/07/13 02:44:21 dholland Exp $ */ 1/* $NetBSD: lfs.c,v 1.44 2015/03/29 19:35:58 chopps Exp $ */
2/*- 2/*-
3 * Copyright (c) 2003 The NetBSD Foundation, Inc. 3 * Copyright (c) 2003 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Konrad E. Schroder <perseant@hhhh.org>. 7 * by Konrad E. Schroder <perseant@hhhh.org>.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -357,27 +357,27 @@ lfs_raw_vget(struct lfs * fs, ino_t ino, @@ -357,27 +357,27 @@ lfs_raw_vget(struct lfs * fs, ino_t ino,
357 357
358 /* Initialize the inode -- from lfs_vcreate. */ 358 /* Initialize the inode -- from lfs_vcreate. */
359 ip->inode_ext.lfs = ecalloc(1, sizeof(*ip->inode_ext.lfs)); 359 ip->inode_ext.lfs = ecalloc(1, sizeof(*ip->inode_ext.lfs));
360 vp->v_data = ip; 360 vp->v_data = ip;
361 /* ip->i_vnode = vp; */ 361 /* ip->i_vnode = vp; */
362 ip->i_number = ino; 362 ip->i_number = ino;
363 ip->i_lockf = 0; 363 ip->i_lockf = 0;
364 ip->i_lfs_effnblks = 0; 364 ip->i_lfs_effnblks = 0;
365 ip->i_flag = 0; 365 ip->i_flag = 0;
366 366
367 /* Load inode block and find inode */ 367 /* Load inode block and find inode */
368 if (daddr > 0) { 368 if (daddr > 0) {
369 bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize, 369 bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize,
370 NULL, 0, &bp); 370 0, &bp);
371 bp->b_flags |= B_AGE; 371 bp->b_flags |= B_AGE;
372 dip = lfs_ifind(fs, ino, bp); 372 dip = lfs_ifind(fs, ino, bp);
373 if (dip == NULL) { 373 if (dip == NULL) {
374 brelse(bp, 0); 374 brelse(bp, 0);
375 free(ip); 375 free(ip);
376 free(vp); 376 free(vp);
377 return NULL; 377 return NULL;
378 } 378 }
379 memcpy(ip->i_din.ffs1_din, dip, sizeof(*dip)); 379 memcpy(ip->i_din.ffs1_din, dip, sizeof(*dip));
380 brelse(bp, 0); 380 brelse(bp, 0);
381 } 381 }
382 ip->i_number = ino; 382 ip->i_number = ino;
383 /* ip->i_devvp = fs->lfs_devvp; */ 383 /* ip->i_devvp = fs->lfs_devvp; */
@@ -469,38 +469,38 @@ lfs_init(int devfd, daddr_t sblkno, dadd @@ -469,38 +469,38 @@ lfs_init(int devfd, daddr_t sblkno, dadd
469 sblkno = LFS_LABELPAD / dev_bsize; 469 sblkno = LFS_LABELPAD / dev_bsize;
470 fs = ecalloc(1, sizeof(*fs)); 470 fs = ecalloc(1, sizeof(*fs));
471 fs->lfs_devvp = devvp; 471 fs->lfs_devvp = devvp;
472 } else { 472 } else {
473 if (sblkno == 0) { 473 if (sblkno == 0) {
474 sblkno = LFS_LABELPAD / dev_bsize; 474 sblkno = LFS_LABELPAD / dev_bsize;
475 tryalt = 1; 475 tryalt = 1;
476 } else if (debug) { 476 } else if (debug) {
477 printf("No -b flag given, not attempting to verify checkpoint\n"); 477 printf("No -b flag given, not attempting to verify checkpoint\n");
478 } 478 }
479 479
480 dev_bsize = DEV_BSIZE; 480 dev_bsize = DEV_BSIZE;
481 481
482 (void)bread(devvp, sblkno, LFS_SBPAD, NOCRED, 0, &bp); 482 (void)bread(devvp, sblkno, LFS_SBPAD, 0, &bp);
483 fs = ecalloc(1, sizeof(*fs)); 483 fs = ecalloc(1, sizeof(*fs));
484 fs->lfs_dlfs = *((struct dlfs *) bp->b_data); 484 fs->lfs_dlfs = *((struct dlfs *) bp->b_data);
485 fs->lfs_devvp = devvp; 485 fs->lfs_devvp = devvp;
486 bp->b_flags |= B_INVAL; 486 bp->b_flags |= B_INVAL;
487 brelse(bp, 0); 487 brelse(bp, 0);
488 488
489 dev_bsize = fs->lfs_fsize >> fs->lfs_fsbtodb; 489 dev_bsize = fs->lfs_fsize >> fs->lfs_fsbtodb;
490  490
491 if (tryalt) { 491 if (tryalt) {
492 (void)bread(devvp, LFS_FSBTODB(fs, fs->lfs_sboffs[1]), 492 (void)bread(devvp, LFS_FSBTODB(fs, fs->lfs_sboffs[1]),
493 LFS_SBPAD, NOCRED, 0, &bp); 493 LFS_SBPAD, 0, &bp);
494 altfs = ecalloc(1, sizeof(*altfs)); 494 altfs = ecalloc(1, sizeof(*altfs));
495 altfs->lfs_dlfs = *((struct dlfs *) bp->b_data); 495 altfs->lfs_dlfs = *((struct dlfs *) bp->b_data);
496 altfs->lfs_devvp = devvp; 496 altfs->lfs_devvp = devvp;
497 bp->b_flags |= B_INVAL; 497 bp->b_flags |= B_INVAL;
498 brelse(bp, 0); 498 brelse(bp, 0);
499  499
500 if (check_sb(fs) || fs->lfs_idaddr <= 0) { 500 if (check_sb(fs) || fs->lfs_idaddr <= 0) {
501 if (debug) 501 if (debug)
502 printf("Primary superblock is no good, using first alternate\n"); 502 printf("Primary superblock is no good, using first alternate\n");
503 free(fs); 503 free(fs);
504 fs = altfs; 504 fs = altfs;
505 } else { 505 } else {
506 /* If both superblocks check out, try verification */ 506 /* If both superblocks check out, try verification */
@@ -588,27 +588,27 @@ try_verify(struct lfs *osb, struct uvnod @@ -588,27 +588,27 @@ try_verify(struct lfs *osb, struct uvnod
588 if (lfs_sntod(osb, lfs_dtosn(osb, daddr)) == daddr) { 588 if (lfs_sntod(osb, lfs_dtosn(osb, daddr)) == daddr) {
589 if (daddr == osb->lfs_start) 589 if (daddr == osb->lfs_start)
590 daddr += lfs_btofsb(osb, LFS_LABELPAD); 590 daddr += lfs_btofsb(osb, LFS_LABELPAD);
591 for (i = 0; i < LFS_MAXNUMSB; i++) { 591 for (i = 0; i < LFS_MAXNUMSB; i++) {
592 if (osb->lfs_sboffs[i] < daddr) 592 if (osb->lfs_sboffs[i] < daddr)
593 break; 593 break;
594 if (osb->lfs_sboffs[i] == daddr) 594 if (osb->lfs_sboffs[i] == daddr)
595 daddr += lfs_btofsb(osb, LFS_SBPAD); 595 daddr += lfs_btofsb(osb, LFS_SBPAD);
596 } 596 }
597 } 597 }
598 598
599 /* Read in summary block */ 599 /* Read in summary block */
600 bread(devvp, LFS_FSBTODB(osb, daddr), osb->lfs_sumsize, 600 bread(devvp, LFS_FSBTODB(osb, daddr), osb->lfs_sumsize,
601 NULL, 0, &bp); 601 0, &bp);
602 sp = (SEGSUM *)bp->b_data; 602 sp = (SEGSUM *)bp->b_data;
603 603
604 /* 604 /*
605 * Check for a valid segment summary belonging to our fs. 605 * Check for a valid segment summary belonging to our fs.
606 */ 606 */
607 if (sp->ss_magic != SS_MAGIC || 607 if (sp->ss_magic != SS_MAGIC ||
608 sp->ss_ident != osb->lfs_ident || 608 sp->ss_ident != osb->lfs_ident ||
609 sp->ss_serial < serial || /* XXX strengthen this */ 609 sp->ss_serial < serial || /* XXX strengthen this */
610 sp->ss_sumsum != cksum(&sp->ss_datasum, osb->lfs_sumsize - 610 sp->ss_sumsum != cksum(&sp->ss_datasum, osb->lfs_sumsize -
611 sizeof(sp->ss_sumsum))) { 611 sizeof(sp->ss_sumsum))) {
612 brelse(bp, 0); 612 brelse(bp, 0);
613 if (debug) { 613 if (debug) {
614 if (sp->ss_magic != SS_MAGIC) 614 if (sp->ss_magic != SS_MAGIC)
@@ -780,43 +780,43 @@ check_summary(struct lfs *fs, SEGSUM *sp @@ -780,43 +780,43 @@ check_summary(struct lfs *fs, SEGSUM *sp
780 for (i = 0, j = 0; 780 for (i = 0, j = 0;
781 i < sp->ss_nfinfo || j < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) { 781 i < sp->ss_nfinfo || j < howmany(sp->ss_ninos, LFS_INOPB(fs)); i++) {
782 if (i >= sp->ss_nfinfo && *idp != daddr) { 782 if (i >= sp->ss_nfinfo && *idp != daddr) {
783 pwarn("Not enough inode blocks in pseg at 0x%" PRIx32 783 pwarn("Not enough inode blocks in pseg at 0x%" PRIx32
784 ": found %d, wanted %d\n", 784 ": found %d, wanted %d\n",
785 pseg_addr, j, howmany(sp->ss_ninos, LFS_INOPB(fs))); 785 pseg_addr, j, howmany(sp->ss_ninos, LFS_INOPB(fs)));
786 if (debug) 786 if (debug)
787 pwarn("*idp=%x, daddr=%" PRIx32 "\n", *idp, 787 pwarn("*idp=%x, daddr=%" PRIx32 "\n", *idp,
788 daddr); 788 daddr);
789 break; 789 break;
790 } 790 }
791 while (j < howmany(sp->ss_ninos, LFS_INOPB(fs)) && *idp == daddr) { 791 while (j < howmany(sp->ss_ninos, LFS_INOPB(fs)) && *idp == daddr) {
792 bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize, 792 bread(devvp, LFS_FSBTODB(fs, daddr), fs->lfs_ibsize,
793 NOCRED, 0, &bp); 793 0, &bp);
794 datap[datac++] = ((u_int32_t *) (bp->b_data))[0]; 794 datap[datac++] = ((u_int32_t *) (bp->b_data))[0];
795 brelse(bp, 0); 795 brelse(bp, 0);
796 796
797 ++j; 797 ++j;
798 daddr += lfs_btofsb(fs, fs->lfs_ibsize); 798 daddr += lfs_btofsb(fs, fs->lfs_ibsize);
799 --idp; 799 --idp;
800 } 800 }
801 if (i < sp->ss_nfinfo) { 801 if (i < sp->ss_nfinfo) {
802 if (func) 802 if (func)
803 func(daddr, fp); 803 func(daddr, fp);
804 for (k = 0; k < fp->fi_nblocks; k++) { 804 for (k = 0; k < fp->fi_nblocks; k++) {
805 len = (k == fp->fi_nblocks - 1 ? 805 len = (k == fp->fi_nblocks - 1 ?
806 fp->fi_lastlength 806 fp->fi_lastlength
807 : fs->lfs_bsize); 807 : fs->lfs_bsize);
808 bread(devvp, LFS_FSBTODB(fs, daddr), len, 808 bread(devvp, LFS_FSBTODB(fs, daddr), len,
809 NOCRED, 0, &bp); 809 0, &bp);
810 datap[datac++] = ((u_int32_t *) (bp->b_data))[0]; 810 datap[datac++] = ((u_int32_t *) (bp->b_data))[0];
811 brelse(bp, 0); 811 brelse(bp, 0);
812 daddr += lfs_btofsb(fs, len); 812 daddr += lfs_btofsb(fs, len);
813 } 813 }
814 fp = (FINFO *) (fp->fi_blocks + fp->fi_nblocks); 814 fp = (FINFO *) (fp->fi_blocks + fp->fi_nblocks);
815 } 815 }
816 } 816 }
817 817
818 if (datac != nblocks) { 818 if (datac != nblocks) {
819 pwarn("Partial segment at 0x%llx expected %d blocks counted %d\n", 819 pwarn("Partial segment at 0x%llx expected %d blocks counted %d\n",
820 (long long) pseg_addr, nblocks, datac); 820 (long long) pseg_addr, nblocks, datac);
821 } 821 }
822 ccksum = cksum(datap, nblocks * sizeof(u_int32_t)); 822 ccksum = cksum(datap, nblocks * sizeof(u_int32_t));
@@ -1033,27 +1033,27 @@ lfs_balloc(struct uvnode *vp, off_t star @@ -1033,27 +1033,27 @@ lfs_balloc(struct uvnode *vp, off_t star
1033 /* Brand new block or fragment */ 1033 /* Brand new block or fragment */
1034 frags = lfs_numfrags(fs, nsize); 1034 frags = lfs_numfrags(fs, nsize);
1035 if (bpp) { 1035 if (bpp) {
1036 *bpp = bp = getblk(vp, lbn, nsize); 1036 *bpp = bp = getblk(vp, lbn, nsize);
1037 bp->b_blkno = UNWRITTEN; 1037 bp->b_blkno = UNWRITTEN;
1038 } 1038 }
1039 ip->i_lfs_effnblks += frags; 1039 ip->i_lfs_effnblks += frags;
1040 fs->lfs_bfree -= frags; 1040 fs->lfs_bfree -= frags;
1041 ip->i_ffs1_db[lbn] = UNWRITTEN; 1041 ip->i_ffs1_db[lbn] = UNWRITTEN;
1042 } else { 1042 } else {
1043 if (nsize <= osize) { 1043 if (nsize <= osize) {
1044 /* No need to extend */ 1044 /* No need to extend */
1045 if (bpp && (error = bread(vp, lbn, osize, 1045 if (bpp && (error = bread(vp, lbn, osize,
1046 NOCRED, 0, &bp))) 1046 0, &bp)))
1047 return error; 1047 return error;
1048 } else { 1048 } else {
1049 /* Extend existing block */ 1049 /* Extend existing block */
1050 if ((error = 1050 if ((error =
1051 lfs_fragextend(vp, osize, nsize, lbn, 1051 lfs_fragextend(vp, osize, nsize, lbn,
1052 (bpp ? &bp : NULL)))) 1052 (bpp ? &bp : NULL))))
1053 return error; 1053 return error;
1054 } 1054 }
1055 if (bpp) 1055 if (bpp)
1056 *bpp = bp; 1056 *bpp = bp;
1057 } 1057 }
1058 return 0; 1058 return 0;
1059 } 1059 }
@@ -1139,28 +1139,27 @@ lfs_balloc(struct uvnode *vp, off_t star @@ -1139,28 +1139,27 @@ lfs_balloc(struct uvnode *vp, off_t star
1139 /* Note the new address */ 1139 /* Note the new address */
1140 bp->b_blkno = UNWRITTEN; 1140 bp->b_blkno = UNWRITTEN;
1141 } 1141 }
1142 1142
1143 switch (num) { 1143 switch (num) {
1144 case 0: 1144 case 0:
1145 ip->i_ffs1_db[lbn] = UNWRITTEN; 1145 ip->i_ffs1_db[lbn] = UNWRITTEN;
1146 break; 1146 break;
1147 case 1: 1147 case 1:
1148 ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN; 1148 ip->i_ffs1_ib[indirs[0].in_off] = UNWRITTEN;
1149 break; 1149 break;
1150 default: 1150 default:
1151 idp = &indirs[num - 1]; 1151 idp = &indirs[num - 1];
1152 if (bread(vp, idp->in_lbn, fs->lfs_bsize, NOCRED, 1152 if (bread(vp, idp->in_lbn, fs->lfs_bsize, 0, &ibp))
1153 0, &ibp)) 
1154 panic("lfs_balloc: bread bno %lld", 1153 panic("lfs_balloc: bread bno %lld",
1155 (long long)idp->in_lbn); 1154 (long long)idp->in_lbn);
1156 /* XXX ondisk32 */ 1155 /* XXX ondisk32 */
1157 ((int32_t *)ibp->b_data)[idp->in_off] = UNWRITTEN; 1156 ((int32_t *)ibp->b_data)[idp->in_off] = UNWRITTEN;
1158 VOP_BWRITE(ibp); 1157 VOP_BWRITE(ibp);
1159 } 1158 }
1160 } else if (bpp && !(bp->b_flags & (B_DONE|B_DELWRI))) { 1159 } else if (bpp && !(bp->b_flags & (B_DONE|B_DELWRI))) {
1161 /* 1160 /*
1162 * Not a brand new block, also not in the cache; 1161 * Not a brand new block, also not in the cache;
1163 * read it in from disk. 1162 * read it in from disk.
1164 */ 1163 */
1165 if (iosize == fs->lfs_bsize) 1164 if (iosize == fs->lfs_bsize)
1166 /* Optimization: I/O is unnecessary. */ 1165 /* Optimization: I/O is unnecessary. */
@@ -1190,27 +1189,27 @@ lfs_fragextend(struct uvnode *vp, int os @@ -1190,27 +1189,27 @@ lfs_fragextend(struct uvnode *vp, int os
1190 int error; 1189 int error;
1191 1190
1192 ip = VTOI(vp); 1191 ip = VTOI(vp);
1193 fs = ip->i_lfs; 1192 fs = ip->i_lfs;
1194 frags = (long)lfs_numfrags(fs, nsize - osize); 1193 frags = (long)lfs_numfrags(fs, nsize - osize);
1195 error = 0; 1194 error = 0;
1196 1195
1197 /* 1196 /*
1198 * If we are not asked to actually return the block, all we need 1197 * If we are not asked to actually return the block, all we need
1199 * to do is allocate space for it. UBC will handle dirtying the 1198 * to do is allocate space for it. UBC will handle dirtying the
1200 * appropriate things and making sure it all goes to disk. 1199 * appropriate things and making sure it all goes to disk.
1201 * Don't bother to read in that case. 1200 * Don't bother to read in that case.
1202 */ 1201 */
1203 if (bpp && (error = bread(vp, lbn, osize, NOCRED, 0, bpp))) { 1202 if (bpp && (error = bread(vp, lbn, osize, 0, bpp))) {
1204 brelse(*bpp, 0); 1203 brelse(*bpp, 0);
1205 goto out; 1204 goto out;
1206 } 1205 }
1207 1206
1208 fs->lfs_bfree -= frags; 1207 fs->lfs_bfree -= frags;
1209 ip->i_lfs_effnblks += frags; 1208 ip->i_lfs_effnblks += frags;
1210 ip->i_flag |= IN_CHANGE | IN_UPDATE; 1209 ip->i_flag |= IN_CHANGE | IN_UPDATE;
1211 1210
1212 if (bpp) { 1211 if (bpp) {
1213 (*bpp)->b_data = erealloc((*bpp)->b_data, nsize); 1212 (*bpp)->b_data = erealloc((*bpp)->b_data, nsize);
1214 (void)memset((*bpp)->b_data + osize, 0, nsize - osize); 1213 (void)memset((*bpp)->b_data + osize, 0, nsize - osize);
1215 } 1214 }
1216 1215

cvs diff -r1.27 -r1.28 src/sbin/fsck_lfs/segwrite.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/segwrite.c 2013/10/19 01:09:58 1.27
+++ src/sbin/fsck_lfs/segwrite.c 2015/03/29 19:35:58 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: segwrite.c,v 1.27 2013/10/19 01:09:58 christos Exp $ */ 1/* $NetBSD: segwrite.c,v 1.28 2015/03/29 19:35:58 chopps Exp $ */
2/*- 2/*-
3 * Copyright (c) 2003 The NetBSD Foundation, Inc. 3 * Copyright (c) 2003 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Konrad E. Schroder <perseant@hhhh.org>. 7 * by Konrad E. Schroder <perseant@hhhh.org>.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -462,27 +462,27 @@ lfs_update_single(struct lfs * fs, struc @@ -462,27 +462,27 @@ lfs_update_single(struct lfs * fs, struc
462 ofrags = lfs_btofsb(fs, ip->i_lfs_fragsize[lbn]); 462 ofrags = lfs_btofsb(fs, ip->i_lfs_fragsize[lbn]);
463 ip->i_ffs1_blocks += (frags - ofrags); 463 ip->i_ffs1_blocks += (frags - ofrags);
464 } 464 }
465 ip->i_ffs1_db[lbn] = ndaddr; 465 ip->i_ffs1_db[lbn] = ndaddr;
466 break; 466 break;
467 case 1: 467 case 1:
468 ooff = ip->i_ffs1_ib[a[0].in_off]; 468 ooff = ip->i_ffs1_ib[a[0].in_off];
469 if (ooff == UNWRITTEN) 469 if (ooff == UNWRITTEN)
470 ip->i_ffs1_blocks += frags; 470 ip->i_ffs1_blocks += frags;
471 ip->i_ffs1_ib[a[0].in_off] = ndaddr; 471 ip->i_ffs1_ib[a[0].in_off] = ndaddr;
472 break; 472 break;
473 default: 473 default:
474 ap = &a[num - 1]; 474 ap = &a[num - 1];
475 if (bread(vp, ap->in_lbn, fs->lfs_bsize, NULL, 0, &bp)) 475 if (bread(vp, ap->in_lbn, fs->lfs_bsize, 0, &bp))
476 errx(1, "lfs_updatemeta: bread bno %" PRId64, 476 errx(1, "lfs_updatemeta: bread bno %" PRId64,
477 ap->in_lbn); 477 ap->in_lbn);
478 478
479 ooff = ((ulfs_daddr_t *) bp->b_data)[ap->in_off]; 479 ooff = ((ulfs_daddr_t *) bp->b_data)[ap->in_off];
480 if (ooff == UNWRITTEN) 480 if (ooff == UNWRITTEN)
481 ip->i_ffs1_blocks += frags; 481 ip->i_ffs1_blocks += frags;
482 ((ulfs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr; 482 ((ulfs_daddr_t *) bp->b_data)[ap->in_off] = ndaddr;
483 (void) VOP_BWRITE(bp); 483 (void) VOP_BWRITE(bp);
484 } 484 }
485 485
486 /* 486 /*
487 * Update segment usage information, based on old size 487 * Update segment usage information, based on old size
488 * and location. 488 * and location.

cvs diff -r1.44 -r1.45 src/sbin/fsck_lfs/setup.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/setup.c 2013/06/18 18:18:58 1.44
+++ src/sbin/fsck_lfs/setup.c 2015/03/29 19:35:58 1.45
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: setup.c,v 1.44 2013/06/18 18:18:58 christos Exp $ */ 1/* $NetBSD: setup.c,v 1.45 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -246,27 +246,27 @@ setup(const char *dev) @@ -246,27 +246,27 @@ setup(const char *dev)
246 if (fs->lfs_sboffs[i] == tdaddr) 246 if (fs->lfs_sboffs[i] == tdaddr)
247 tdaddr += lfs_btofsb(fs, LFS_SBPAD); 247 tdaddr += lfs_btofsb(fs, LFS_SBPAD);
248 if (fs->lfs_sboffs[i] > tdaddr) 248 if (fs->lfs_sboffs[i] > tdaddr)
249 break; 249 break;
250 } 250 }
251 } 251 }
252 fs->lfs_offset = tdaddr; 252 fs->lfs_offset = tdaddr;
253 if (debug) 253 if (debug)
254 pwarn("begin with offset/serial 0x%x/%d\n", 254 pwarn("begin with offset/serial 0x%x/%d\n",
255 (int)fs->lfs_offset, (int)fs->lfs_serial); 255 (int)fs->lfs_offset, (int)fs->lfs_serial);
256 while (tdaddr < idaddr) { 256 while (tdaddr < idaddr) {
257 bread(fs->lfs_devvp, LFS_FSBTODB(fs, tdaddr), 257 bread(fs->lfs_devvp, LFS_FSBTODB(fs, tdaddr),
258 fs->lfs_sumsize, 258 fs->lfs_sumsize,
259 NULL, 0, &bp); 259 0, &bp);
260 sp = (SEGSUM *)bp->b_data; 260 sp = (SEGSUM *)bp->b_data;
261 if (sp->ss_sumsum != cksum(&sp->ss_datasum, 261 if (sp->ss_sumsum != cksum(&sp->ss_datasum,
262 fs->lfs_sumsize - 262 fs->lfs_sumsize -
263 sizeof(sp->ss_sumsum))) { 263 sizeof(sp->ss_sumsum))) {
264 brelse(bp, 0); 264 brelse(bp, 0);
265 if (debug) 265 if (debug)
266 printf("bad cksum at %x\n", 266 printf("bad cksum at %x\n",
267 (unsigned)tdaddr); 267 (unsigned)tdaddr);
268 break; 268 break;
269 } 269 }
270 fp = (FINFO *)(sp + 1); 270 fp = (FINFO *)(sp + 1);
271 bc = howmany(sp->ss_ninos, LFS_INOPB(fs)) << 271 bc = howmany(sp->ss_ninos, LFS_INOPB(fs)) <<
272 (fs->lfs_version > 1 ? fs->lfs_ffshift : 272 (fs->lfs_version > 1 ? fs->lfs_ffshift :
@@ -401,27 +401,27 @@ setup(const char *dev) @@ -401,27 +401,27 @@ setup(const char *dev)
401 /* 401 /*
402 * Read in the Ifile; we'll be using it a lot. 402 * Read in the Ifile; we'll be using it a lot.
403 * XXX If the Ifile is corrupted we are in bad shape. We need to 403 * XXX If the Ifile is corrupted we are in bad shape. We need to
404 * XXX run through the segment headers of the entire disk to 404 * XXX run through the segment headers of the entire disk to
405 * XXX reconstruct the inode table, then pretend all segments are 405 * XXX reconstruct the inode table, then pretend all segments are
406 * XXX dirty while we do the rest. 406 * XXX dirty while we do the rest.
407 */ 407 */
408 ivp = fs->lfs_ivnode; 408 ivp = fs->lfs_ivnode;
409 maxino = ((VTOI(ivp)->i_ffs1_size - (fs->lfs_cleansz + fs->lfs_segtabsz) 409 maxino = ((VTOI(ivp)->i_ffs1_size - (fs->lfs_cleansz + fs->lfs_segtabsz)
410 * fs->lfs_bsize) / fs->lfs_bsize) * fs->lfs_ifpb; 410 * fs->lfs_bsize) / fs->lfs_bsize) * fs->lfs_ifpb;
411 if (debug) 411 if (debug)
412 pwarn("maxino = %llu\n", (unsigned long long)maxino); 412 pwarn("maxino = %llu\n", (unsigned long long)maxino);
413 for (i = 0; i < VTOI(ivp)->i_ffs1_size; i += fs->lfs_bsize) { 413 for (i = 0; i < VTOI(ivp)->i_ffs1_size; i += fs->lfs_bsize) {
414 bread(ivp, i >> fs->lfs_bshift, fs->lfs_bsize, NOCRED, 0, &bp); 414 bread(ivp, i >> fs->lfs_bshift, fs->lfs_bsize, 0, &bp);
415 /* XXX check B_ERROR */ 415 /* XXX check B_ERROR */
416 brelse(bp, 0); 416 brelse(bp, 0);
417 } 417 }
418 418
419 /* 419 /*
420 * allocate and initialize the necessary maps 420 * allocate and initialize the necessary maps
421 */ 421 */
422 din_table = ecalloc(maxino, sizeof(*din_table)); 422 din_table = ecalloc(maxino, sizeof(*din_table));
423 seg_table = ecalloc(fs->lfs_nseg, sizeof(SEGUSE)); 423 seg_table = ecalloc(fs->lfs_nseg, sizeof(SEGUSE));
424 /* Get segment flags */ 424 /* Get segment flags */
425 for (i = 0; i < fs->lfs_nseg; i++) { 425 for (i = 0; i < fs->lfs_nseg; i++) {
426 LFS_SEGENTRY(sup, fs, i, bp); 426 LFS_SEGENTRY(sup, fs, i, bp);
427 seg_table[i].su_flags = sup->su_flags & ~SEGUSE_ACTIVE; 427 seg_table[i].su_flags = sup->su_flags & ~SEGUSE_ACTIVE;

cvs diff -r1.29 -r1.30 src/sbin/newfs_lfs/make_lfs.c (expand / switch to unified diff)

--- src/sbin/newfs_lfs/make_lfs.c 2013/10/19 01:09:59 1.29
+++ src/sbin/newfs_lfs/make_lfs.c 2015/03/29 19:35:58 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: make_lfs.c,v 1.29 2013/10/19 01:09:59 christos Exp $ */ 1/* $NetBSD: make_lfs.c,v 1.30 2015/03/29 19:35:58 chopps Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Konrad E. Schroder <perseant@hhhh.org>. 8 * by Konrad E. Schroder <perseant@hhhh.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE. 57 * SUCH DAMAGE.
58 */ 58 */
59 59
60#include <sys/cdefs.h> 60#include <sys/cdefs.h>
61#ifndef lint 61#ifndef lint
62#if 0 62#if 0
63static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95"; 63static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
64#else 64#else
65__RCSID("$NetBSD: make_lfs.c,v 1.29 2013/10/19 01:09:59 christos Exp $"); 65__RCSID("$NetBSD: make_lfs.c,v 1.30 2015/03/29 19:35:58 chopps Exp $");
66#endif 66#endif
67#endif /* not lint */ 67#endif /* not lint */
68 68
69#include <sys/param.h> 69#include <sys/param.h>
70#include <sys/disk.h> 70#include <sys/disk.h>
71#include <sys/time.h> 71#include <sys/time.h>
72#include <sys/mount.h> 72#include <sys/mount.h>
73#include <sys/stat.h> 73#include <sys/stat.h>
74 74
75/* Override certain things to make <ufs/lfs/lfs.h> work */ 75/* Override certain things to make <ufs/lfs/lfs.h> work */
76# undef simple_lock 76# undef simple_lock
77# define simple_lock(x) 77# define simple_lock(x)
78# undef simple_unlock 78# undef simple_unlock
@@ -679,47 +679,47 @@ make_lfs(int devfd, uint secsize, struct @@ -679,47 +679,47 @@ make_lfs(int devfd, uint secsize, struct
679 VTOI(vp)->i_lfs_osize = dip->di_size = LFS_DIRBLKSIZ; 679 VTOI(vp)->i_lfs_osize = dip->di_size = LFS_DIRBLKSIZ;
680#ifdef MAKE_LF_DIR 680#ifdef MAKE_LF_DIR
681 VTOI(vp)->i_nlink = dip->di_nlink = 3; 681 VTOI(vp)->i_nlink = dip->di_nlink = 3;
682#else 682#else
683 VTOI(vp)->i_nlink = dip->di_nlink = 2; 683 VTOI(vp)->i_nlink = dip->di_nlink = 2;
684#endif 684#endif
685 VTOI(vp)->i_lfs_effnblks = dip->di_blocks = 685 VTOI(vp)->i_lfs_effnblks = dip->di_blocks =
686 lfs_btofsb(fs, roundup(LFS_DIRBLKSIZ,fs->lfs_fsize)); 686 lfs_btofsb(fs, roundup(LFS_DIRBLKSIZ,fs->lfs_fsize));
687 for (i = 0; i < ULFS_NDADDR && i < howmany(LFS_DIRBLKSIZ, fs->lfs_bsize); i++) 687 for (i = 0; i < ULFS_NDADDR && i < howmany(LFS_DIRBLKSIZ, fs->lfs_bsize); i++)
688 VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize; 688 VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize;
689 if (LFS_DIRBLKSIZ < fs->lfs_bsize) 689 if (LFS_DIRBLKSIZ < fs->lfs_bsize)
690 VTOI(vp)->i_lfs_fragsize[i - 1] = 690 VTOI(vp)->i_lfs_fragsize[i - 1] =
691 roundup(LFS_DIRBLKSIZ,fs->lfs_fsize); 691 roundup(LFS_DIRBLKSIZ,fs->lfs_fsize);
692 bread(vp, 0, fs->lfs_fsize, NOCRED, 0, &bp); 692 bread(vp, 0, fs->lfs_fsize, 0, &bp);
693 make_dir(bp->b_data, lfs_root_dir,  693 make_dir(bp->b_data, lfs_root_dir,
694 sizeof(lfs_root_dir) / sizeof(struct lfs_direct)); 694 sizeof(lfs_root_dir) / sizeof(struct lfs_direct));
695 VOP_BWRITE(bp); 695 VOP_BWRITE(bp);
696 696
697#ifdef MAKE_LF_DIR 697#ifdef MAKE_LF_DIR
698 /* Initialize lost+found directory */ 698 /* Initialize lost+found directory */
699 vp = lfs_raw_vget(fs, LOSTFOUNDINO, devfd, 0x0); 699 vp = lfs_raw_vget(fs, LOSTFOUNDINO, devfd, 0x0);
700 dip = VTOI(vp)->i_din.ffs1_din; 700 dip = VTOI(vp)->i_din.ffs1_din;
701 make_dinode(LOSTFOUNDINO, dip, howmany(DIRBLKSIZ,fs->lfs_fsize), fs); 701 make_dinode(LOSTFOUNDINO, dip, howmany(DIRBLKSIZ,fs->lfs_fsize), fs);
702 dip->di_mode = IFDIR | UMASK; 702 dip->di_mode = IFDIR | UMASK;
703 VTOI(vp)->i_lfs_osize = dip->di_size = DIRBLKSIZ; 703 VTOI(vp)->i_lfs_osize = dip->di_size = DIRBLKSIZ;
704 VTOI(vp)->i_nlink = dip->di_nlink = 2; 704 VTOI(vp)->i_nlink = dip->di_nlink = 2;
705 VTOI(vp)->i_lfs_effnblks = dip->di_blocks = 705 VTOI(vp)->i_lfs_effnblks = dip->di_blocks =
706 lfs_btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize)); 706 lfs_btofsb(fs, roundup(DIRBLKSIZ,fs->lfs_fsize));
707 for (i = 0; i < ULFS_NDADDR && i < howmany(DIRBLKSIZ, fs->lfs_bsize); i++) 707 for (i = 0; i < ULFS_NDADDR && i < howmany(DIRBLKSIZ, fs->lfs_bsize); i++)
708 VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize; 708 VTOI(vp)->i_lfs_fragsize[i] = fs->lfs_bsize;
709 if (DIRBLKSIZ < fs->lfs_bsize) 709 if (DIRBLKSIZ < fs->lfs_bsize)
710 VTOI(vp)->i_lfs_fragsize[i - 1] = 710 VTOI(vp)->i_lfs_fragsize[i - 1] =
711 roundup(DIRBLKSIZ,fs->lfs_fsize); 711 roundup(DIRBLKSIZ,fs->lfs_fsize);
712 bread(vp, 0, fs->lfs_fsize, NOCRED, 0, &bp); 712 bread(vp, 0, fs->lfs_fsize, 0, &bp);
713 make_dir(bp->b_data, lfs_lf_dir,  713 make_dir(bp->b_data, lfs_lf_dir,
714 sizeof(lfs_lf_dir) / sizeof(struct lfs_direct)); 714 sizeof(lfs_lf_dir) / sizeof(struct lfs_direct));
715 VOP_BWRITE(bp); 715 VOP_BWRITE(bp);
716#endif /* MAKE_LF_DIR */ 716#endif /* MAKE_LF_DIR */
717 717
718 /* Set their IFILE entry version numbers to 1 */ 718 /* Set their IFILE entry version numbers to 1 */
719 LFS_IENTRY(ip, fs, 1, bp); 719 LFS_IENTRY(ip, fs, 1, bp);
720 if (version == 1) { 720 if (version == 1) {
721 ip_v1 = (IFILE_V1 *)ip; 721 ip_v1 = (IFILE_V1 *)ip;
722 for (i = LFS_IFILE_INUM; i <= HIGHEST_USED_INO; i++) { 722 for (i = LFS_IFILE_INUM; i <= HIGHEST_USED_INO; i++) {
723 ip_v1->if_version = 1; 723 ip_v1->if_version = 1;
724 ip_v1->if_daddr = 0x0; 724 ip_v1->if_daddr = 0x0;
725 ip_v1->if_nextfree = 0; 725 ip_v1->if_nextfree = 0;