summaryrefslogtreecommitdiff
path: root/futility/cmd_dump_fmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'futility/cmd_dump_fmap.c')
-rw-r--r--futility/cmd_dump_fmap.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/futility/cmd_dump_fmap.c b/futility/cmd_dump_fmap.c
index 89b702bd..1c5b070c 100644
--- a/futility/cmd_dump_fmap.c
+++ b/futility/cmd_dump_fmap.c
@@ -473,16 +473,17 @@ static int do_dump_fmap(int argc, char *argv[])
return 1;
}
- if (0 != stat(argv[optind], &sb)) {
- fprintf(stderr, "%s: can't stat %s: %s\n",
+ fd = open(argv[optind], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "%s: can't open %s: %s\n",
argv[0], argv[optind], strerror(errno));
return 1;
}
- fd = open(argv[optind], O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "%s: can't open %s: %s\n",
+ if (0 != fstat(fd, &sb)) {
+ fprintf(stderr, "%s: can't stat %s: %s\n",
argv[0], argv[optind], strerror(errno));
+ close(fd);
return 1;
}