args.objectid = ri->dir_id;
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
- if (ret) {
+ if (ret < 0) {
if (errno == ENOENT) {
ri->ref_tree = 0;
return -ENOENT;
/* this ioctl fills in ino_args->treeid */
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n",
(unsigned long long)BTRFS_FIRST_FREE_OBJECTID,
strerror(errno));
args.objectid = dirid;
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n",
(unsigned long long)dirid, strerror(errno));
return ERR_PTR(ret);
}
memset(&arg, 0, sizeof(arg));
strncpy_null(arg.name, argv[i]);
+ /*
+ * Positive values are from BTRFS_ERROR_DEV_*,
+ * otherwise it's a generic error, one of errnos
+ */
res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
if (res) {
const char *msg;
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);
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);
sargs->total_spaces = 0;
ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
- if (ret) {
+ if (ret < 0) {
error("cannot get space info: %s\n", strerror(errno));
free(sargs);
return -errno;
sargs->space_slots = count;
sargs->total_spaces = 0;
ret = ioctl(fd, BTRFS_IOC_SPACE_INFO, sargs);
- if (ret) {
+ if (ret < 0) {
error("cannot get space info with %llu slots: %s",
count, strerror(errno));
free(sargs);
ipa.fspath = ptr_to_u64(fspath);
ret = ioctl(fd, BTRFS_IOC_INO_PATHS, &ipa);
- if (ret) {
+ if (ret < 0) {
printf("ioctl ret=%d, error: %s\n", ret, strerror(errno));
goto out;
}
}
ret = ioctl(fd, BTRFS_IOC_LOGICAL_INO, &loi);
- if (ret) {
+ if (ret < 0) {
printf("ioctl ret=%d, error: %s\n", ret, strerror(errno));
goto out;
}
clone_args.src_length = len;
clone_args.dest_offset = offset;
ret = ioctl(r->write_fd, BTRFS_IOC_CLONE_RANGE, &clone_args);
- if (ret) {
+ if (ret < 0) {
ret = -errno;
error("failed to clone extents to %s\n%s\n",
path, strerror(-ret));
status_args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS;
status_args.result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT;
ret = ioctl(fdmnt, BTRFS_IOC_DEV_REPLACE, &status_args);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr,
"ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s",
path, strerror(errno));
start_args.result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT;
ret = ioctl(fdmnt, BTRFS_IOC_DEV_REPLACE, &start_args);
if (do_not_background) {
- if (ret) {
+ if (ret < 0) {
fprintf(stderr,
"ERROR: ioctl(DEV_REPLACE_START) failed on \"%s\": %s",
path, strerror(errno));
args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS;
args.result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT;
ret = ioctl(fd, BTRFS_IOC_DEV_REPLACE, &args);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_STATUS) failed on \"%s\": %s",
path, strerror(errno));
if (args.result != BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT)
ret = ioctl(fd, BTRFS_IOC_DEV_REPLACE, &args);
e = errno;
close_file_or_dir(fd, dirstream);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr, "ERROR: ioctl(DEV_REPLACE_CANCEL) failed on \"%s\": %s",
path, strerror(e));
if (args.result != BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_RESULT)
if (!is_last_subvol)
io_send.flags |= BTRFS_SEND_FLAG_OMIT_END_CMD;
ret = ioctl(subvol_fd, BTRFS_IOC_SEND, &io_send);
- if (ret) {
+ if (ret < 0) {
ret = -errno;
error("send ioctl failed with %d: %s", ret, strerror(-ret));
if (ret == -EINVAL && (!is_first_subvol || !is_last_subvol))
io_send.flags = BTRFS_SEND_FLAG_NO_FILE_DATA;
ret = ioctl(subvol_fd, BTRFS_IOC_SEND, &io_send);
- if (ret) {
+ if (ret < 0) {
ret = errno;
fprintf(stderr, "ERROR: send ioctl failed with %d: %s\n", ret,
strerror(ret));
search_arg.key.max_transid = (u64)-1;
search_arg.key.nr_items = 1;
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &search_arg);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr,
"ioctl(BTRFS_IOC_TREE_SEARCH, subvol_id %llu) ret=%d, error: %s\n",
(unsigned long long)subvol_id, ret, strerror(errno));
ino_lookup_arg.objectid =
btrfs_stack_root_ref_dirid(backref_item);
ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_lookup_arg);
- if (ret) {
+ if (ret < 0) {
fprintf(stderr,
"ioctl(BTRFS_IOC_INO_LOOKUP) ret=%d, error: %s\n",
ret, strerror(errno));
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,
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;