format, make-fs: specify the label on mkfs

If specified, pass the label for the new filesystem directly to the
mkfs (or mkfs_btrfs) call.

This saves one set_label call, mostly.
This commit is contained in:
Pino Toscano
2015-01-09 18:57:24 +01:00
parent 7723614a91
commit d7abf5c8f2
2 changed files with 22 additions and 14 deletions

View File

@@ -434,13 +434,15 @@ do_format (void)
}
if (filesystem) {
if (guestfs_mkfs_opts (g, filesystem, dev, -1) == -1)
exit (EXIT_FAILURE);
struct guestfs_mkfs_opts_argv optargs = { .bitmask = 0 };
if (label) {
if (guestfs_set_label (g, dev, label) == -1)
exit (EXIT_FAILURE);
optargs.label = label;
optargs.bitmask |= GUESTFS_MKFS_OPTS_LABEL_BITMASK;
}
if (guestfs_mkfs_opts_argv (g, filesystem, dev, &optargs) == -1)
exit (EXIT_FAILURE);
}
if (free_dev)