summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-15 10:08:21 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-11-15 10:16:28 +0000
commita41629deb965830788d6b531272a0a20767e2ce6 (patch)
treead9f48b56d51a0bcb3eea575149f6700e4238c2b
parent5d9f10c31297c5f6bfe261717dfc5c841722a4c2 (diff)
downloadlibguestfs-a41629deb965830788d6b531272a0a20767e2ce6.tar.gz
libguestfs-a41629deb965830788d6b531272a0a20767e2ce6.tar.xz
libguestfs-a41629deb965830788d6b531272a0a20767e2ce6.zip
daemon: Perform device name translation on mke2fs journaldevice (RHBZ#876579).
Also various fixes: - remove fixed-size buffer - change if (err) free (err) -> free (err).
-rw-r--r--daemon/ext2.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/daemon/ext2.c b/daemon/ext2.c
index e4afced1..0d1a7869 100644
--- a/daemon/ext2.c
+++ b/daemon/ext2.c
@@ -864,7 +864,7 @@ do_mke2fs (const char *device, /* 0 */
char bytesperinode_s[64];
char inodesize_s[64];
char journalsize_s[64];
- char journaldevice_s[256];
+ char *journaldevice_s = NULL;
char reservedblockspercentage_s[64];
char numberofinodes_s[64];
char mmpupdateinterval_s[84];
@@ -947,8 +947,20 @@ do_mke2fs (const char *device, /* 0 */
}
if (optargs_bitmask & GUESTFS_MKE2FS_JOURNALDEVICE_BITMASK) {
if (journaldevice) {
- snprintf (journaldevice_s, sizeof journaldevice_s,
- "device=%s", journaldevice);
+ /* OString doesn't do device name translation (RHBZ#876579). We
+ * have to do it manually here, but note that LABEL=.. and
+ * UUID=.. are valid strings which do not require translation.
+ */
+ journaldevice_s = malloc (strlen (journaldevice) + 8);
+ if (!journaldevice_s) {
+ reply_with_perror ("malloc");
+ goto error;
+ }
+
+ sprintf (journaldevice_s, "device=%s", journaldevice);
+ if (STRPREFIX (&journaldevice_s[7], "/dev/"))
+ RESOLVE_DEVICE (&journaldevice_s[7], , goto error);
+
ADD_ARG (argv, i, "-J");
ADD_ARG (argv, i, journaldevice_s);
}
@@ -1171,11 +1183,13 @@ do_mke2fs (const char *device, /* 0 */
goto error;
}
+ free (journaldevice_s);
free (err);
return 0;
error:
- if (err) free (err);
+ free (journaldevice_s);
+ free (err);
return -1;
}