aboutsummaryrefslogtreecommitdiffstats
path: root/disk-io.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-03-18 16:07:09 +0100
committerDavid Sterba <dsterba@suse.com>2016-03-18 16:38:14 +0100
commitc921544bba7c49f0e7ea882bbff301a0d82e4f70 (patch)
tree8ea5ddf289b96a4ed4465322301d459cfaf4ac16 /disk-io.c
parent3519f83574c29a49e7e3e493f1bf4bb8dd5b0e33 (diff)
downloadbtrfs-progs-c921544bba7c49f0e7ea882bbff301a0d82e4f70.tar.gz
btrfs-progs-c921544bba7c49f0e7ea882bbff301a0d82e4f70.tar.xz
btrfs-progs-c921544bba7c49f0e7ea882bbff301a0d82e4f70.zip
btrfs-progs: handle stat errors in open_ctree_fs_info
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/disk-io.c b/disk-io.c
index 6b47977..c46f366 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1323,11 +1323,16 @@ struct btrfs_fs_info *open_ctree_fs_info(const char *filename,
enum btrfs_open_ctree_flags flags)
{
int fp;
+ int ret;
struct btrfs_fs_info *info;
int oflags = O_CREAT | O_RDWR;
struct stat st;
- stat(filename, &st);
+ ret = stat(filename, &st);
+ if (ret < 0) {
+ error("cannot stat '%s': %s", filename, strerror(errno));
+ return NULL;
+ }
if (!(((st.st_mode & S_IFMT) == S_IFREG) || ((st.st_mode & S_IFMT) == S_IFBLK))) {
fprintf (stderr, "%s is not a regular file or block device\n", filename);
return NULL;