diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2015-05-11 16:08:49 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-05-14 15:41:07 +0200 |
commit | cff8aa2313c48788b55d6559e107b5726dcb1217 (patch) | |
tree | 81cde543620dcca1d3f9c8c660cf15b932e43fc5 /btrfstune.c | |
parent | 605621993d414e0779d1d47426d2f1524de3b214 (diff) |
btrfs-progs: Introduce change_device_uuid function
This function changes a device items uuid.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'btrfstune.c')
-rw-r--r-- | btrfstune.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/btrfstune.c b/btrfstune.c index b8900113..4ccd6d4c 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -198,6 +198,27 @@ out: return ret; } +static int change_device_uuid(struct btrfs_root *root, struct extent_buffer *eb, + int slot) +{ + struct btrfs_fs_info *fs_info = root->fs_info; + struct btrfs_dev_item *di; + int ret = 0; + + di = btrfs_item_ptr(eb, slot, struct btrfs_dev_item); + if (fs_info->new_fsid) { + if (!memcmp_extent_buffer(eb, fs_info->new_fsid, + (unsigned long)btrfs_device_fsid(di), + BTRFS_FSID_SIZE)) + return ret; + write_extent_buffer(eb, fs_info->new_fsid, + (unsigned long)btrfs_device_fsid(di), + BTRFS_FSID_SIZE); + ret = write_tree_block(NULL, root, eb); + } + return ret; +} + static void print_usage(void) { fprintf(stderr, "usage: btrfstune [options] device\n"); |