diff --git a/include/crucible/fs.h b/include/crucible/fs.h index 6f95551..3561681 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -246,9 +246,11 @@ namespace crucible { struct BtrfsIoctlFsInfoArgs : public btrfs_ioctl_fs_info_args_v3 { BtrfsIoctlFsInfoArgs(); void do_ioctl(int fd); + bool do_ioctl_nothrow(int fd); uint16_t csum_type() const; uint16_t csum_size() const; uint64_t generation() const; + vector fsid() const; }; ostream & operator<<(ostream &os, const BtrfsIoctlFsInfoArgs &a); diff --git a/lib/fs.cc b/lib/fs.cc index 3366d14..8c8226c 100644 --- a/lib/fs.cc +++ b/lib/fs.cc @@ -1138,11 +1138,17 @@ namespace crucible { { } - void - BtrfsIoctlFsInfoArgs::do_ioctl(int fd) + bool + BtrfsIoctlFsInfoArgs::do_ioctl_nothrow(int const fd) { btrfs_ioctl_fs_info_args_v3 *p = static_cast(this); - if (ioctl(fd, BTRFS_IOC_FS_INFO, p)) { + return 0 == ioctl(fd, BTRFS_IOC_FS_INFO, p); + } + + void + BtrfsIoctlFsInfoArgs::do_ioctl(int const fd) + { + if (!do_ioctl_nothrow(fd)) { THROW_ERRNO("BTRFS_IOC_FS_INFO: fd " << fd); } } @@ -1159,6 +1165,13 @@ namespace crucible { return this->btrfs_ioctl_fs_info_args_v3::csum_size; } + vector + BtrfsIoctlFsInfoArgs::fsid() const + { + const auto begin = btrfs_ioctl_fs_info_args_v3::fsid; + return vector(begin, begin + BTRFS_FSID_SIZE); + } + uint64_t BtrfsIoctlFsInfoArgs::generation() const {