Tue Feb 13 11:20:08 2018 UTC ()
Treat an inode with "mode == 0" and "blocks != 0" as partially allocated
and clear it as ffs_newvnode() tests for "blocks == 0".


(hannken)
diff -r1.57 -r1.58 src/sbin/fsck_ffs/pass1.c

cvs diff -r1.57 -r1.58 src/sbin/fsck_ffs/pass1.c (expand / switch to unified diff)

--- src/sbin/fsck_ffs/pass1.c 2017/02/08 16:11:40 1.57
+++ src/sbin/fsck_ffs/pass1.c 2018/02/13 11:20:08 1.58
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pass1.c,v 1.57 2017/02/08 16:11:40 rin Exp $ */ 1/* $NetBSD: pass1.c,v 1.58 2018/02/13 11:20:08 hannken 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.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34#if 0 34#if 0
35static char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95"; 35static char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
36#else 36#else
37__RCSID("$NetBSD: pass1.c,v 1.57 2017/02/08 16:11:40 rin Exp $"); 37__RCSID("$NetBSD: pass1.c,v 1.58 2018/02/13 11:20:08 hannken Exp $");
38#endif 38#endif
39#endif /* not lint */ 39#endif /* not lint */
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/stat.h> 42#include <sys/stat.h>
43#include <sys/time.h> 43#include <sys/time.h>
44 44
45#include <ufs/ufs/dinode.h> 45#include <ufs/ufs/dinode.h>
46#include <ufs/ufs/dir.h> 46#include <ufs/ufs/dir.h>
47#include <ufs/ffs/fs.h> 47#include <ufs/ffs/fs.h>
48#include <ufs/ufs/ufs_bswap.h> 48#include <ufs/ufs/ufs_bswap.h>
49#include <ufs/ffs/ffs_extern.h> 49#include <ufs/ffs/ffs_extern.h>
50 50
@@ -243,28 +243,29 @@ checkinode(ino_t inumber, struct inodesc @@ -243,28 +243,29 @@ checkinode(ino_t inumber, struct inodesc
243 mode = iswap16(DIP(dp, mode)) & IFMT; 243 mode = iswap16(DIP(dp, mode)) & IFMT;
244 size = iswap64(DIP(dp, size)); 244 size = iswap64(DIP(dp, size));
245 if (mode == 0) { 245 if (mode == 0) {
246 if ((is_ufs2 &&  246 if ((is_ufs2 &&
247 (memcmp(dp->dp2.di_db, ufs2_zino.di_db, 247 (memcmp(dp->dp2.di_db, ufs2_zino.di_db,
248 UFS_NDADDR * sizeof(int64_t)) || 248 UFS_NDADDR * sizeof(int64_t)) ||
249 memcmp(dp->dp2.di_ib, ufs2_zino.di_ib, 249 memcmp(dp->dp2.di_ib, ufs2_zino.di_ib,
250 UFS_NIADDR * sizeof(int64_t)))) 250 UFS_NIADDR * sizeof(int64_t))))
251 || 251 ||
252 (!is_ufs2 &&  252 (!is_ufs2 &&
253 (memcmp(dp->dp1.di_db, ufs1_zino.di_db, 253 (memcmp(dp->dp1.di_db, ufs1_zino.di_db,
254 UFS_NDADDR * sizeof(int32_t)) || 254 UFS_NDADDR * sizeof(int32_t)) ||
255 memcmp(dp->dp1.di_ib, ufs1_zino.di_ib, 255 memcmp(dp->dp1.di_ib, ufs1_zino.di_ib,
256 UFS_NIADDR * sizeof(int32_t)))) || 256 UFS_NIADDR * sizeof(int32_t))))
257 mode || size) { 257 ||
 258 mode || size || DIP(dp, blocks)) {
258 pfatal("PARTIALLY ALLOCATED INODE I=%llu", 259 pfatal("PARTIALLY ALLOCATED INODE I=%llu",
259 (unsigned long long)inumber); 260 (unsigned long long)inumber);
260 if (reply("CLEAR") == 1) { 261 if (reply("CLEAR") == 1) {
261 dp = ginode(inumber); 262 dp = ginode(inumber);
262 clearinode(dp); 263 clearinode(dp);
263 inodirty(); 264 inodirty();
264 } else 265 } else
265 markclean = 0; 266 markclean = 0;
266 } 267 }
267 info->ino_state = USTATE; 268 info->ino_state = USTATE;
268 return; 269 return;
269 } 270 }
270 lastino = inumber; 271 lastino = inumber;