[Pkg-libvirt-commits] [libguestfs] 160/384: format, make-fs: specify the label on mkfs
Hilko Bengen
bengen at moszumanska.debian.org
Sun Mar 29 16:56:45 UTC 2015
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit d7abf5c8f2b9c0895faaa3166eb3a3f72ede17a2
Author: Pino Toscano <ptoscano at redhat.com>
Date: Fri Jan 9 18:57:24 2015 +0100
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.
---
format/format.c | 10 ++++++----
make-fs/make-fs.c | 28 +++++++++++++++++-----------
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/format/format.c b/format/format.c
index 4e6069f..cc371ab 100644
--- a/format/format.c
+++ b/format/format.c
@@ -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)
diff --git a/make-fs/make-fs.c b/make-fs/make-fs.c
index bbea28f..01058c9 100644
--- a/make-fs/make-fs.c
+++ b/make-fs/make-fs.c
@@ -755,9 +755,15 @@ do_make_fs (const char *input, const char *output_str)
/* Create the filesystem. */
if (STRNEQ (type, "btrfs")) {
int r;
+ struct guestfs_mkfs_opts_argv optargs = { .bitmask = 0 };
+
+ if (label) {
+ optargs.label = label;
+ optargs.bitmask |= GUESTFS_MKFS_OPTS_LABEL_BITMASK;
+ }
guestfs_push_error_handler (g, NULL, NULL);
- r = guestfs_mkfs (g, type, dev);
+ r = guestfs_mkfs_opts_argv (g, type, dev, &optargs);
guestfs_pop_error_handler (g);
if (r == -1) {
@@ -774,17 +780,17 @@ do_make_fs (const char *input, const char *output_str)
}
else {
const char *devs[] = { dev, NULL };
+ struct guestfs_mkfs_btrfs_argv optargs = { .bitmask = 0 };
+
+ optargs.datatype = "single";
+ optargs.metadata = "single";
+ optargs.bitmask |= GUESTFS_MKFS_BTRFS_DATATYPE_BITMASK | GUESTFS_MKFS_BTRFS_METADATA_BITMASK;
+ if (label) {
+ optargs.label = label;
+ optargs.bitmask |= GUESTFS_MKFS_BTRFS_LABEL_BITMASK;
+ }
- if (guestfs_mkfs_btrfs (g, (char **) devs,
- GUESTFS_MKFS_BTRFS_DATATYPE, "single",
- GUESTFS_MKFS_BTRFS_METADATA, "single",
- -1) == -1)
- return -1;
- }
-
- /* Set label. */
- if (label) {
- if (guestfs_set_label (g, dev, label) == -1)
+ if (guestfs_mkfs_btrfs_argv (g, (char **) devs, &optargs) == -1)
return -1;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list