New files that the last commit missed.

This commit is contained in:
Paul Richards 1994-11-18 18:24:00 +00:00
parent 9e3f27547d
commit 111054f0ba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4646
4 changed files with 362 additions and 0 deletions

98
sbin/sysinstall/disk.h Normal file
View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 1994, Paul Richards.
*
* All rights reserved.
*
* This software may be used, modified, copied, distributed, and
* sold, in both source and binary form provided that the above
* copyright and these terms are retained, verbatim, as the first
* lines of this file. Under no circumstances is the author
* responsible for the proper functioning of this software, nor does
* the author assume any responsibility for damages incurred with
* its use.
*/
#define MBRSIZE 512
#define MBR_MAGIC 0xAA55
#define ACTIVE 0x80
#define BOOT1 "/stand/sdboot"
#define BOOT2 "/stand/bootsd"
/* XXX -- calculate these, this is nasty */
#define DEFFSIZE 1024
#define DEFFRAG 8
/* bootarea.c */
int write_bootblocks(int);
int enable_label(int);
int disable_label(int);
/* label.c */
char *diskname(int);
struct mbr
{
unsigned char padding[2];
unsigned char bootcode[DOSPARTOFF];
struct dos_partition dospart[4];
unsigned short magic;
};
struct disk {
struct disklabel lbl;
struct mbr mbr;
struct devconf *devconf;
int selected;
int inst_part;
struct fstab mounts[MAXPARTITIONS];
};
extern struct disk disk_list[];
struct part_type
{
unsigned char type;
char *name;
};
#define PARTITION_TYPES \
{ \
{0x00, "Unused"} \
,{0x01, "Primary DOS with 12 bit FAT"} \
,{0x02, "XENIX / filesystem"} \
,{0x03, "XENIX /usr filesystem"} \
,{0x04, "Primary DOS with 16 bit FAT"} \
,{0x05, "Extended DOS"} \
,{0x06, "Primary 'big' DOS (> 32MB)"} \
,{0x07, "OS/2 HPFS, QNX or Advanced UNIX"} \
,{0x08, "AIX filesystem"} \
,{0x09, "AIX boot partition or Coherent"} \
,{0x0A, "OS/2 Boot Manager or OPUS"} \
,{0x10, "OPUS"} \
,{0x40, "VENIX 286"} \
,{0x50, "DM"} \
,{0x51, "DM"} \
,{0x52, "CP/M or Microport SysV/AT"} \
,{0x56, "GB"} \
,{0x61, "Speed"} \
,{0x63, "ISC UNIX, other System V/386, GNU HURD or Mach"} \
,{0x64, "Novell Netware 2.xx"} \
,{0x65, "Novell Netware 3.xx"} \
,{0x75, "PCIX"} \
,{0x80, "Minix 1.1 ... 1.4a"} \
,{0x81, "Minix 1.4b ... 1.5.10"} \
,{0x82, "Linux"} \
,{0x93, "Amoeba filesystem"} \
,{0x94, "Amoeba bad block table"} \
,{0xA5, "FreeBSD/NetBSD/386BSD"} \
,{0xB7, "BSDI BSD/386 filesystem"} \
,{0xB8, "BSDI BSD/386 swap"} \
,{0xDB, "Concurrent CPM or C.DOS or CTOS"} \
,{0xE1, "Speed"} \
,{0xE3, "Speed"} \
,{0xE4, "Speed"} \
,{0xF1, "Speed"} \
,{0xF2, "DOS 3.3+ Secondary"} \
,{0xF4, "Speed"} \
,{0xFF, "BBT (Bad Blocks Table)"} \
};

197
sbin/sysinstall/editor.c Normal file
View File

@ -0,0 +1,197 @@
#include <string.h>
#include <ncurses.h>
#include <dialog.h>
#include "editor.h"
int
disp_fields(WINDOW *window, struct field field[], int no_fields)
{
int i, j;
wattrset(window, dialog_attr);
for (i=0; i < no_fields; i++) {
mvwprintw(window, field[i].y, field[i].x, "%s", field[i].field);
j=strlen(field[i].field);
if (j < field[i].width)
for (; j < field[i].width; j++)
waddch(window, ' ');
}
wrefresh(window);
}
int
change_field(struct field field, int key)
{
int next;
switch(key) {
case KEY_UP:
next = field.up;
break;
case KEY_DOWN:
next = field.down;
break;
case '\t':
next = field.right;
break;
case KEY_BTAB:
next = field.left;
break;
case '\n':
case '\r':
next = field.next;
break;
default:
next = -1;
break;
}
return (next);
}
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;
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 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;
}
} 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);
}

19
sbin/sysinstall/editor.h Normal file
View File

@ -0,0 +1,19 @@
#define ESC 27
#define TAB 9
struct field {
int y;
int x;
int width;
int maxlen;
int next;
int up;
int down;
int left;
int right;
char field[80];
};
int disp_fields(WINDOW *, struct field *, int);
int change_field(struct field, int);
int edit_line(WINDOW *, int, int, char *, int, int);

48
sbin/sysinstall/label.h Normal file
View File

@ -0,0 +1,48 @@
struct field label_field[] = {
{ 4, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
{ 4, 16, 3, 3, 2, -1, -1, -1, -1, "YES"},
{ 4, 27, 20, 20, 3, -1, -1, -1, -1, "MSDOS"},
{ 4, 39, 5, 5, 4, -1, -1, -1, -1, "1000"},
{ 4, 47, 20, 30, 6, -1, -1, -1, -1, "/an/example/mountpoint"},
{ 6, 02, 4, 4, -1, -1, -1, -1, -1, "wd0a"},
{ 6, 16, 3, 3, 7, -1, -1, -1, -1, "YES"},
{ 6, 27, 20, 20, 8, -1, -1, -1, -1, "MSDOS"},
{ 6, 39, 5, 5, 9, -1, -1, -1, -1, "1000"},
{ 6, 47, 20, 30, 11, -1, -1, -1, -1, "/an/example/mountpoint"},
{ 8, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
{ 8, 16, 3, 3, 12, -1, -1, -1, -1, "YES"},
{ 8, 27, 20, 20, 13, -1, -1, -1, -1, "MSDOS"},
{ 8, 39, 5, 5, 14, -1, -1, -1, -1, "1000"},
{ 8, 47, 20, 30, 16, -1, -1, -1, -1, "/an/example/mountpoint"},
{10, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
{10, 16, 3, 3, 17, -1, -1, -1, -1, "YES"},
{10, 27, 20, 20, 18, -1, -1, -1, -1, "MSDOS"},
{10, 39, 5, 5, 19, -1, -1, -1, -1, "1000"},
{10, 47, 20, 30, 21, -1, -1, -1, -1, "/an/example/mountpoint"},
{12, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
{12, 16, 3, 3, 22, -1, -1, -1, -1, "YES"},
{12, 27, 20, 20, 23, -1, -1, -1, -1, "MSDOS"},
{12, 39, 5, 5, 24, -1, -1, -1, -1, "1000"},
{12, 47, 20, 30, 26, -1, -1, -1, -1, "/an/example/mountpoint"},
{14, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
{14, 16, 3, 3, 27, -1, -1, -1, -1, "YES"},
{14, 27, 20, 20, 28, -1, -1, -1, -1, "MSDOS"},
{14, 39, 5, 5, 29, -1, -1, -1, -1, "1000"},
{14, 47, 20, 30, 31, -1, -1, -1, -1, "/an/example/mountpoint"},
{16, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
{16, 16, 3, 3, 32, -1, -1, -1, -1, "YES"},
{16, 27, 20, 20, 33, -1, -1, -1, -1, "MSDOS"},
{16, 39, 5, 5, 34, -1, -1, -1, -1, "1000"},
{16, 47, 20, 30, 36, -1, -1, -1, -1, "/an/example/mountpoint"},
{18, 02, 10, 10, -1, -1, -1, -1, -1, "wd0a"},
{18, 16, 3, 3, 37, -1, -1, -1, -1, "YES"},
{18, 27, 20, 20, 38, -1, -1, -1, -1, "MSDOS"},
{18, 39, 5, 5, 39, -1, -1, -1, -1, "1000"},
{18, 47, 20, 30, 1, -1, -1, -1, -1, "/an/example/mountpoint"},
{ 0, 18, 17, 17, -1, -1, -1, -1, -1, "Disk label editor"},
{ 2, 2, 11, 11, -1, -1, -1, -1, -1, "Partition"},
{ 2, 14, 8, 8, -1, -1, -1, -1, -1, "Preserve"},
{ 2, 25, 10, 10, -1, -1, -1, -1, -1, "Filesystem"},
{ 2, 39, 5, 5, -1, -1, -1, -1, -1, "Size"},
{ 2, 47, 10, 10, -1, -1, -1, -1, -1, "Mountpoint"}
};