Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions common/root-tree-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "kerncompat.h"
#include <string.h>
#include <time.h>
#include <uuid/uuid.h>
#include "kernel-shared/disk-io.h"
Expand Down Expand Up @@ -102,6 +103,16 @@ int btrfs_make_subvolume(struct btrfs_trans_handle *trans, u64 objectid,
if (ret < 0)
goto error;

if (objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) {
time_t now = time(NULL);
uuid_t uuid;

uuid_generate(uuid);
memcpy(root->root_item.uuid, uuid, BTRFS_UUID_SIZE);
btrfs_set_stack_timespec_sec(&root->root_item.otime, now);
btrfs_set_stack_timespec_sec(&root->root_item.ctime, now);
}

btrfs_set_stack_inode_flags(&root->root_item.inode,
BTRFS_INODE_ROOT_ITEM_INIT);

Expand Down
13 changes: 13 additions & 0 deletions convert/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <uuid/uuid.h>
#include "kernel-lib/sizes.h"
#include "kernel-shared/ctree.h"
Expand Down Expand Up @@ -232,6 +233,18 @@ static void insert_temp_root_item(struct extent_buffer *buf,
btrfs_set_stack_inode_nlink(inode_item, 1);
btrfs_set_stack_inode_nbytes(inode_item, cfg->nodesize);
btrfs_set_stack_inode_mode(inode_item, S_IFDIR | 0755);

if (objectid == BTRFS_FS_TREE_OBJECTID) {
time_t now = time(NULL);
uuid_t uuid;

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);
btrfs_set_stack_inode_flags(inode_item, BTRFS_INODE_ROOT_ITEM_INIT);
}

btrfs_set_root_refs(&root_item, 1);
btrfs_set_root_used(&root_item, cfg->nodesize);
btrfs_set_root_generation(&root_item, 1);
Expand Down