- r = command (NULL, &err, "/sbin/mkfs", "-t", fstype, device, NULL);
- if (r == -1) {
- reply_with_error ("mkfs: %s", err);
- free (err);
- return -1;
+ argv[i++] = "mkfs";
+ argv[i++] = "-t";
+ argv[i++] = fstype;
+
+ /* mkfs.ntfs requires the -Q argument otherwise it writes zeroes
+ * to every block and does bad block detection, neither of which
+ * are useful behaviour for virtual devices.
+ */
+ if (STREQ (fstype, "ntfs"))
+ argv[i++] = "-Q";
+
+ /* mkfs.reiserfs produces annoying interactive prompts unless you
+ * tell it to be quiet.
+ */
+ if (STREQ (fstype, "reiserfs"))
+ argv[i++] = "-f";
+
+ /* Same for JFS. */
+ if (STREQ (fstype, "jfs"))
+ argv[i++] = "-f";
+
+ /* For GFS, GFS2, assume a single node. */
+ if (STREQ (fstype, "gfs") || STREQ (fstype, "gfs2")) {
+ argv[i++] = "-p";
+ argv[i++] = "lock_nolock";
+ /* The man page says this is default, but it doesn't seem to be: */
+ argv[i++] = "-j";
+ argv[i++] = "1";
+ /* Don't ask questions: */
+ argv[i++] = "-O";