mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-24 23:22:27 +00:00
use a different inode number for subvols than the root root dir
This commit is contained in:
parent
88e3e66570
commit
6d9ce71c81
3
ctree.h
3
ctree.h
@ -11,7 +11,8 @@ struct btrfs_trans_handle;
|
||||
#define BTRFS_ROOT_TREE_OBJECTID 1ULL
|
||||
#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
|
||||
#define BTRFS_FS_TREE_OBJECTID 3ULL
|
||||
#define BTRFS_FIRST_FREE_OBJECTID 4ULL
|
||||
#define BTRFS_ROOT_TREE_DIR_OBJECTID 4ULL
|
||||
#define BTRFS_FIRST_FREE_OBJECTID 5ULL
|
||||
|
||||
/*
|
||||
* we can actually store much bigger names, but lets not confuse the rest
|
||||
|
14
mkfs.c
14
mkfs.c
@ -22,21 +22,16 @@ static inline int ioctl(int fd, int define, u64 *size) { return 0; }
|
||||
#endif
|
||||
|
||||
static int __make_root_dir(struct btrfs_trans_handle *trans,
|
||||
struct btrfs_root *root)
|
||||
struct btrfs_root *root, u64 objectid)
|
||||
{
|
||||
int ret;
|
||||
char buf[8];
|
||||
u64 objectid;
|
||||
struct btrfs_key inode_map;
|
||||
struct btrfs_inode_item inode_item;
|
||||
|
||||
buf[0] = '.';
|
||||
buf[1] = '.';
|
||||
|
||||
ret = btrfs_find_free_objectid(trans, root, 1, &objectid);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
inode_map.objectid = objectid;
|
||||
inode_map.flags = 0;
|
||||
btrfs_set_key_type(&inode_map, BTRFS_INODE_ITEM_KEY);
|
||||
@ -44,7 +39,7 @@ static int __make_root_dir(struct btrfs_trans_handle *trans,
|
||||
|
||||
memset(&inode_item, 0, sizeof(inode_item));
|
||||
btrfs_set_inode_generation(&inode_item, root->fs_info->generation);
|
||||
btrfs_set_inode_size(&inode_item, 3);
|
||||
btrfs_set_inode_size(&inode_item, 6);
|
||||
btrfs_set_inode_nlink(&inode_item, 1);
|
||||
btrfs_set_inode_nblocks(&inode_item, 1);
|
||||
btrfs_set_inode_mode(&inode_item, S_IFDIR | 0555);
|
||||
@ -83,10 +78,11 @@ static int make_root_dir(int fd) {
|
||||
return -1;
|
||||
}
|
||||
trans = btrfs_start_transaction(root, 1);
|
||||
ret = __make_root_dir(trans, root->fs_info->tree_root);
|
||||
ret = __make_root_dir(trans, root->fs_info->tree_root,
|
||||
BTRFS_ROOT_TREE_DIR_OBJECTID);
|
||||
if (ret)
|
||||
goto err;
|
||||
ret = __make_root_dir(trans, root);
|
||||
ret = __make_root_dir(trans, root, BTRFS_FIRST_FREE_OBJECTID);
|
||||
if (ret)
|
||||
goto err;
|
||||
memcpy(&location, &root->fs_info->fs_root->root_key, sizeof(location));
|
||||
|
Loading…
Reference in New Issue
Block a user