} else if (get_gen && sh->type == BTRFS_ROOT_ITEM_KEY) {
ri = (struct btrfs_root_item *)(args.buf + off);
gen = btrfs_root_generation(ri);
- if(ri->generation == ri->generation_v2) {
+ if(sh->len >
+ sizeof(struct btrfs_root_item_v0)) {
t = ri->otime.sec;
memcpy(uuid, ri->uuid, BTRFS_UUID_SIZE);
} else {
off += sizeof(*sh);
if (sh->type == BTRFS_ROOT_ITEM_KEY && sh->offset) {
item = (struct btrfs_root_item *)(args.buf + off);
- if(item->generation == item->generation_v2) {
+ if(sh->len >
+ sizeof(struct btrfs_root_item_v0)) {
t = item->otime.sec;
- memcpy(uuid, item->uuid, BTRFS_UUID_SIZE);
+ memcpy(uuid, item->uuid,
+ BTRFS_UUID_SIZE);
} else {
t = 0;
memset(uuid, 0, BTRFS_UUID_SIZE);
u8 type;
} __attribute__ ((__packed__));
+struct btrfs_root_item_v0 {
+ struct btrfs_inode_item inode;
+ __le64 generation;
+ __le64 root_dirid;
+ __le64 bytenr;
+ __le64 byte_limit;
+ __le64 bytes_used;
+ __le64 last_snapshot;
+ __le64 flags;
+ __le32 refs;
+ struct btrfs_disk_key drop_progress;
+ u8 drop_level;
+ u8 level;
+} __attribute__ ((__packed__));
+
struct btrfs_root_item {
struct btrfs_inode_item inode;
__le64 generation;