summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1994-11-17 14:12:38 +0000
committerjkh <jkh@FreeBSD.org>1994-11-17 14:12:38 +0000
commit307863bc923ad1184dbfeb8a792c2e56add13db9 (patch)
treed2925d40d231ff3dfb47c935006fd45395d2b02e /sbin
parent86f1a4176a2ecc79adce54186068d7db0e73557e (diff)
downloadFreeBSD-src-307863bc923ad1184dbfeb8a792c2e56add13db9.zip
FreeBSD-src-307863bc923ad1184dbfeb8a792c2e56add13db9.tar.gz
1. Add check to see if CPIO floppy extracted properly.
2. See if swapon() failed and at least print a diagnostic. 3. Use -1 instead of strheight()/strwidth() everywhere. Reviewed by: Submitted by: Obtained from:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/sysinstall/ourcurses.c281
-rw-r--r--sbin/sysinstall/stage3.c6
-rw-r--r--sbin/sysinstall/stage4.c11
-rw-r--r--sbin/sysinstall/utils.c6
4 files changed, 161 insertions, 143 deletions
diff --git a/sbin/sysinstall/ourcurses.c b/sbin/sysinstall/ourcurses.c
index 95b808a..00d00d1 100644
--- a/sbin/sysinstall/ourcurses.c
+++ b/sbin/sysinstall/ourcurses.c
@@ -14,148 +14,158 @@
int
edit_line(WINDOW *window, int y, int x, char *field, int width, int maxlen)
{
- int len;
- int key = 0;
- int fpos, dispos, curpos;
- int i;
- int done = 0;
+ int len;
+ int key = 0;
+ int fpos, dispos, curpos;
+ int i;
+ int done = 0;
- len = strlen(field);
- if (len < width) {
+ len = strlen(field);
+ if (len < width) {
+ fpos = len;
+ curpos = len;
+ dispos = 0;
+ } else {
+ fpos = width;
+ curpos = width;
+ dispos = len - width;
+ };
+
+
+ do {
+ wattrset(window, item_selected_attr);
+ wmove(window, y, x);
+ for (i=0; i < width; i++)
+ if (i < (len - dispos))
+ waddch(window, field[dispos+i]);
+ else
+ waddch(window, ' ');
+ wmove(window, y, x + curpos);
+ wrefresh(window);
+
+ key = wgetch(window);
+ switch (key) {
+ case TAB:
+ case KEY_BTAB:
+ case KEY_UP:
+ case KEY_DOWN:
+ case ESC:
+ case '\n':
+ case '\r':
+ done = 1;
+ break;
+
+ case '\001': /* ^A */
+ case KEY_HOME:
+ if (len < width) {
fpos = len;
curpos = len;
dispos = 0;
- } else {
+ } else {
fpos = width;
curpos = width;
dispos = len - width;
- };
-
-
- do {
- wattrset(window, item_selected_attr);
- wmove(window, y, x);
- for (i=0; i < width; i++)
- if (i < (len - dispos))
- waddch(window, field[dispos+i]);
- else
- waddch(window, ' ');
- wmove(window, y, x + curpos);
- wrefresh(window);
-
- key = wgetch(window);
- switch (key) {
- case TAB:
- case KEY_BTAB:
- case KEY_UP:
- case KEY_DOWN:
- case ESC:
- case '\n':
- case '\r':
- done = 1;
- break;
- case KEY_HOME:
- if (len < width) {
- fpos = len;
- curpos = len;
- dispos = 0;
- } else {
- fpos = width;
- curpos = width;
- dispos = len - width;
- };
- break;
- case KEY_END:
- if (len < width) {
- dispos = 0;
- curpos = len - 1;
- } else {
- dispos = len - width - 1;
- curpos = width - 1;
- }
- fpos = len - 1;
- break;
- case KEY_LEFT:
- if ((!curpos) && (!dispos)) {
- beep();
- break;
- }
- if (--curpos < 0) {
- curpos = 0;
- if (--dispos < 0)
- dispos = 0;
- }
- if (--fpos < 0)
- fpos = 0;
- break;
- case KEY_RIGHT:
- if ((curpos + dispos) == len) {
- beep();
- break;
- }
- if ((curpos == (width-1)) && (dispos == (maxlen - width -1))) {
- beep();
- break;
- }
- if (++curpos >= width) {
- curpos = width - 1;
- dispos++;
- }
- if (dispos >= len)
- dispos = len - 1;
- if (++fpos >= len) {
- fpos = len;
- }
- break;
- case KEY_BACKSPACE:
- case KEY_DC:
- if ((!curpos) && (!dispos)) {
- beep();
- break;
- }
- if (fpos > 0) {
- memmove(field+fpos-1, field+fpos, len - fpos);
- len--;
- fpos--;
- if (curpos > 0)
- --curpos;
- if (!curpos)
- --dispos;
- if (dispos < 0)
- dispos = 0;
- } else
- beep();
- break;
- default:
- if (len < maxlen - 1) {
- memmove(field+fpos+1, field+fpos, len - fpos);
- field[fpos] = key;
- len++;
- fpos++;
- if (++curpos == width) {
- --curpos;
- dispos++;
- }
- if (len == (maxlen - 1)) {
- dispos = (maxlen - width - 1);
- }
- } else
- beep();
- break;
+ };
+ break;
+
+ case '\005': /* ^E */
+ case KEY_END:
+ if (len < width) {
+ dispos = 0;
+ curpos = len - 1;
+ } else {
+ dispos = len - width - 1;
+ curpos = width - 1;
+ }
+ fpos = len - 1;
+ break;
+
+ case '\002': /* ^B */
+ case KEY_LEFT:
+ if ((!curpos) && (!dispos)) {
+ beep();
+ break;
+ }
+ if (--curpos < 0) {
+ curpos = 0;
+ if (--dispos < 0)
+ dispos = 0;
+ }
+ if (--fpos < 0)
+ fpos = 0;
+ break;
+
+ case '\006': /* ^F */
+ case KEY_RIGHT:
+ if ((curpos + dispos) == len) {
+ beep();
+ break;
+ }
+ if ((curpos == (width-1)) && (dispos == (maxlen - width -1))) {
+ beep();
+ break;
+ }
+ if (++curpos >= width) {
+ curpos = width - 1;
+ dispos++;
+ }
+ if (dispos >= len)
+ dispos = len - 1;
+ if (++fpos >= len) {
+ fpos = len;
+ }
+ break;
+
+ case KEY_BACKSPACE:
+ case KEY_DC:
+ if ((!curpos) && (!dispos)) {
+ beep();
+ break;
+ }
+ if (fpos > 0) {
+ memmove(field+fpos-1, field+fpos, len - fpos);
+ len--;
+ fpos--;
+ if (curpos > 0)
+ --curpos;
+ if (!curpos)
+ --dispos;
+ if (dispos < 0)
+ dispos = 0;
+ } else
+ beep();
+ break;
+
+ default:
+ if (len < maxlen - 1) {
+ memmove(field+fpos+1, field+fpos, len - fpos);
+ field[fpos] = key;
+ len++;
+ fpos++;
+ if (++curpos == width) {
+ --curpos;
+ dispos++;
}
- } while (!done);
- wattrset(window, dialog_attr);
- wmove(window, y, x);
- for (i=0; i < width; i++)
- if (i < (len - dispos))
- waddch(window, field[dispos+i]);
- else
- waddch(window, ' ');
- wmove(window, y, x + curpos);
- wstandend(window);
- field[len] = 0;
- wrefresh(window);
- return (key);
+ if (len == (maxlen - 1)) {
+ dispos = (maxlen - width - 1);
+ }
+ } else
+ beep();
+ break;
+ }
+ } while (!done);
+ wattrset(window, dialog_attr);
+ wmove(window, y, x);
+ for (i=0; i < width; i++)
+ if (i < (len - dispos))
+ waddch(window, field[dispos+i]);
+ else
+ waddch(window, ' ');
+ wmove(window, y, x + curpos);
+ wstandend(window);
+ field[len] = 0;
+ wrefresh(window);
+ return (key);
}
int
@@ -174,10 +184,11 @@ ShowFile(char *filename, char *header)
char buf[256];
if (access(filename, R_OK)) {
sprintf(buf, "The %s file is not provided on the 1.2MB floppy image.", filename);
- dialog_msgbox("Sorry!", buf, strheight(buf)+4, strwidth(buf)+4, 1);
+ dialog_msgbox("Sorry!", buf, -1, -1, 1);
return;
}
dialog_clear();
dialog_textbox(header, filename, LINES, COLS);
dialog_clear();
}
+
diff --git a/sbin/sysinstall/stage3.c b/sbin/sysinstall/stage3.c
index f99918c..2121f3a 100644
--- a/sbin/sysinstall/stage3.c
+++ b/sbin/sysinstall/stage3.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: stage3.c,v 1.7 1994/11/02 06:19:47 jkh Exp $
+ * $Id: stage3.c,v 1.8 1994/11/08 13:40:01 phk Exp $
*
*/
@@ -46,7 +46,9 @@ stage3()
if (*p++ != '/') continue;
if (!strcmp(fs->fs_type, "sw")) {
- swapon(fs->fs_spec);
+ if (swapon(fs->fs_spec) == -1)
+ AskAbort("Unable to swap to %s - are you sure it's right?",
+ fs->fs_spec);
continue;
}
diff --git a/sbin/sysinstall/stage4.c b/sbin/sysinstall/stage4.c
index c7b0cf2..dc374c8 100644
--- a/sbin/sysinstall/stage4.c
+++ b/sbin/sysinstall/stage4.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: stage4.c,v 1.4 1994/11/02 06:19:49 jkh Exp $
+ * $Id: stage4.c,v 1.5 1994/11/02 07:15:55 jkh Exp $
*
*/
@@ -76,6 +76,11 @@ stage4()
Fatal("Pid %d, status %d, cpio=%d, gunzip=%d.\nerror:%s",
i, j, cpid, zpid, strerror(errno));
- TellEm("unlink /stand/need_cpio_floppy");
- unlink("/stand/need_cpio_floppy");
+ if (access("/stand/cpio_floppy_done", R_OK) == -1)
+ Fatal("CPIO floppy was bad! Please check media for defects.");
+ else {
+ TellEm("unlink /stand/need_cpio_floppy");
+ unlink("/stand/need_cpio_floppy");
+ unlink("/stand/cpio_floppy_done");
+ }
}
diff --git a/sbin/sysinstall/utils.c b/sbin/sysinstall/utils.c
index 4dfc87d..dc1e656 100644
--- a/sbin/sysinstall/utils.c
+++ b/sbin/sysinstall/utils.c
@@ -6,7 +6,7 @@
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*
- * $Id: utils.c,v 1.26 1994/11/07 13:48:54 jkh Exp $
+ * $Id: utils.c,v 1.27 1994/11/16 14:42:22 ache Exp $
*
*/
@@ -68,7 +68,7 @@ TellEm(char *fmt, ...)
write(debug_fd,">\n\r",3);
dialog_clear();
dialog_update();
- dialog_msgbox("Progress", p, strheight(p)+2, strwidth(p)+4, 0);
+ dialog_msgbox("Progress", p, -1, -1, 0);
free(p);
}
@@ -83,7 +83,7 @@ Fatal(char *fmt, ...)
va_end(ap);
strip_trailing_newlines(p);
if (dialog_active)
- dialog_msgbox("Fatal", p, strheight(p)+4, strwidth(p)+4, 1);
+ dialog_msgbox("Fatal", p, -1, -1, 1);
else
fprintf(stderr, "Fatal -- %s\n", p);
free(p);
OpenPOWER on IntegriCloud