From ac4ec4d4f44e67fc3d1fd806cf7acbe2485cedee Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 12 Jan 2016 13:35:50 +0100 Subject: 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 --- cmds-fi-usage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmds-fi-usage.c') diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c index 356ed04..c91c2ca 100644 --- a/cmds-fi-usage.c +++ b/cmds-fi-usage.c @@ -240,7 +240,7 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path) sargs->total_spaces = 0; ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs); - if (ret) { + if (ret < 0) { error("cannot get space info on '%s': %s", path, strerror(errno)); free(sargs); @@ -266,7 +266,7 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path) sargs->total_spaces = 0; ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs); - if (ret) { + if (ret < 0) { error("cannot get space info with %u slots: %s", count, strerror(errno)); free(sargs); -- cgit v1.2.1