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

📄 cmd.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic char *sccsid = "@(#)cmd.c	4.4      (ULTRIX)        4/11/91";#endif/************************************************************************ *									* *			Copyright (c) 1988 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	"crash.h"#include	<ctype.h>#include	<sys/buf.h>#include	<sys/ioctl.h>#include	<sys/param.h>#include	<sys/map.h>#include	<sys/file.h>#include	<sgtty.h>#include	<signal.h>#include	<sys/varargs.h>#include	<sys/proc.h> #include	<machine/pte.h>char *token();extern struct tsw t[];c_null(c) 	char *c;{	printf("command '%s' not known, type ? for help\n", c);	while(token() != NULL);}c_arp(c) 	char *c;{	char *arg;	int cnt;	printf("     NAME  BUCK SLOT          IPADDR        ETHERADDR     MHOLD  TIMER  FLAGS\n");	if((arg = token()) == NULL)		for(cnt=0; cnt < tab[ARP_T].ents; cnt++)			(void)prarp(cnt, 0);	else if(*arg == '-')		if((arg = token()) == NULL)			for(cnt = 0; cnt < tab[ARP_T].ents; cnt++)				(void)prarp(cnt, 1);		else			do				(void)prarp(findarp(arg), 1);	while((arg = token()) != NULL);	else		do 			(void)prarp(findarp(arg), 0);	while((arg = token()) != NULL);}#define	CURPROC	-1	/* Use the current or last process's data */c_uarea(c)	char *c;{	char *arg;	int index;	if((arg = token()) == NULL)		pruarea(CURPROC);	else do {		if((index = gt_proc_slt(arg)) != -1)			pruarea(index);	} while((arg = token()) != NULL);}c_ofile(c)	char *c;{	char *arg;	int index;   	if((arg = token()) == NULL)		profile(CURPROC);	else do {		if((index = gt_proc_slt(arg)) != -1)			profile(index);	} while((arg = token()) != NULL);}c_history(c)	char *c;{	while(token());	pr_history();}c_bufstats(c)	char *c;{	while(token());	pr_bufstats();}c_kmalloc(c)	char *c;{	while(token());	pr_kmalloc();}c_namei(c)	char *c;{	char *arg;	int index;	if((arg = token()) == NULL)		prnamei(-1);	else do {		if((index = atoi(arg)) != -1)			prnamei(index);	} while((arg = token()) != NULL);}c_dnlc(c)	char *c;{	while(token());	pr_dnlc();}c_ufile(c)	char *c;{	char *arg;	int index;	if((arg = token()) == NULL)		do_ufile(CURPROC);	else do {		if((index = gt_proc_slt(arg)) != -1)			do_ufile(index);	} while((arg = token()) != NULL);}	c_block(c)	char *c;{	char *arg;	int index;	if((arg = token()) != NULL) {		do {			index = get_gnode_slot(arg);			if(index != -1)				prblocks(index);		} while((arg = token()) != NULL);	}}c_ps(c)	char *c;{	char *arg;	int index, cnt, done=0;	if((arg = token()) == NULL) {		ps_hdr();		for (cnt=0; cnt<tab[PROC_T].ents; cnt++)			do_ps(cnt);	}	else {		if (strcmp(arg,"-uid") == 0) {			do {				int uid;				arg = token();				sscanf(arg,"%d",&uid);				for (cnt=0; cnt<tab[PROC_T].ents; cnt++) 					if (proctab[cnt].p_uid == uid)						do_ps(cnt);			} while((arg = token()) != NULL);			return;		}		do {			if((index = gt_proc_slt(arg)) != -1) {				if(done++ == 0)					ps_hdr();				do_ps(index);			}		}		while((arg = token()) != NULL);	}}c_pcblk(c)	char *c;{	char *arg;	int index;	/* Uses the Process Table Slot */	if((arg = token()) == NULL)		prpcb(CURPROC);	else do {		if((index = gt_proc_slt(arg)) != -1)			prpcb(index);	} while((arg = token()) != NULL);}c_stack(c)	char *c;{	char *arg;	int index;	if((arg = token()) == NULL)		prstack(CURPROC);	else do {		if((index = gt_proc_slt(arg)) != -1)			prstack(index);	} while((arg = token()) != NULL);}c_trace(c)	char *c;{	char *arg;	int index, cpu, r;	if((arg=token()) == NULL) {		prtrace(0,CURPROC, 0);		fflush(stdout);		return;	}	if(arg[0] == '-') {		if (strcmp(arg,"-sym") == 0) {			r = -1;	/* wants vars */		} else {			r = 1;		}		arg = token();	} else		r = 0;			if (strcmp(arg,"-all") == 0) {		for (index=0; index<tab[PROC_T].ents; index++) {			if(proctab[index].p_stat == SIDL)				continue;			printf("Trace - proc %d pid %d uid %d\n",			       index, proctab[index].p_pid, 			       proctab[index].p_uid);			prtrace(r, index, 0); 		}		return;	}	if(arg[0] == '#') {		if (arg[1] == '\0')			arg = token();		else			arg++;		cpu = atoi(arg);		prtrace(r,CURPROC, cpu);		return;	}			if(arg == NULL)		prtrace(r,CURPROC, 0);	else do {		if((index = gt_proc_slt(arg)) != -1)			prtrace(r, index, 0);	} while((arg = token()) != NULL);}c_files(c)	char *c;{	char *arg;	int index, cnt, done=0;	if((arg = token()) == NULL) {		pr_filehdr();					for(cnt = 0; cnt < tab[FILE_T].ents; cnt++)			prfile(cnt, 0);	} else {		do {			index = get_file_slot(arg);			if(index != -1) {				if(done++ == 0)					pr_filehdr();				prfile(index, 1);			}		} while((arg = token()) != NULL);	}}c_clntrpc(c)	char *c;{	char *arg;	int index, cnt, done=0;	if((arg = token()) == NULL) {		prclienthd();		for(cnt = 0; cnt < MAXCLIENTS; cnt++)			prclient(cnt, 0);	} else {		done=0;		do {			index = get_file_slot(arg);			if(index != -1) {				if(done++ == 0)					prclienthd();				prclient(index, 1);			}		} while((arg = token()) != NULL);	}}c_rpcxprt(c)	char *c;{	char *arg;	int index;	unsigned int addr;	if ((arg= token()) == NULL) {		printf("usage: svcxprt addr\n");		return;	}	addr = scan_vaddr(arg);	pr_svcxprt(addr);}c_svcreq(c)	char *c;{	char *arg;	int index;	unsigned int addr;	if ((arg= token()) == NULL) {		printf("usage: svcreq addr\n");		return;	}	addr = scan_vaddr(arg);	pr_svcreq(addr);}c_udpdata(c)	char *c;{	char *arg;	int index;	unsigned int addr;	if ((arg= token()) == NULL) {		printf("usage: udpdata addr\n");		return;	}	addr = scan_vaddr(arg);	pr_udpdata(addr);}c_socket(c)	char *c;{	char *arg;	int index, cnt, r, done=0;	unsigned int addr;	if((arg = token()) == NULL) {		pr_sockhdr();					for(cnt = 0; cnt < tab[FILE_T].ents; cnt++)			prsock(cnt, 0, 0);			return;	}	if(arg[0] == '-') {		r = 1;	/* wants details */	} else		r = 0;	if((arg = token()) == NULL) {		pr_sockhdr();		for(cnt = 0; cnt < tab[FILE_T].ents; cnt++)			prsock(cnt, 0, r);		return;	} else {		do {			index = get_file_slot(arg);			if(index != -1) {				if(done++ == 0)					pr_sockhdr();				prsock(index, 1, r);			}		} while((arg = token()) != NULL);	}}c_rnode(c)	char *c;{	char *arg;	int index, cnt, done=0;	unsigned int addr;	if((arg = token()) == NULL) {		printrnodehd();		for(cnt=0; cnt < tab[GNODE_T].ents; cnt++)			prvnode(cnt, 0);	} else if (*arg == '-')		if ((arg = token()) == NULL) {			printrnodehd();			for(cnt=0;cnt<tab[GNODE_T].ents;cnt++)				prvnode(cnt, 1);		} else {			do {				index = get_gnode_slot(arg);				if(index != -1) {					if(done++ == 0)						printrnodehd();					prvnode(index, 1);				}			} while((arg=token()) != NULL);		}	else {		do {			index = get_gnode_slot(arg);			if(index != -1) {				if(done++ == 0)					(void)printrnodehd();				prvnode(index, 0);			} 		} while((arg = token()) != NULL);	}}c_mntinfo(c)	char *c;{	char *arg;	int index, done=0;	unsigned int addr;	if((arg = token()) == NULL)		printf("Usage: mi <mounttab slot>\n");	else {		done = 0;		do {			index = get_mount_slot(arg);			if(index != -1) {				if (done++ == 0)					(void)printmntinfohd();				prmntinfo(index);			}		} while((arg = token()) != NULL);	}}c_bufgp(c)	char *c;{	char *arg;	int index, done=0;	unsigned int addr;	if((arg = token()) == NULL) {		printf("Usage: bufgp <gno slot>\n");		return;	}	do {		index = get_buf_slot(arg);		if(index != -1) {			if(done++ == 0)				(void)printbufhd();			do_bufgp(index);		}	} while((arg = token()) != NULL);}c_gnode(c)	char *c;{	char *arg;	int index, detail, cnt, done=0;	unsigned int addr;		detail = 1;	if((arg = token()) == NULL) {		(void)printgnodehd();		/* print all valid gnodes */		for(cnt=0; cnt < tab[GNODE_T].ents; cnt++)			prgnode(cnt, 0, -1, detail);		return;	}	if (strcmp(arg,"-lock") == 0) {		detail = 2;		arg = token();	}	if (strcmp(arg,"-all") == 0) {		detail = 3;		arg = token();	}		if(*arg == '-') {		if (strcmp(arg,"-") == 0) {			if ((arg = token()) == NULL) {				printgnodehd();				/* print ALL gnodes */				for(cnt = 0;				    cnt < tab[GNODE_T].ents;				    cnt++)					prgnode(cnt, 1, -1, detail);			}			else {				/* print ALL asked for slots */				do {					index = get_gnode_slot(arg);					if(index != -1) {						if(done++ == 0)							printgnodehd();						prgnode(index, 1, -1, 							detail);					}									} while((arg = token()) != NULL);				return;			}		}		else if (strcmp(arg,"-maj") == 0) {			int maj;			if((arg = token()) == NULL) {				printf("-maj requires dev\n");				return;			}			printgnodehd();			sscanf(arg,"%x",&maj);			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 2, maj, detail);					}		else if (strcmp(arg,"-min") == 0) {			int min;			if((arg = token()) == NULL) {				printf("-min require dev\n");				return;			}			printgnodehd();			sscanf(token(),"%x",&min);			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 3, min, detail);		}		else if (strcmp(arg,"-fs") == 0) {			int filesys;			if((arg = token()) == NULL) {				printf("-fs requires mount slot\n");				return;			}			if(isdigit(*arg))				filesys = atoi(arg);			else {				printf("%s is an invalid token\n",				       arg);				while(token());				return;			}			printgnodehd();			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 4, filesys, detail);		}		else if (strcmp(arg,"-gno") == 0) {			int gno;			if((arg = token()) == NULL) {				printf("-gno requires gnode\n");				return;			}			gno = get_gnode_slot(arg);			if(gno == -1) {				printf("'%s' bad\n", arg);				while(token());				return;			}			printgnodehd();			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 5, gno, detail);		}		else if (strcmp(arg,"-uid") == 0) {			int uid;			if((arg = token()) == NULL) {				printf("-uid requires uid\n");				return;			}			if(isdigit(*arg))				uid = atoi(arg);			else {				printf("%s is an invalid token\n",				       arg);				while(token());				return;			}			printgnodehd();			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 6, uid, detail);		}		else if (strcmp(arg,"-gid") == 0) {			int gid;			if((arg = token()) == NULL) {				printf("-gid requires gid\n");				return;			}			if(isdigit(*arg))				gid = atoi(arg);			else {				printf("%s is an invalid token\n",				       arg);				while(token());				return;			}			printgnodehd();			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 7, gid, detail);		}		else if (strcmp(arg,"-lmod") == 0) {			int mode;			if((arg = token()) == NULL) {				printf("-lmod requires lower modes\n");				return;			}			printgnodehd();			sscanf(arg,"%o",&mode);			if (mode > 0777) {				printf("bad mode\n");				while(token()!=NULL);				return;			}			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 8, mode, detail);		}		else if (strcmp(arg,"-hmod") == 0) {			int mode;			if((arg = token()) == NULL) {				printf("-hmod requires high modes\n");				return;			}			printgnodehd();			sscanf(arg,"%o",&mode);			if (mode & 0777) {				printf("bad mode\n");				while(token()!=NULL);				return;			}			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 9, mode);		}		else if (strcmp(arg,"-amod") == 0) {			int mode;			if((arg = token()) == NULL) {				printf("-amod requires absolute modes\n");				return;			}			printgnodehd();			sscanf(arg,"%o",&mode);			for(cnt = 0; cnt < tab[GNODE_T].ents;			    cnt++)				prgnode(cnt, 10, mode, detail);		}		else printf("bad arg\n");	}	else {		/* print gnode slots asked for */		do {			index = get_gnode_slot(arg);			if(index != -1) {				if(done++ == 0)					printgnodehd();				prgnode(index, 1, -1, detail);			}		} while((arg = token()) != NULL);		return;	}	while(token()!=NULL);}c_gnofree(c)	char *c;{	char *arg;	int index, detail;	unsigned int addr;	printgnodehd();	prgnodelist((struct gnode *)(Gfree.s_value), detail);	while(token() != NULL);}c_gnolock(c)	char *c;{	char *arg;	int index, cnt, detail;	unsigned int addr;	printgnodehd();	for(cnt = 0; cnt < tab[GNODE_T].ents; cnt++)		prgnode(cnt, 11, 0, detail);}c_gnorefs(c)	char *c;{	char *arg;	int index;	unsigned int addr;	arg = token();	if (arg==NULL)		return;	do {		index = get_gnode_slot(arg);		if(index != -1) {			pr_gref(index);			}	} while((arg = token()) != NULL);}c_dupreq(c)	char *c;{	char *arg;	int index;	unsigned int addr;	prdupreq();	while(token() != NULL);}c_mbuf(c)	char *c;{	char *arg;	int index;	unsigned int addr;	arg = token();	if (arg == NULL)		goto mbuf_usage;	addr = scan_vaddr(arg);	prmbuf_chain(addr);	return;mbuf_usage:	printf("usage: mbuf addr\n");}c_inpcb(c)	char *c;{	char *arg;	int index;	unsigned int addr;	arg = token();	if (arg == NULL) {		printf("\nUDP:\n");		readsym(symsrch("_udb"), &addr, sizeof(addr));		prinpcb(addr);		printf("\nTCP:\n");		readsym(symsrch("_tcb"), &addr, sizeof(addr));		prinpcb(addr);		return;	}	if (strcmp(arg,"-udp") == 0) {			readsym(symsrch("_udb"), &addr, sizeof(addr));		prinpcb(addr);	}	if (strcmp(arg,"-tcp") == 0) {		readsym(symsrch("_tcb"), &addr, sizeof(addr));		prinpcb(addr);	}}c_cred(c)	char *c;{	char *arg;	int index, done=0;	unsigned int addr;	done = 0;	arg = token();	if(arg == NULL) {		printf("cred needs addr\n");		return;	}	do {		if(done++ == 0)			pr_credhdr();					addr = scan_vaddr(arg);		(void)print_cred(addr);

⌨️ 快捷键说明

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