mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-24 22:43:19 +00:00
btrfs-progs: mkfs: use preallocated buffers for config uuids
No need for dynamic allocation, the buffers are small, remove the now-useless error conditions. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
90e3e630c2
commit
7aaa1a92f6
@ -2373,10 +2373,8 @@ static int do_convert(const char *devname, int datacsum, int packing,
|
||||
mkfs_cfg.stripesize = blocksize;
|
||||
mkfs_cfg.features = features;
|
||||
/* New convert need these space */
|
||||
mkfs_cfg.fs_uuid = malloc(BTRFS_UUID_UNPARSED_SIZE);
|
||||
mkfs_cfg.chunk_uuid = malloc(BTRFS_UUID_UNPARSED_SIZE);
|
||||
*(mkfs_cfg.fs_uuid) = '\0';
|
||||
*(mkfs_cfg.chunk_uuid) = '\0';
|
||||
memset(mkfs_cfg.chunk_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
|
||||
memset(mkfs_cfg.fs_uuid, 0, BTRFS_UUID_UNPARSED_SIZE);
|
||||
|
||||
ret = make_btrfs(fd, &mkfs_cfg, &cctx);
|
||||
if (ret) {
|
||||
|
2
mkfs.c
2
mkfs.c
@ -1735,7 +1735,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mkfs_cfg.label = label;
|
||||
mkfs_cfg.fs_uuid = fs_uuid;
|
||||
memcpy(mkfs_cfg.fs_uuid, fs_uuid, sizeof(mkfs_cfg.fs_uuid));
|
||||
memcpy(mkfs_cfg.blocks, blocks, sizeof(blocks));
|
||||
mkfs_cfg.num_bytes = dev_block_count;
|
||||
mkfs_cfg.nodesize = nodesize;
|
||||
|
12
utils.c
12
utils.c
@ -250,16 +250,10 @@ static int setup_temp_super(int fd, struct btrfs_mkfs_config *cfg,
|
||||
struct btrfs_super_block *super = (struct btrfs_super_block *)super_buf;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* We rely on cfg->chunk_uuid and cfg->fs_uuid to pass uuid
|
||||
* for other functions.
|
||||
* Caller must allocate space for them
|
||||
*/
|
||||
BUG_ON(!cfg->chunk_uuid || !cfg->fs_uuid);
|
||||
memset(super_buf, 0, BTRFS_SUPER_INFO_SIZE);
|
||||
cfg->num_bytes = round_down(cfg->num_bytes, cfg->sectorsize);
|
||||
|
||||
if (cfg->fs_uuid && *cfg->fs_uuid) {
|
||||
if (*cfg->fs_uuid) {
|
||||
if (uuid_parse(cfg->fs_uuid, super->fsid) != 0) {
|
||||
error("cound not parse UUID: %s", cfg->fs_uuid);
|
||||
ret = -EINVAL;
|
||||
@ -320,8 +314,6 @@ static int setup_temp_extent_buffer(struct extent_buffer *buf,
|
||||
unsigned char chunk_uuid[BTRFS_UUID_SIZE];
|
||||
int ret;
|
||||
|
||||
/* We rely on cfg->fs_uuid and chunk_uuid to fsid and chunk uuid */
|
||||
BUG_ON(!cfg->fs_uuid || !cfg->chunk_uuid);
|
||||
ret = uuid_parse(cfg->fs_uuid, fsid);
|
||||
if (ret)
|
||||
return -EINVAL;
|
||||
@ -1049,7 +1041,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg,
|
||||
memset(&super, 0, sizeof(super));
|
||||
|
||||
num_bytes = (cfg->num_bytes / cfg->sectorsize) * cfg->sectorsize;
|
||||
if (cfg->fs_uuid && *cfg->fs_uuid) {
|
||||
if (*cfg->fs_uuid) {
|
||||
if (uuid_parse(cfg->fs_uuid, super.fsid) != 0) {
|
||||
error("cannot not parse UUID: %s", cfg->fs_uuid);
|
||||
ret = -EINVAL;
|
||||
|
Loading…
Reference in New Issue
Block a user