Now we check if the root item contains otime and uuid or not by comparing ->generation_v2 and ->generation of the btrfs_root_item structure, it is wrong because it is possbile that ->generation may equal to the first variant of the next item. We fix this problem by comparing the size of btrfs_root_item because the size is different between the old and new ones. we needn't worry the case that the new filesystem is mounted on the old kernel. because the otime and uuid are not changed on the old kernel, we can get the correct result even on the kernel.
Signed-off-by: Miao Xie <mi...@cn.fujitsu.com> --- Changelog v1 -> v3: - new patch --- btrfs-list.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/btrfs-list.c b/btrfs-list.c index ef621f0..2101695 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -737,7 +737,7 @@ again: } 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)) { t = ri->otime.sec; memcpy(uuid, ri->uuid, BTRFS_UUID_SIZE); } else { @@ -844,7 +844,7 @@ static int __list_snapshot_search(int fd, struct root_lookup *root_lookup) 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)) { t = item->otime.sec; memcpy(uuid, item->uuid, BTRFS_UUID_SIZE); } else { -- 1.7.6.5 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html