summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-01-12 13:35:50 +0100
committerDavid Sterba <dsterba@suse.com>2016-01-12 15:02:55 +0100
commitac4ec4d4f44e67fc3d1fd806cf7acbe2485cedee (patch)
tree434f39155069a914bc76d3e9fdca87a331012b7a /utils.c
parent633dc6f80f201afdf5b8524ae377187d58f0ef3b (diff)
btrfs-progs: check for negative return value from ioctl
Handle only negative values returned by ioctl syscalls, with exception of the device remove. It returns positive values that are handled later. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/utils.c b/utils.c
index 0339894d..74bb066d 100644
--- a/utils.c
+++ b/utils.c
@@ -2077,7 +2077,7 @@ int get_device_info(int fd, u64 devid,
memset(&di_args->uuid, '\0', sizeof(di_args->uuid));
ret = ioctl(fd, BTRFS_IOC_DEV_INFO, di_args);
- return ret ? -errno : 0;
+ return ret < 0 ? -errno : 0;
}
static u64 find_max_device_id(struct btrfs_ioctl_search_args *search_args,
@@ -2700,7 +2700,7 @@ int lookup_ino_rootid(int fd, u64 *rootid)
args.objectid = BTRFS_FIRST_FREE_OBJECTID;
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr, "ERROR: Failed to lookup root id - %s\n",
strerror(errno));
return ret;