DataMuseum.dk

Presents historical artifacts from the history of:

ICL Comet 32

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about ICL Comet 32

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦a01fa7242⟧ TextFile

    Length: 11594 (0x2d4a)
    Types: TextFile
    Notes: UNIX file
    Names: »uboot.c«

Derivation

└─⟦26887b7e0⟧ Bits:30009717 Comet 32 harddisk image
    └─⟦28c352965⟧ »/a« UNIX Filesystem
        └─⟦this⟧ »sys/stand/uboot.c« 

TextFile

/*
 * uboot.c: version 1 860926
 * 
 */
# ifdef SCCS
static char *sccsid = "@(#)uboot.c"	
# endif

#ifndef STANDALONE
#include <stdio.h>
#include "bootcap.h"
#include <sys/reboot.h>
#include "bootop.h"
#else
#include "/sys/h/param.h"
#include "/sys/h/bootcap.h"
#include <sys/reboot.h>
#include "/sys/h/bootop.h"
#endif

#define DEF_NAME	"vmunix"
#define DEF_HOW		"auto"

char 	*tbuf;
int 	hopcount;	/* detect infinite loops in termcap, init 0 */
char	bootopbuf[BFSIZ];
char	getbopres[10];
char	tempbcb[1024];
char	*bcentry = tempbcb;
main()
{
	register howto;
	int io,i,j;
	char s[50], line[50];
	struct bootop bootop;
#ifdef ASK
#ifdef MENY 
	callmeny();
#endif
#endif
nameloop:
#ifdef ASK
	printf("\n\nboot [ %s ]: ", DEF_HOW);
	gets(s);
	if (s[0] != 0)
		strcpy(line, s);
	else
#endif
		strcpy(line, DEF_HOW);
#ifdef ASK 
	if (menyans(line))
		goto nameloop;
	else
#endif
	if (bgetent(bootopbuf,line)){
		if (getbop("su")) howto = RB_SINGLE;
		else if (getbop("mu")) howto = 0;
		else goto bad;
	} else goto bad;
	if (getbop("bd")==0) goto bad;
	strcpy(line,getbopres);
	if (getbop("nm")==0){
#ifdef ASK
		printf("file [ %s ]: ", DEF_NAME);
		gets(s);
		if (s[0] != 0)
			strcpy(getbopres, s);
		else
#endif
			strcpy(getbopres, DEF_NAME);
	} 
	i=j=0;
	while (line[i++] != '\0') continue;
	i--;
	while (getbopres[j] != '\0')
	line[i++] = getbopres[j++];
	line[i] = '\0';

#ifdef STANDALONE
	io = open(line, 0);
	if (io < 0)
		goto nameloop;

	copyunix(howto, io);
#else
	setbootop(&bootop);
	printf("bootop = [ rd:%d,sd:%d,pd:%d,dd:%d,tz:%d,ns:%d,nb:%d,%d,%d ]\n",bootop);
#endif
	goto end;
bad:
	printf("Bad bootcap entry\n");
	goto nameloop;
end:	;
}

/*
 * Get an entry for boot option named "name" in buffer bp,
 * from the bootcap array.  Parse is very rudimentary;
 * we just notice escaped newlines.
 */
bgetent(bp, name)
	char *bp, *name;
{
	register char *cp;
	register char c;
	register int i = 0, cnt = 0;
	char *ibuf;

	ibuf = bootcapbuf;
	tbuf = bp;
	for (;;) {
		cp = bp;
		for (;;) {
			if (i == 0) {
				cnt = strlen(bootcapbuf);
				i = 0;
			} 
			if (i >= cnt) {
				return(0);
			}
			c = ibuf[i++];
			if (c == '#') {
				break;
			}
			*cp++ = c;
		}
		*cp = 0;

		/*
		 * The real work for the match.
		 */
		if (bnamatch(name)) {
			return(tnchkcf());
		}
	}
}

/*
 * tnchkcf: check the last entry, see if it's cf=xxx. If so,
 * recursively find xxx and append that entry (minus the names)
 * to take the place of the cf=xxx entry. This allows bootcap
 * entries to say "like multi"
 */
tnchkcf()
{
	register char *p, *q;
	char tcname[16];	/* name of similar terminal */
	char tcbuf[BFSIZ];
	char *holdtbuf = tbuf;
	int l;
	p = tbuf + strlen(tbuf) - 2;	/* before the last colon */
	while (*--p != ':')
		if (p<tbuf) {
			printf("Bad bootcap entry\n");
			return (0);
		}
	p++;
	/* p now points to beginning of last field */
	if (p[0] != 'c' || p[1] != 'f')
		return(1);
	strcpy(tcname,p+3);
	q = tcname;
	while (q && *q != ':')
		q++;
	*q = 0;
	if (++hopcount > MAXHOP) {
		printf("Infinite cf= loop\n");
		return (0);
	}
	if (bgetent(tcbuf, tcname) != 1)
		return(0);
	for (q=tcbuf; *q != ':'; q++)
		;
	l = p - holdtbuf + strlen(q);
	if (l > BFSIZ) {
		printf("Bootcap entry too long\n");
		q[BFSIZ - (p-tbuf)] = 0;
	}
	strcpy(p, q+1);
	tbuf = holdtbuf;
	return(1);
}

/*
 * Bnamatch deals with name matching.  The first field of the bootcap
 * entry is a sequence of names separated by |'s, so we compare
 * against each such name.  The normal : terminator after the last
 * name (before the first field) stops us.
 */
bnamatch(np)
	char *np;
{
	register char *Np, *Bp;

	Bp = tbuf;
	for (;;) {
		for (Np = np; *Np && *Bp == *Np; Bp++, Np++)
			continue;
		if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0))
			return (1);
		while (*Bp && *Bp != ':' && *Bp != '|')
			Bp++;
		if (*Bp == 0 || *Bp == ':')
			return (0);
		Bp++;
	}
}

getbop(np)
	char *np;
{
	register char *Np, *Bp, *res;
	
	Bp = bootopbuf;
	Np = np;
	res = getbopres;
    	for(;;) {	
		while (*Bp != *Np){
			*Bp++;
			if (*Bp == 0 ) return(0);
		}
		*Np++; *Bp++;
		if ( *Np == *Bp ) {
			*Np++; *Bp++;
		} else {
			*Np--;
			continue;
		}
		if (*Np == 0 && ( *Bp == ':' || *Bp == 0))
			return (1);
		if (*Np == 0 && ( *Bp == '=' )){
			*Bp++;
			while (*Bp && *Bp != ':' && *Bp != '\0')
			*res++ = *Bp++;
			*res = '\0';
			return(1);
		}
		if (*Bp == '\0') return(0);
		*Np--; *Np--;
     	}	 
}
setbootop(p)
register struct bootop *p;
{
	char *s;
	char sp[16],t[16];
	int strlen;

	s = bootopbuf;
	strlen = getstr(":",s,t);		/* get string ended whit "::"*/
	s = (s + strlen + 2);

	while ((strlen=getstr(":",s,t))) {

		s = (s + strlen +1);	

		if (strlen = getstr("=",t,sp)) {
			
			t[0] = t[1] = t[2] = ' ';

			if( sp[0] == 'b'  &&  sp[1] == 'd')
				continue;

			if( sp[0] ==  'r' && sp[1] == 'd') {
				p->rootdev = getdev(t);	
				continue;
			}
			if ( sp[0] == 's' && sp[1] == 'd') {
				p->swapdev = getdev(t);		
				continue;
			}	
			if ( sp[0] == 'p' && sp[1] == 'd') {
				p->pipedev = getdev(t);
				continue;
			}
			if ( sp[0] == 'd' && sp[1] == 'd') {
				p->dumpdev = getdev(t);
				continue;
			}
			if ( sp[0] == 't' && sp[1] == 'z') {
				p->timezone = atoi(t);
				continue;
			}
			if ( sp[0] == 'n' && sp[1] == 's') { 
				p->nswap = atoi(t);
				continue;
			}
			if ( sp[0] == 'n' && sp[1] == 'b'){
				p->nbuf = atoi(t);
				continue;
			}
		} else {
			if ( sp[0] == 'g' && sp[1] == 's'){
				p->graphsys = 0;
				continue;
			}
			if ( sp[0] == 'w' && sp[1] == 's'){
				p->graphsys = 1;
				continue;
			}
		}
	}
}
getstr(a,b,c)
char *a,*b,*c;
{
	int i = 0;
	char *ta,*tb,*tc;

	ta = a; tb = b; tc = c;

	while(*tb != *ta && *tb != '\0') {
		*tc++ = *tb++;
		i++;
	}
	if (*tb == '\0' ) return(0);
	tb++; i++;
	while(*tb == *ta){
		tb++; i++;
	}
	i--;
	*tc = '\0';
	return(i);
}

getdev(s)
char *s;
{
	int i;

	while(*s++ == ' ' && *s != '\0');
	*s--;

	for (i=0; i< BODSIZE; i++) {

		if (strcmp(s,bootdev[i].bdname) == 0){

			return (makedev(bootdev[i].majo,bootdev[i].mino));
		}
	}
	return(0);
}

callmeny()
{
	printf("\n\n");
	printf("\t Welcome to ICL/COMET 32-GENIX boot system \n");
	printf("\t ----------------------------------------- \n\n\n");

	printf("\t This system makes it easyer for the user to administrate\n");
	printf("\t the several unix versions such as vmunix vmback vmflop \n");
	printf("\t etc (only one is neaded for the same hardware) and it gives \n");
	printf("\t the user the opportunity to change system parameters.\n\n");
	printf("\t To start up the GENIX system -       Give appropriate\n");
	printf("\t                                      bootcap entry name\n");
	printf("\t Bootcap description          -       Give 0\n");
	printf("\t To see bootcap               -       Give 1\n");
	printf("\t To insert/change a bootcap   -       Give 2\n");
	printf("\t entry temporary \n");
	printf("\t To insert/change an entry    -       Give 3\n");
	printf("\t permanent \n");
	printf("\t To delete an entry           -       Give 4\n");
	printf("\t To see this meny             -       Give ?\n\n");
}
bootcapcont()
{ 
    printf("\tThe include file \" bootcap.h\" contains the bootcap entrys\n");

    printf("\tA bootcap entry is configured:\n");
    printf("\tname|longname::fields:fields:fields#\n\n");
    printf("\tFields\n");
    printf("\t------\n\n");
    printf("\tbd=dev		standalone device booted from\n");
    printf("\trd=dev		kernel root device\n");
    printf("\tsd=dev		kernel swap device\n");
    printf("\tpd=dev		kernel pipe device\n");
    printf("\tdd=dev            kernel dump device\n"); 
    printf("\ttz=num		timezone in minutes from GMT\n");
    printf("\tns=num		number of swapping sectors\n");
    printf("\tnb=num		number of kernel buffers\n");
    printf("\tgs		\"graphsys\" (console=rs232)\n");
    printf("\tws		\"workstation\" (console=bitmap)\n");
    printf("\tsu		singleuser\n");
    printf("\tmu		multiuser\n");
    printf("\tcf=name		take configuration from name\n");
    printf("\tnm=file	        name of file to boot\n");
    printf("\t#                 end sign for one entry\n");
}

menyans(line)
char *line;
{
	int i,n;
	char *bp;

	if (strcmp("0",line) == 0) {
			bootcapcont();
			return(1);
	} else if (strcmp("1",line) == 0){
			n = strlen(bootcapbuf);
			bp = bootcapbuf; i = 0;
			printf("\n");
			while (n--) {
			   if (*bp != '#') {
				bootopbuf [i] = *bp;
				bp++; i++;
			   } else {
				bootopbuf[i] = *bp;
				bootopbuf[i+1] = '\0';
				bp++; i=0;
				printf("%s\n",bootopbuf);
			   }
			}
			return(1);
	} else if (strcmp("2",line) == 0) {
			insentry();
			return(1);
	} else if (strcmp("3",line)==0) {
			printf("Change entry in bootcap.h and recompile boot\n");
			printf("Make a new bootfloppy\n");
			return(1);
	} else if (strcmp("4",line)==0){
			printf("Delete entry in bootcap.h and recompile boot\n");
			printf("Make a new bootfloppy\n");
			return(1);
	} else if (strcmp("?",line)==0){
			callmeny();
			return(1);
	} else return(0);
}

insentry()
{
int n,index,i,entexist,valex;
char s[10],line[100],*entry,*bp;

/*	Get entry name	 						*/

	printf("name = ");
	gets(s);
	n = strlen(s);

/*	Check if entry already exist in bootcap 			*/
	
	entexist = bgetent(bootopbuf,s);

/*	Start making the new bootcap entry 				*/

	line[0]=s[0]; line[1]=s[1]; line[2]=s[2]; line[3]='|'; index=4;

	for (i=0; i<n; i++)
		line[index+i] = s[i];

	index=index+n; line[index]=':'; line[index+1]=':'; index=index+2;

	for (i=0; i<BCAPSIZE ; i++) {

		printf("%s ",bop[i]);

		if (entexist) {
			valex = outpr_ent(i);
		}
		gets(s);
		if( n = strlen(s)) {
			getnew_val(s,line,&index,i);
	        } else {
			if (entexist & valex){
				getnew_val(getbopres,line,&index,i);
			}
		}
	}
	line[index-1] ='#';

	line[index] = '\0';

/* Output new or changed entry into bootcap				*/

	i = 0;	entry = bcentry ;  bp = bootcapbuf;	
	if (entexist){
		s[0] = line[0]; s[1] = line[1]; s[2] = line[2];
	}
	while (line[i] != '\0') *entry++ = line[i++];
	while (*bp != '\0') {
		if (entexist) {
		   if ((s[0] == *bp) & (s[1] == *(bp+1)) & (s[2] == *(bp+2))) {
			while( *bp != '#') bp++;
			bp++;
		   } else {
			while (*bp != '#') *entry++ = *bp++;
			*entry++ = *bp++;
		   } 	
		} else {
			while (*bp != '#') *entry++ = *bp++;
			*entry++ = *bp++;
		} 	
	}
	*entry = '\0'; bp = bootcapbuf;
	bootcapbuf = bcentry; 
	bcentry = bp;
}
	

outpr_ent(i)
int i;
{	
char *sp,t[3];
		sp = bop[i];
		if (i < 9) {
		t[0] = *sp++; t[1] = *sp; t[2] ='\0';
			if (getbop(t)) {
				printf("%s ",getbopres);
				return(1);
			}
		 } else if (i == 9) {
			if (getbop("gs")) {
				printf("gs ");
				getbopres[0] = 'g'; getbopres[1] = 's';
				return(1);
			} else {
			   if (getbop("ws")){
				printf("ws ");
				getbopres[0] = 'w'; getbopres[1] = 's';
				return(1);
			   }
			}
		   } else if (i == 10) {
			if (getbop("su")) {
				printf("su ");
				getbopres[0] = 's'; getbopres[1] = 'u';
				return(1);
			} else {
			   if (getbop("mu")){
				printf("mu ");
				getbopres[0] = 'm'; getbopres[1] = 'u';
				return(1);	
			   }
			}
		   }
		return(0);
}
getnew_val(s,line,ind,i)
char *s,*line;
int *ind,i;
{
int j;
		   if ( i < 9 || i > 10) {
		      *(line + *ind) = *bop[i]; 
		      *(line + *ind+1) = *(bop[i]+1); 
		      *(line + *ind+2) = '='; 
		      *ind = *ind + 3;

	       	      j=0; 
		      while (*(s+j) != '\0'){
			*(line + *ind+j) = *(s+j);
			j++;
  		      }			
		      *(line + *ind+j) = ':';
		      *ind = *ind+j+1;

		   } else {
		      *(line + *ind) = *s; 
		      *(line + *ind+1) = *(s+1); 
			*(line + *ind+2) = ':';
		      *ind = *ind + 3;
		   }
}