+ free (err);
+ return 0;
+}
+
+int
+do_mke2fs_JL (const char *fstype, int blocksize, const char *device,
+ const char *label)
+{
+ char *err;
+ int r;
+
+ char prog[] = "mke2fs";
+ if (e2prog (prog) == -1)
+ return -1;
+
+ if (strlen (label) > EXT2_LABEL_MAX) {
+ reply_with_error ("%s: ext2 labels are limited to %d bytes",
+ label, EXT2_LABEL_MAX);
+ return -1;
+ }
+
+ char blocksize_s[32];
+ snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize);
+
+ int len = strlen (label);
+ char jdev[len+32];
+ snprintf (jdev, len+32, "device=LABEL=%s", label);
+
+ r = command (NULL, &err,
+ prog, "-t", fstype, "-J", jdev, "-b", blocksize_s,
+ device, NULL);
+ if (r == -1) {
+ reply_with_error ("%s", err);
+ free (err);
+ return -1;
+ }
+
+ free (err);
+ return 0;
+}
+
+int
+do_mke2fs_JU (const char *fstype, int blocksize, const char *device,
+ const char *uuid)
+{
+ char *err;
+ int r;
+
+ char prog[] = "mke2fs";
+ if (e2prog (prog) == -1)
+ return -1;
+
+ char blocksize_s[32];
+ snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize);
+
+ int len = strlen (uuid);
+ char jdev[len+32];
+ snprintf (jdev, len+32, "device=UUID=%s", uuid);
+
+ r = command (NULL, &err,
+ prog, "-t", fstype, "-J", jdev, "-b", blocksize_s,
+ device, NULL);
+ if (r == -1) {
+ reply_with_error ("%s", err);
+ free (err);
+ return -1;
+ }
+
+ free (err);
+ return 0;