summaryrefslogtreecommitdiff
path: root/sbin/fsck_ext2fs/pass1.c
diff options
context:
space:
mode:
authorNiall O'Higgins <niallo@cvs.openbsd.org>2005-04-30 13:56:17 +0000
committerNiall O'Higgins <niallo@cvs.openbsd.org>2005-04-30 13:56:17 +0000
commite723898372517d7a195b4eb18912751f9316ae2e (patch)
tree4a6149adbaa52b0539597497fd19f2cfd9cf066e /sbin/fsck_ext2fs/pass1.c
parent8153e99f0a02eb7725ff3061033d08113ee83991 (diff)
Support checking filesystems which have or once had large files (>4 GB)
on them. From NetBSD
Diffstat (limited to 'sbin/fsck_ext2fs/pass1.c')
-rw-r--r--sbin/fsck_ext2fs/pass1.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/sbin/fsck_ext2fs/pass1.c b/sbin/fsck_ext2fs/pass1.c
index 15805efc916..e32a79030eb 100644
--- a/sbin/fsck_ext2fs/pass1.c
+++ b/sbin/fsck_ext2fs/pass1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1.c,v 1.10 2003/06/11 06:22:13 deraadt Exp $ */
+/* $OpenBSD: pass1.c,v 1.11 2005/04/30 13:56:16 niallo Exp $ */
/* $NetBSD: pass1.c,v 1.9 2000/01/31 11:40:12 bouyer Exp $ */
/*
@@ -135,7 +135,7 @@ checkinode(ino_t inumber, struct inodesc *idesc)
if (mode == 0 && (
memcmp(dp->e2di_blocks, zino.e2di_blocks,
(NDADDR + NIADDR) * sizeof(u_int32_t)) ||
- dp->e2di_mode || dp->e2di_size)) {
+ dp->e2di_mode || inosize(dp))) {
pfatal("PARTIALLY ALLOCATED INODE I=%u", inumber);
if (reply("CLEAR") == 1) {
dp = ginode(inumber);
@@ -175,24 +175,22 @@ checkinode(ino_t inumber, struct inodesc *idesc)
inodirty();
}
}
- if (/* dp->di_size < 0 || */
- fs2h32(dp->e2di_size) + sblock.e2fs_bsize - 1 <
- fs2h32(dp->e2di_size)) {
+ if (inosize(dp) + sblock.e2fs_bsize - 1 < inosize(dp)) {
if (debug)
- printf("bad size %lu:", (u_long)fs2h32(dp->e2di_size));
+ printf("bad size %llu:", (unsigned long long)inosize(dp));
goto unknown;
}
if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) {
dp = ginode(inumber);
- dp->e2di_size = h2fs32(sblock.e2fs_bsize);
dp->e2di_mode = h2fs16(IFREG|0600);
+ inossize(dp, sblock.e2fs_bsize);
inodirty();
}
- ndb = howmany(fs2h32(dp->e2di_size), sblock.e2fs_bsize);
+ ndb = howmany(inosize(dp), sblock.e2fs_bsize);
if (ndb < 0) {
if (debug)
- printf("bad size %lu ndb %d:",
- (u_long)fs2h32(dp->e2di_size), ndb);
+ printf("bad size %llu ndb %d:",
+ (unsigned long long)inosize(dp), ndb);
goto unknown;
}
if (mode == IFBLK || mode == IFCHR)
@@ -202,9 +200,9 @@ checkinode(ino_t inumber, struct inodesc *idesc)
* Fake ndb value so direct/indirect block checks below
* will detect any garbage after symlink string.
*/
- if (fs2h32(dp->e2di_size) < EXT2_MAXSYMLINKLEN ||
+ if (inosize(dp) < EXT2_MAXSYMLINKLEN ||
(EXT2_MAXSYMLINKLEN == 0 && dp->e2di_blocks == 0)) {
- ndb = howmany(fs2h32(dp->e2di_size), sizeof(u_int32_t));
+ ndb = howmany(inosize(dp), sizeof(u_int32_t));
if (ndb > NDADDR) {
j = ndb - NDADDR;
for (ndb = 1; j > 1; j--)
@@ -250,7 +248,7 @@ checkinode(ino_t inumber, struct inodesc *idesc)
}
}
if (mode == IFDIR) {
- if (dp->e2di_size == 0)
+ if (inosize(dp) == 0)
statemap[inumber] = DCLEAR;
else
statemap[inumber] = DSTATE;