is_subvolume_read_only(int fd)
{
__u64 flags;
- if (ioctl(fd, BTRFS_IOC_SUBVOL_GETFLAGS, &flags) != 0)
+ if (ioctl(fd, BTRFS_IOC_SUBVOL_GETFLAGS, &flags) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_SUBVOL_GETFLAGS) failed", errno);
return flags & BTRFS_SUBVOL_RDONLY;
strncpy(args.name, name.c_str(), sizeof(args.name) - 1);
- if (ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args) != 0)
+ if (ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_SUBVOL_CREATE) failed", errno);
}
args.fd = fd;
strncpy(args.name, name.c_str(), sizeof(args.name) - 1);
- if (ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args) != 0)
+ if (ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_SNAP_CREATE) failed", errno);
}
strncpy(args.name, name.c_str(), sizeof(args.name) - 1);
- if (ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_SNAP_DESTROY) failed", errno);
}
void
set_default_id(int fd, subvolid_t id)
{
- if (ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &id) != 0)
+ if (ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &id) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_DEFAULT_SUBVOL) failed", errno);
}
sk->max_offset = (__u64) -1;
sk->max_transid = (__u64) -1;
- if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_TREE_SEARCH) failed", errno);
if (sk->nr_items == 0)
args.treeid = 0;
args.objectid = BTRFS_FIRST_FREE_OBJECTID;
- if (ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_INO_LOOKUP) failed", errno);
return args.treeid;
sk->max_transid = (u64) -1;
sk->nr_items = 1;
- if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_TREE_SEARCH) failed", errno);
return sk->nr_items == 0;
memset(&args, 0, sizeof(args));
args.cmd = BTRFS_QUOTA_CTL_ENABLE;
- if (ioctl(fd, BTRFS_IOC_QUOTA_CTL, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QUOTA_CTL, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_CTL) failed", errno);
}
memset(&args, 0, sizeof(args));
args.cmd = BTRFS_QUOTA_CTL_DISABLE;
- if (ioctl(fd, BTRFS_IOC_QUOTA_CTL, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QUOTA_CTL, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_CTL) failed", errno);
}
struct btrfs_ioctl_quota_rescan_args args;
memset(&args, 0, sizeof(args));
- if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_RESCAN) failed", errno);
while (true)
memset(&args, 0, sizeof(args));
- if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN_STATUS, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QUOTA_RESCAN_STATUS, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QUOTA_RESCAN_STATUS) failed", errno);
if (!args.flags)
args.create = 1;
args.qgroupid = qgroup;
- if (ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QGROUP_CREATE) failed", errno);
}
args.create = 0;
args.qgroupid = qgroup;
- if (ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QGROUP_CREATE) failed", errno);
}
args.src = src;
args.dst = dst;
- if (ioctl(fd, BTRFS_IOC_QGROUP_ASSIGN, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QGROUP_ASSIGN, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QGROUP_ASSIGN) failed", errno);
}
args.src = src;
args.dst = dst;
- if (ioctl(fd, BTRFS_IOC_QGROUP_ASSIGN, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_QGROUP_ASSIGN, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_QGROUP_ASSIGN) failed", errno);
}
while (true)
{
- if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) != 0)
+ if (ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_TREE_SEARCH) failed", errno);
if (sk->nr_items == 0)
void
sync(int fd)
{
- if (ioctl(fd, BTRFS_IOC_SYNC) != 0)
+ if (ioctl(fd, BTRFS_IOC_SYNC) < 0)
throw runtime_error_with_errno("ioctl(BTRFS_IOC_SYNC) failed", errno);
}