-/* $OpenBSD: cmd.c,v 1.144 2021/09/02 18:07:45 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.145 2021/09/09 15:21:39 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
int
Xquit(char *args, struct mbr *mbr)
{
- return CMD_SAVE;
+ return CMD_QUIT;
}
int
-/* $OpenBSD: cmd.h,v 1.24 2021/08/12 12:31:16 krw Exp $ */
+/* $OpenBSD: cmd.h,v 1.25 2021/09/09 15:21:39 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#define _CMD_H
#define CMD_EXIT 0x0000
-#define CMD_SAVE 0x0001
+#define CMD_QUIT 0x0001
#define CMD_CONT 0x0002
#define CMD_CLEAN 0x0003
#define CMD_DIRTY 0x0004
-/* $OpenBSD: user.c,v 1.76 2021/08/25 23:47:36 krw Exp $ */
+/* $OpenBSD: user.c,v 1.77 2021/09/09 15:21:39 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
{"abort", 1, Xabort, "Abort program without saving current changes"},
};
-
int modified;
int ask_cmd(const int, char **);
int i, st;
static int editlevel;
- editlevel += 1;
-
if (MBR_read(lba_self, lba_firstembr, &mbr))
- goto done;
+ return;
+
+ editlevel += 1;
if (editlevel == 1)
GPT_read(ANYGPT);
printf("Enter 'help' for information\n");
-again:
- do {
+ for (;;) {
if (letoh64(gh.gh_sig) == GPTSIGNATURE && editlevel > 1)
- goto done; /* 'reinit gpt'. Unwind recursion! */
+ break; /* 'reinit gpt'. Unwind recursion! */
i = ask_cmd(editlevel, &args);
if (i == -1)
st = cmd_table[i].cmd_fcn(args ? args : "", &mbr);
- if (st == CMD_EXIT)
+ if (st == CMD_EXIT) {
+ if (modified)
+ printf("Aborting changes to current MBR\n");
break;
- if (st == CMD_SAVE)
+ }
+ if (st == CMD_QUIT) {
+ if (modified && Xwrite(NULL, &mbr) == CMD_CONT)
+ continue;
break;
+ }
if (st == CMD_CLEAN)
modified = 0;
if (st == CMD_DIRTY)
modified = 1;
- } while (1);
-
- if (modified) {
- if (st == CMD_SAVE) {
- if (Xwrite(NULL, &mbr) == CMD_CONT)
- goto again;
- } else
- printf("Aborting changes to current MBR.\n");
}
-done:
editlevel -= 1;
}