Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Mar 2019 21:30:02 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344732 - head/sbin/fsck_ffs
Message-ID:  <201903022130.x22LU2Ow033434@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Sat Mar  2 21:30:01 2019
New Revision: 344732
URL: https://svnweb.freebsd.org/changeset/base/344732

Log:
  Properly calculate the last used logical block of a file when checking
  inodes that reference directories. While here tighten the check for
  comparing the last logical block with the end of the file.
  
  Reported by:  Peter Holm
  Tested by:    Peter Holm
  Sponsored by: Netflix

Modified:
  head/sbin/fsck_ffs/inode.c
  head/sbin/fsck_ffs/pass1.c

Modified: head/sbin/fsck_ffs/inode.c
==============================================================================
--- head/sbin/fsck_ffs/inode.c	Sat Mar  2 21:22:56 2019	(r344731)
+++ head/sbin/fsck_ffs/inode.c	Sat Mar  2 21:30:01 2019	(r344732)
@@ -127,9 +127,9 @@ ckinode(union dinode *dp, struct inodesc *idesc)
 			ret = iblock(idesc, i + 1, remsize, BT_LEVEL1 + i);
 			if (ret & STOP)
 				return (ret);
-		} else {
+		} else if (remsize > 0) {
 			idesc->id_lbn += sizepb / sblock.fs_bsize;
-			if (idesc->id_type == DATA && remsize > 0) {
+			if (idesc->id_type == DATA) {
 				/* An empty block in a directory XXX */
 				getpathname(pathbuf, idesc->id_number,
 						idesc->id_number);

Modified: head/sbin/fsck_ffs/pass1.c
==============================================================================
--- head/sbin/fsck_ffs/pass1.c	Sat Mar  2 21:22:56 2019	(r344731)
+++ head/sbin/fsck_ffs/pass1.c	Sat Mar  2 21:30:01 2019	(r344732)
@@ -439,7 +439,7 @@ checkinode(ino_t inumber, struct inodesc *idesc, int r
 	 * at its end.
 	 */
 	if (DIP(dp, di_size) > UFS_NDADDR * sblock.fs_bsize &&
-	    idesc->id_lballoc != lblkno(&sblock, DIP(dp, di_size) - 1)) {
+	    idesc->id_lballoc < lblkno(&sblock, DIP(dp, di_size) - 1)) {
 		fixsize = lblktosize(&sblock, idesc->id_lballoc + 1);
 		pwarn("INODE %lu: FILE SIZE %ju BEYOND END OF ALLOCATED FILE, "
 		      "SIZE SHOULD BE %ju", (u_long)inumber,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903022130.x22LU2Ow033434>