summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2013-11-06 17:15:53 -0600
committerChris Mason <chris.mason@fusionio.com>2013-11-07 16:10:41 -0500
commitb68477aee114470bde87d655ef647f8475b18003 (patch)
treed760a39edf9415798b4a020abeb08e0253a127f4
parente11712a146c8a16c697a60ead980a9da68eaaddf (diff)
btrfs-progs: check for fstat failure in cmd_defrag
Resolves-Coverity-CID: 1125924 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--cmds-filesystem.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index b4727c27..aa361d67 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -681,7 +681,13 @@ static int cmd_defrag(int argc, char **argv)
if (recursive) {
struct stat st;
- fstat(fd, &st);
+ if (fstat(fd, &st)) {
+ fprintf(stderr, "ERROR: failed to stat %s - %s\n",
+ argv[i], strerror(errno));
+ defrag_global_errors++;
+ close_file_or_dir(fd, dirstream);
+ continue;
+ }
if (S_ISDIR(st.st_mode)) {
ret = nftw(argv[i], defrag_callback, 10,
FTW_MOUNT | FTW_PHYS);