mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
fs: add do_ioctl_nothrow and fsid methods to btrfs fs info
Enable use of the ioctl to probe whether two fds refer to the same btrfs, without throwing an exception. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
561e604edc
commit
925b12823e
@ -246,9 +246,11 @@ namespace crucible {
|
|||||||
struct BtrfsIoctlFsInfoArgs : public btrfs_ioctl_fs_info_args_v3 {
|
struct BtrfsIoctlFsInfoArgs : public btrfs_ioctl_fs_info_args_v3 {
|
||||||
BtrfsIoctlFsInfoArgs();
|
BtrfsIoctlFsInfoArgs();
|
||||||
void do_ioctl(int fd);
|
void do_ioctl(int fd);
|
||||||
|
bool do_ioctl_nothrow(int fd);
|
||||||
uint16_t csum_type() const;
|
uint16_t csum_type() const;
|
||||||
uint16_t csum_size() const;
|
uint16_t csum_size() const;
|
||||||
uint64_t generation() const;
|
uint64_t generation() const;
|
||||||
|
vector<uint8_t> fsid() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
ostream & operator<<(ostream &os, const BtrfsIoctlFsInfoArgs &a);
|
ostream & operator<<(ostream &os, const BtrfsIoctlFsInfoArgs &a);
|
||||||
|
19
lib/fs.cc
19
lib/fs.cc
@ -1138,11 +1138,17 @@ namespace crucible {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
BtrfsIoctlFsInfoArgs::do_ioctl(int fd)
|
BtrfsIoctlFsInfoArgs::do_ioctl_nothrow(int const fd)
|
||||||
{
|
{
|
||||||
btrfs_ioctl_fs_info_args_v3 *p = static_cast<btrfs_ioctl_fs_info_args_v3 *>(this);
|
btrfs_ioctl_fs_info_args_v3 *p = static_cast<btrfs_ioctl_fs_info_args_v3 *>(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);
|
THROW_ERRNO("BTRFS_IOC_FS_INFO: fd " << fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1159,6 +1165,13 @@ namespace crucible {
|
|||||||
return this->btrfs_ioctl_fs_info_args_v3::csum_size;
|
return this->btrfs_ioctl_fs_info_args_v3::csum_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<uint8_t>
|
||||||
|
BtrfsIoctlFsInfoArgs::fsid() const
|
||||||
|
{
|
||||||
|
const auto begin = btrfs_ioctl_fs_info_args_v3::fsid;
|
||||||
|
return vector<uint8_t>(begin, begin + BTRFS_FSID_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
BtrfsIoctlFsInfoArgs::generation() const
|
BtrfsIoctlFsInfoArgs::generation() const
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user