Resolves-Coverity-CID: 1125924
Signed-off-by: Eric Sandeen <sand...@redhat.com>
---
 cmds-filesystem.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index b1291d6..2cb067d 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -661,7 +661,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);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to