[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150514002134.10785.61003.stgit@birch.djwong.org>
Date: Wed, 13 May 2015 17:21:34 -0700
From: "Darrick J. Wong" <darrick.wong@...cle.com>
To: tytso@....edu, darrick.wong@...cle.com
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 04/14] filefrag: fix broken extent emulation and
uninitialized variables
This started with the fm_ext being uninitialized, but upon closer
analysis I discovered that forcing extent emulation in FIBMAP mode
was reporting an extent for every block in the file. Fix both
problems.
The Coverity bug was 1297512.
Signed-off-by: Darrick J. Wong <darrick.wong@...cle.com>
---
misc/filefrag.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/misc/filefrag.c b/misc/filefrag.c
index c1a8684..3b104c6 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -287,8 +287,8 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
const long bpib = st->st_blksize / 4;
int count;
+ memset(&fm_ext, 0, sizeof(fm_ext));
if (force_extent) {
- memset(&fm_ext, 0, sizeof(fm_ext));
fm_ext.fe_flags = FIEMAP_EXTENT_MERGED;
}
@@ -331,15 +331,17 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
blk_shift, st);
fm_ext.fe_length = 0;
(*num_extents)++;
+ fm_ext.fe_logical = logical;
+ fm_ext.fe_physical = block * st->st_blksize;
} else if (last_block && (block != last_block + 1)) {
if (verbose)
printf("Discontinuity: Block %ld is at %lu (was "
"%lu)\n", i, block, last_block + 1);
fm_ext.fe_length = 0;
(*num_extents)++;
+ fm_ext.fe_logical = logical;
+ fm_ext.fe_physical = block * st->st_blksize;
}
- fm_ext.fe_logical = logical;
- fm_ext.fe_physical = block * st->st_blksize;
fm_ext.fe_length += st->st_blksize;
last_block = block;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists