u32 itemoff;
int ret = 0;
int blk;
+ u8 uuid[BTRFS_UUID_SIZE];
memset(buf->data + sizeof(struct btrfs_header), 0,
cfg->nodesize - sizeof(struct btrfs_header));
btrfs_set_item_offset(buf, btrfs_item_nr(nritems), itemoff);
btrfs_set_item_size(buf, btrfs_item_nr(nritems),
sizeof(root_item));
+ if (blk == MKFS_FS_TREE) {
+ time_t now = time(NULL);
+
+ uuid_generate(uuid);
+ memcpy(root_item.uuid, uuid, BTRFS_UUID_SIZE);
+ btrfs_set_stack_timespec_sec(&root_item.otime, now);
+ btrfs_set_stack_timespec_sec(&root_item.ctime, now);
+ } else {
+ memset(uuid, 0, BTRFS_UUID_SIZE);
+ memcpy(root_item.uuid, uuid, BTRFS_UUID_SIZE);
+ btrfs_set_stack_timespec_sec(&root_item.otime, 0);
+ btrfs_set_stack_timespec_sec(&root_item.ctime, 0);
+ }
write_extent_buffer(buf, &root_item,
btrfs_item_ptr_offset(buf, nritems),
sizeof(root_item));
struct btrfs_key location;
struct btrfs_root_item root_item;
struct extent_buffer *tmp;
+ u8 uuid[BTRFS_UUID_SIZE] = {0};
int ret;
ret = btrfs_copy_root(trans, root, root->node, &tmp, objectid);
btrfs_set_root_bytenr(&root_item, tmp->start);
btrfs_set_root_level(&root_item, btrfs_header_level(tmp));
btrfs_set_root_generation(&root_item, trans->transid);
+ /* clear uuid and o/ctime of source tree */
+ memcpy(root_item.uuid, uuid, BTRFS_UUID_SIZE);
+ btrfs_set_stack_timespec_sec(&root_item.otime, 0);
+ btrfs_set_stack_timespec_sec(&root_item.ctime, 0);
free_extent_buffer(tmp);
location.objectid = objectid;