summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2013-11-06 17:15:49 -0600
committerChris Mason <chris.mason@fusionio.com>2013-11-07 16:10:41 -0500
commit53e56831b051c36bb229463349c12b407beb2c91 (patch)
treefd51981e34df69fcf7c5cee3cbb2015afe857895 /utils.c
parent09aa5d3601d0bd9fdb02c3a232daba87e36ca093 (diff)
btrfs-progs: Check for open failure in btrfs_scan_lblkid()
open can fail, of course. Resolves-Coverity-CID: 1125925 Resolves-Coverity-CID: 1125930 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/utils.c b/utils.c
index 9f476efd..3c74f690 100644
--- a/utils.c
+++ b/utils.c
@@ -1978,12 +1978,16 @@ int btrfs_scan_lblkid(int update_kernel)
dev = blkid_verify(cache, dev);
if (!dev)
continue;
- /* if we are here its definitly a btrfs disk*/
+ /* if we are here its definitely a btrfs disk*/
strncpy(path, blkid_dev_devname(dev), PATH_MAX);
if (test_skip_this_disk(path))
continue;
fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ printf("ERROR: could not open %s\n", path);
+ continue;
+ }
btrfs_scan_one_device(fd, path, &tmp_devices,
&num_devices, BTRFS_SUPER_INFO_OFFSET);
close(fd);