1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 21:35:45 +02:00

fs: update btrfs compatibility header: add csum types, BTRFS_FS_INFO_FLAG_GENERATION and _METADATA_UUID

I guess this means it's "args_v3" now?

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2022-10-24 11:48:35 -04:00
parent 07a4c9e8c0
commit 5953ea6d3c
3 changed files with 41 additions and 8 deletions

View File

@ -216,7 +216,28 @@ enum btrfs_compression_type {
#define BTRFS_FS_INFO_FLAG_CSUM_INFO (1 << 0) #define BTRFS_FS_INFO_FLAG_CSUM_INFO (1 << 0)
#endif #endif
struct btrfs_ioctl_fs_info_args_v2 { #ifndef BTRFS_FS_INFO_FLAG_GENERATION
/* Request information about filesystem generation */
#define BTRFS_FS_INFO_FLAG_GENERATION (1 << 1)
#endif
#ifndef BTRFS_FS_INFO_FLAG_METADATA_UUID
/* Request information about filesystem metadata UUID */
#define BTRFS_FS_INFO_FLAG_METADATA_UUID (1 << 2)
#endif
// BTRFS_CSUM_TYPE_CRC32 was a #define from 2008 to 2019.
// After that, it's an enum with the other 3 types.
// So if we do _not_ have CRC32 defined, it means we have the other 3;
// if we _do_ have CRC32 defined, it means we need the other 3.
// This seems likely to break some day.
#ifdef BTRFS_CSUM_TYPE_CRC32
#define BTRFS_CSUM_TYPE_XXHASH 1
#define BTRFS_CSUM_TYPE_SHA256 2
#define BTRFS_CSUM_TYPE_BLAKE2 3
#endif
struct btrfs_ioctl_fs_info_args_v3 {
__u64 max_id; /* out */ __u64 max_id; /* out */
__u64 num_devices; /* out */ __u64 num_devices; /* out */
__u8 fsid[BTRFS_FSID_SIZE]; /* out */ __u8 fsid[BTRFS_FSID_SIZE]; /* out */
@ -227,7 +248,9 @@ struct btrfs_ioctl_fs_info_args_v2 {
__u16 csum_type; /* out */ __u16 csum_type; /* out */
__u16 csum_size; /* out */ __u16 csum_size; /* out */
__u64 flags; /* in/out */ __u64 flags; /* in/out */
__u8 reserved[968]; /* pad to 1k */ __u64 generation; /* out */
__u8 metadata_uuid[BTRFS_FSID_SIZE]; /* out */
__u8 reserved[944]; /* pad to 1k */
}; };
#endif // CRUCIBLE_BTRFS_H #endif // CRUCIBLE_BTRFS_H

View File

@ -248,11 +248,12 @@ namespace crucible {
template<class V> ostream &hexdump(ostream &os, const V &v); template<class V> ostream &hexdump(ostream &os, const V &v);
struct BtrfsIoctlFsInfoArgs : public btrfs_ioctl_fs_info_args_v2 { struct BtrfsIoctlFsInfoArgs : public btrfs_ioctl_fs_info_args_v3 {
BtrfsIoctlFsInfoArgs(); BtrfsIoctlFsInfoArgs();
void do_ioctl(int fd); void do_ioctl(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;
}; };
ostream & operator<<(ostream &os, const BtrfsIoctlFsInfoArgs &a); ostream & operator<<(ostream &os, const BtrfsIoctlFsInfoArgs &a);

View File

@ -1136,8 +1136,11 @@ namespace crucible {
}; };
BtrfsIoctlFsInfoArgs::BtrfsIoctlFsInfoArgs() : BtrfsIoctlFsInfoArgs::BtrfsIoctlFsInfoArgs() :
btrfs_ioctl_fs_info_args_v2( (btrfs_ioctl_fs_info_args_v2) { btrfs_ioctl_fs_info_args_v3( (btrfs_ioctl_fs_info_args_v3) {
.flags = BTRFS_FS_INFO_FLAG_CSUM_INFO, .flags = 0
| BTRFS_FS_INFO_FLAG_CSUM_INFO
| BTRFS_FS_INFO_FLAG_GENERATION
,
}) })
{ {
} }
@ -1145,7 +1148,7 @@ namespace crucible {
void void
BtrfsIoctlFsInfoArgs::do_ioctl(int fd) BtrfsIoctlFsInfoArgs::do_ioctl(int fd)
{ {
btrfs_ioctl_fs_info_args_v2 *p = static_cast<btrfs_ioctl_fs_info_args_v2 *>(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)) { if (ioctl(fd, BTRFS_IOC_FS_INFO, p)) {
THROW_ERRNO("BTRFS_IOC_FS_INFO: fd " << fd); THROW_ERRNO("BTRFS_IOC_FS_INFO: fd " << fd);
} }
@ -1154,13 +1157,19 @@ namespace crucible {
uint16_t uint16_t
BtrfsIoctlFsInfoArgs::csum_type() const BtrfsIoctlFsInfoArgs::csum_type() const
{ {
return this->btrfs_ioctl_fs_info_args_v2::csum_type; return this->btrfs_ioctl_fs_info_args_v3::csum_type;
} }
uint16_t uint16_t
BtrfsIoctlFsInfoArgs::csum_size() const BtrfsIoctlFsInfoArgs::csum_size() const
{ {
return this->btrfs_ioctl_fs_info_args_v2::csum_size; return this->btrfs_ioctl_fs_info_args_v3::csum_size;
}
uint64_t
BtrfsIoctlFsInfoArgs::generation() const
{
return this->btrfs_ioctl_fs_info_args_v3::generation;
} }
}; };