⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 finder.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 3 页
字号:
#ifndef lintstatic	char	*sccsid = "@(#)finder.c	4.6	(ULTRIX)	10/9/90";#endif lint/************************************************************************ *									* *			Copyright (c) 1986 by				* *		Digital Equipment Corporation, Maynard, MA		* *			All rights reserved.				* *									* *   This software is furnished under a license and may be used and	* *   copied  only  in accordance with the terms of such license and	* *   with the  inclusion  of  the  above  copyright  notice.   This	* *   software  or  any  other copies thereof may not be provided or	* *   otherwise made available to any other person.  No title to and	* *   ownership of the software is hereby transferred.			* *									* *   This software is  derived  from  software  received  from  the	* *   University    of   California,   Berkeley,   and   from   Bell	* *   Laboratories.  Use, duplication, or disclosure is  subject  to	* *   restrictions  under  license  agreements  with  University  of	* *   California and with AT&T.						* *									* *   The information in this software is subject to change  without	* *   notice  and should not be construed as a commitment by Digital	* *   Equipment Corporation.						* *									* *   Digital assumes no responsibility for the use  or  reliability	* *   of its software on equipment which is not supplied by Digital.	* *									* ************************************************************************/#include <ctype.h>#include <stdio.h>#include <nlist.h>#include <signal.h>#include <sys/ioctl.h>#include <sys/file.h>#include <sys/types.h>#include <sys/devio.h>#include <sys/mtio.h>#include <sys/dkio.h>#include <sys/param.h>#include <machine/cpuconf.h>#ifdef vax#include <machine/rpb.h>#endif vax#ifdef mips#include <machine/entrypt.h>#include <sys/sysinfo.h>#endif mips#define 	MAXDEVICES	300	/* maximum number of devs to find  */#define		MAXDISKS	32	/* maximum number of non-ra disks  */#define		MAX_RA_DISKS	256	/* maximum number of ra disks      */#define		MAXTAPES	32	/* maximum number of any tape type */#define		RA_BASE_MAJOR	60	/* Base major number for ra char dev */#define SUPPORTED_ROOT  	0	/* Dev supported for root installs   */#define UNSUPPORTED_ROOT	1	/* Dev unsupported for root installs */#define DEF_A_PARTITION		32768	/* Size of a default "a" partition   */#define DEF_B_PARTITION		50160	/* Size of a default "b" partition   */#define MIN_CAPACITY		(DEF_A_PARTITION + DEF_B_PARTITION)/* * ra disks can occupy a range of major numbers.  For this reason the unit * number is held in both the major and minor numbers; not just the upper 5 * bits of the minor number as before.  Each major number represents 32 disks. * For this reason the major number is the base major number added to the * div by 32 to determine which "set" if 32 disks is referenced.  The minor * number is which disk within the "set" of 32 and is the mod of 32 shifted * left by 3 bits because the low 3 bits represent partition. */#define RAMAJOR(index, base)    ((index/32) + base)#define RAMINOR(index)          ((index%32) * 8)#define maketape(x,y)	((dev_t)(((x)<<8)  | ((((y&0xfc)<<3) | (y&3)))))struct d {	char *type;			/* Ultrix name of device */	int majnum;			/* major number of device */};struct d roots [] =			/* disks that can be root devices */	 {	"ra",   RA_BASE_MAJOR,	"rz",   56,#ifdef vax 	"hp",	4,	"rd",	47,#endif vax	"\0",   -1	 };struct d installs [] =			/* install devices */	{	"ra",   RA_BASE_MAJOR,	"tms",  36,	"rz",   56,#ifdef vax	"tu",	5,	"ts",	16,	"mu",	19,	"st",	46,	"tz",	55,#endif vax	"\0",   -1	};struct d disks [] =			/* all disk devices */	{	"ra",   RA_BASE_MAJOR,	"rz",   56,#ifdef vax	"hp",	4,	"rd",	47,#endif vax	"\0",   -1	};struct f {	char type[20];			/* device type (TU77,RA60...) */	char name[20];			/* Ultrix name */	char interface[20];		/* controller name (HSC70,UDA50) */	int unit;			/* Unit number assigned by kernel */	int plug;			/* physical plug number */	int link;			/* number of controller is linked to */	int linktype;			/* bus type */	int trlevel;			/* TR level or BI node number */	int adpt_num;			/* BI number or SBI number*/	short rctlr_num;		/* remote controller number,i.e. hsc #*/};int FMAX = 0;int supported_root();struct f found[MAXDEVICES];		/* devices found */struct devget dev_info;			/* IOCTL structure *//* * The following is a list of devices which are not supported as root * installation devices. */char *unsupported_roots[] = {	"RX",		/* Floppy - too small			*/	"RD31",		/* Disk - too small			*/	"RD32",		/* Disk - too small			*/	"RD51",		/* Disk - too small			*/	"RD52",		/* Disk - too small			*/	"RZ22",		/* Disk - too small			*/	"ESE20",	/* Limited number of power hits problem	*/	"RRD",		/* Read-only media			*/	""		/* Terminating element in the array	*/};#ifdef vaxstruct rpb rpb;#endif vaxchar *header0, *getenv();static char header1[]="Selection   Device     ULTRIX     Device       Controller   Controller ";static char header2[]="            Name       Name       Number       Name         Number     ";static char header3[]="---------------------------------------------------------------------- ";/**************************************************************************//* FINDER:								  *//*		This routine finds all the devices that can be used as    *//*	installation devices,root devices, or all disks.  It searches for *//*	devices in the previously defined in the structures.  A system    *//*	call, using mknod, is issued to create a device special file for  *//*	each device.  The special file is then opened and an ioctl call   *//*	is issued to the device.  Information returned is stored in the   *//*	'found' structure and is printed after the device list has been   *//*	exhausted.							  *//* 									  *//**************************************************************************//*  Modification History						  *//*									  */	/*  000 - July,   1986	- Bob Fontaine created				  *//*									  *//*  001 - August, 1986  - Bob Fontaine					  */	/*   		Added the message for boot command.			  *//*  									  *//*  002 - August 14, 1986 -  Tungning Cherng				  *//*		Added the -f flag to reduce the redundant check in order  *//*			to have a faster output.		          *//*									  */	/*  003 - Mar 9, 1987 - Tungning Cherng					  *//*		Added the CVAX cpu support.				  *//*									  */	/*  004 - July 9, 1987 - Tungning Cherng				  *//*		RD51,RD52 and RD31 not for system disk, only data disk.	  *//*									  */	/*  005 - June,7,1988 - Tungning cherng					  *//* 		Supported the C_VAXSTAR(VAX420), and VAX8820.	  	  *//* 		Supported the RZ23 disk, RRDxx cdrom, and TZ30 tape.	  *//*  									  *//*  006 - May 11, 1989 - Tim Burke					  *//*		Allow more than 32 "ra" type disks.  Change major	  *//*		number of "ra"						  *//*									  *//*  007 - May 31, 1989 - Jon Wallace					  *//*		New User interface that allows paging through disk	  *//*		selections of more than 16 disks.			  *//*									  *//*  008 - Jun 27, 1989 - Jon Wallace					  *//*		Added ULTRIX name to user menu, and discontinued	  *//*		TA90 support per Tim Burke.				  *//*									  *//*  009 - Sep 13, 1989 - Tim Burke                                        *//*              Added the supported_root routine.  This determines if     *//*              the disk qualifies as a supported system disk.            *//*									  *//*  010 - Nov 09, 1989 - Jon Wallace					  *//*		Added -w option that looks to see if the console	  *//*		device is graphic or not				  *//*									  *//*  011 - Jul 05, 1909 - Pete Keilty					  *//*		Added new DEV_BICI and DEV_XMICI defines.		  *//*		This informs which bus the CI is on and booting from.	  *//*									  *//*  012 - Aug 31, 1990 - Jon Wallace					  *//*		Added new rom support for DS5000 machines with code	  *//*		from Joe Szczypek					  *//*									  *//*  013 - Sep 07, 1990 - Ali Rafieymehr					  *//*		Added support for the VAX9000.				  *//*									  *//*  014 - Oct 09, 1990 - Joe Szczypek					  *//*		Corrected new ROM support.				  *//*									  *//**************************************************************************/main(argc,argv)int argc;char *argv[];{        int answer, anschk, fflag=0, rflag=0;        int COUNTER=0, ERR_FLAG=0, PAGE_FLAG=0;        char ans[8], line[128];        register int i;        FILE *fp1, *fp2;        char *path1="/tmp/finder.tab";        char *path2="/tmp/finder.dev";        header0=getenv("ROUTINE");	switch(argv[1][1])	{		case 'i':			getinstalls();			break;		case 'r':			getroots();			rflag++;			break;		case 'd':			getdisks();			break;		case 'f':			/* to reduce redundant check, show the previous form */			fflag++;			break;		case 'w':			/* find out if the machine has graphics capability */			getwscons();			exit(0);		default:			fprintf(stderr,"usage: finder -[irdfw]\n");			break;	}	if(FMAX == 0 && fflag==0)	{		exit(-1);	}	if (fflag==0)	{		if ((fp1=fopen(path1,"w"))==NULL)		{			fprintf(stderr,"open %s failed\n",path1);			exit(-1);		}		if ((fp2=fopen(path2,"w"))==NULL)		{			fprintf(stderr,"open %s failed\n",path2);			exit(-1);		}		for(i=0;i<FMAX;i++)		{			fprintf(fp1,"   %2d       %-10s ",i+1,found[i].type);			fprintf(fp1,"%3s%-3d     ",found[i].name,found[i].unit);			fprintf(fp1," %3d         ",found[i].plug);			fprintf(fp1,"%-10s   %3d\n",found[i].interface,found[i].link);			fprintf(fp2,"%s %s %d\n",found[i].type,found[i].name,found[i].unit);		}		fclose(fp1);		fclose(fp2);	}	if ((fp1=fopen(path1,"r"))==NULL)	{		fprintf(stderr,"read %s failed\n",path1);		exit(-1);	}	if ((fp2=fopen(path2,"r"))==NULL)	{		fprintf(stderr,"read %s failed\n",path2);		exit(-1);	}	answer = 0;	for (;;)	{		fprintf(stderr, "\n%s TABLE \n\n", header0);                Headeroutine();                for (COUNTER=0, FMAX=0; fgets(line, sizeof(line), fp1)!=NULL; COUNTER++, FMAX++)                {                        if (COUNTER==16)                        {                                fprintf(stderr, "%s\n", header3);                                ERR_FLAG=Multipage_routine(ans, ERR_FLAG);                                answer=atoi(gets(ans));                                if ( *ans == '\0' )                                {                                        COUNTER=0;                                        fprintf(stderr, "\n\n%s TABLE \n\n", header0);                                         Headeroutine();                                }                                else                                {                                        PAGE_FLAG=1;                                        break;                                }                        }                        fprintf(stderr,"%s",line);                }                if (PAGE_FLAG == 0)                {                        fprintf(stderr, "%s\n", header3);                        ERR_FLAG=Unipage_routine(ERR_FLAG, FMAX);                        answer=atoi(gets(ans));                        if ( *ans == '\0' )                        {                                if ( FMAX <= 16 )                                        ERR_FLAG=1;                                else                                        ERR_FLAG=0;                                PAGE_FLAG=0;                                (void) rewind(fp1);                                continue;                        }                }                anschk=choicechk(ans);                if(FMAX < answer || answer <= 0 || anschk == 0)                        ERR_FLAG=1;                else                {			answer--;			break;                }                PAGE_FLAG=0;                (void) rewind(fp1);        }        fclose(fp1);	for (i=0; fgets(line,sizeof(line),fp2)!=NULL && i!=answer; i++)		;	printf("%s",line);	fclose(fp2);		if (rflag)		showboot(answer);	exit(0);}/**************************************************************************/Headeroutine()                          /* User Interface headers/titles */{        fprintf(stderr, "%s\n", header1);        fprintf(stderr, "%s\n", header2);        fprintf(stderr, "%s\n", header3);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -