diff options
author | 2009-04-23 00:00:06 +0000 | |
---|---|---|
committer | 2009-04-23 00:00:06 +0000 | |
commit | ab20a3ea989b20fc735fc0ea137a5ec4ed43c97b (patch) | |
tree | 50f30e78e059c0f8130368716c4deaef1d2c151e | |
parent | fix creating packages with long names in plist; from espie@ (diff) | |
download | wireguard-openbsd-ab20a3ea989b20fc735fc0ea137a5ec4ed43c97b.tar.xz wireguard-openbsd-ab20a3ea989b20fc735fc0ea137a5ec4ed43c97b.zip |
Unrevert reversion of r1.192. This time make sure 'aflag' is treated
the same way 'dflag' is treated. i.e. reset it when the label is
written out so a 'w' followed by a 'q' exits the editor without
further questions. Also set it whenever the 'A' command is executed.
Suggestions by Alexander Hall.
ok deraadt@
-rw-r--r-- | sbin/disklabel/editor.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c index bc5380d580d..7122bdb39b9 100644 --- a/sbin/disklabel/editor.c +++ b/sbin/disklabel/editor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: editor.c,v 1.193 2009/04/20 17:40:43 deraadt Exp $ */ +/* $OpenBSD: editor.c,v 1.194 2009/04/23 00:00:06 krw Exp $ */ /* * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: editor.c,v 1.193 2009/04/20 17:40:43 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: editor.c,v 1.194 2009/04/23 00:00:06 krw Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -226,9 +226,10 @@ editor(struct disklabel *lp, int f) break; case 'A': - if (ioctl(f, DIOCGPDINFO, &label) == 0) + if (ioctl(f, DIOCGPDINFO, &label) == 0) { + aflag = 1; editor_allocspace(&label); - else + } else label = lastlabel; break; case 'a': @@ -313,11 +314,13 @@ editor(struct disklabel *lp, int f) if (fstabfile) mpsave(&label); /* - * If we didn't manufacture a new default label and - * didn't change the label read from disk, there is no - * need to do anything before exiting. + * If we haven't changed the label we started with, and it was not + * a default label or an auto-allocated label, there is no + * need to do anything before exiting. Note that 'w' will reset + * dflag and aflag to allow 'q' to exit with further questions. */ - if (!dflag && memcmp(lp, &label, sizeof(label)) == 0) { + if (!dflag && !aflag && + memcmp(lp, &label, sizeof(label)) == 0) { puts("No label changes."); return(1); } @@ -417,7 +420,7 @@ editor(struct disklabel *lp, int f) if (writelabel(f, bootarea, &label) != 0) warnx("unable to write label"); else { - dflag = 0; + dflag = aflag = 0; *lp = label; } break; |