This allows us to make the RUN_PARTED macro do something else
along the error path, other than just returning -1.
-#define RUN_PARTED(device,...) \
+#define RUN_PARTED(error,device,...) \
do { \
int r; \
char *err; \
do { \
int r; \
char *err; \
if (recover_blkrrpart ((device), err) == -1) { \
reply_with_error ("%s: parted: %s: %s", __func__, (device), err); \
free (err); \
if (recover_blkrrpart ((device), err) == -1) { \
reply_with_error ("%s: parted: %s: %s", __func__, (device), err); \
free (err); \
- RUN_PARTED (device, "mklabel", parttype, NULL);
+ RUN_PARTED (return -1, device, "mklabel", parttype, NULL);
* name_ to prlogex, eg. "primary". I would essentially describe
* this as a bug in the parted mkpart command.
*/
* name_ to prlogex, eg. "primary". I would essentially describe
* this as a bug in the parted mkpart command.
*/
- RUN_PARTED (device, "mkpart", prlogex, startstr, endstr, NULL);
+ RUN_PARTED (return -1, device, "mkpart", prlogex, startstr, endstr, NULL);
+ RUN_PARTED (return -1,
+ device,
"mklabel", parttype,
/* See comment about about the parted mkpart command. */
"mkpart", STREQ (parttype, "gpt") ? "p1" : "primary",
"mklabel", parttype,
/* See comment about about the parted mkpart command. */
"mkpart", STREQ (parttype, "gpt") ? "p1" : "primary",
snprintf (partstr, sizeof partstr, "%d", partnum);
snprintf (partstr, sizeof partstr, "%d", partnum);
- RUN_PARTED (device, "set", partstr, "boot", bootable ? "on" : "off", NULL);
+ RUN_PARTED (return -1,
+ device, "set", partstr, "boot", bootable ? "on" : "off", NULL);
snprintf (partstr, sizeof partstr, "%d", partnum);
snprintf (partstr, sizeof partstr, "%d", partnum);
- RUN_PARTED (device, "name", partstr, name, NULL);
+ RUN_PARTED (return -1, device, "name", partstr, name, NULL);