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>
This commit is contained in:
Eric Sandeen 2013-11-06 17:15:53 -06:00 committed by Chris Mason
parent e11712a146
commit b68477aee1
1 changed files with 7 additions and 1 deletions

View File

@ -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);