Пример #1
0
void
ccb_stat(int ac, char **av)
{
	struct si_pstat sip;
#define	CCB	sip.tc_ccb

	if (ac != 0)
		prusage(U_STAT_CCB, 1);
	sip.tc_dev = tc.tc_dev;
	if (ioctl(ctlfd, TCSI_CCB, &sip) < 0)
		err(1, "TCSI_CCB on %s", Devname);
	printf("%s: ", Devname);

							/* WORD	next - Next Channel */
							/* WORD	addr_uart - Uart address */
							/* WORD	module - address of module struct */
	printf("\tuart_type 0x%x\n", CCB.type);		/* BYTE type - Uart type */
							/* BYTE	fill - */
	printf("\tx_status 0x%x %s\n", CCB.x_status, s_xstat(CCB.x_status));	/* BYTE	x_status - XON / XOFF status */
	printf("\tc_status 0x%x %s\n", CCB.c_status, s_cstat(CCB.c_status));	/* BYTE	c_status - cooking status */
	printf("\thi_rxipos 0x%x\n", CCB.hi_rxipos);	/* BYTE	hi_rxipos - stuff into rx buff */
	printf("\thi_rxopos 0x%x\n", CCB.hi_rxopos);	/* BYTE	hi_rxopos - stuff out of rx buffer */
	printf("\thi_txopos 0x%x\n", CCB.hi_txopos);	/* BYTE	hi_txopos - Stuff into tx ptr */
	printf("\thi_txipos 0x%x\n", CCB.hi_txipos);	/* BYTE	hi_txipos - ditto out */
	printf("\thi_stat 0x%x %s\n", CCB.hi_stat, s_stat(CCB.hi_stat));/* BYTE	hi_stat - Command register */
	printf("\tdsr_bit 0x%x\n", CCB.dsr_bit);		/* BYTE	dsr_bit - Magic bit for DSR */
	printf("\ttxon 0x%x\n", CCB.txon);		/* BYTE	txon - TX XON char */
	printf("\ttxoff 0x%x\n", CCB.txoff);		/* BYTE	txoff - ditto XOFF */
	printf("\trxon 0x%x\n", CCB.rxon);		/* BYTE	rxon - RX XON char */
	printf("\trxoff 0x%x\n", CCB.rxoff);		/* BYTE	rxoff - ditto XOFF */
	printf("\thi_mr1 0x%x %s\n", CCB.hi_mr1, s_mr1(CCB.hi_mr1));		/* BYTE	hi_mr1 - mode 1 image */
	printf("\thi_mr2 0x%x %s\n", CCB.hi_mr2, s_mr2(CCB.hi_mr2));		/* BYTE	hi_mr2 - mode 2 image */
        printf("\thi_csr 0x%x in:%s out:%s\n", CCB.hi_csr, s_clk(CCB.hi_csr >> 4), s_clk(CCB.hi_csr));		/* BYTE	hi_csr - clock register */
	printf("\thi_op 0x%x %s\n", CCB.hi_op, s_op(CCB.hi_op));		/* BYTE	hi_op - Op control */
	printf("\thi_ip 0x%x %s\n", CCB.hi_ip, s_ip(CCB.hi_ip));		/* BYTE	hi_ip - Input pins */
	printf("\thi_state 0x%x %s\n", CCB.hi_state, s_state(CCB.hi_state));	/* BYTE	hi_state - status */
	printf("\thi_prtcl 0x%x %s\n", CCB.hi_prtcl, s_prtcl(CCB.hi_prtcl));	/* BYTE	hi_prtcl - Protocol */
	printf("\thi_txon 0x%x\n", CCB.hi_txon);		/* BYTE	hi_txon - host copy tx xon stuff */
	printf("\thi_txoff 0x%x\n", CCB.hi_txoff);	/* BYTE	hi_txoff - */
	printf("\thi_rxon 0x%x\n", CCB.hi_rxon);		/* BYTE	hi_rxon - */
	printf("\thi_rxoff 0x%x\n", CCB.hi_rxoff);	/* BYTE	hi_rxoff - */
	printf("\tclose_prev 0x%x\n", CCB.close_prev);	/* BYTE	close_prev - Was channel previously closed */
	printf("\thi_break 0x%x %s\n", CCB.hi_break, s_break(CCB.hi_break));	/* BYTE	hi_break - host copy break process */
	printf("\tbreak_state 0x%x\n", CCB.break_state);	/* BYTE	break_state - local copy ditto */
	printf("\thi_mask 0x%x\n", CCB.hi_mask);		/* BYTE	hi_mask - Mask for CS7 etc. */
	printf("\tmask_z280 0x%x\n", CCB.mask_z280);	/* BYTE	mask_z280 - Z280's copy */
							/* BYTE	res[0x60 - 36] - */
							/* BYTE	hi_txbuf[SLXOS_BUFFERSIZE] - */
							/* BYTE	hi_rxbuf[SLXOS_BUFFERSIZE] - */
							/* BYTE	res1[0xA0] - */
}
Пример #2
0
void
port_stat(int ac, char **av)
{
	struct si_pstat sip;
#define	PRT	sip.tc_siport

	if (ac != 0)
		prusage(U_STAT_PORT, 1);
	sip.tc_dev = tc.tc_dev;
	if (ioctl(ctlfd, TCSI_PORT, &sip) < 0)
		err(1, "TCSI_PORT on %s", Devname);
	printf("%s: ", Devname);

	printf("\tsp_pend 0x%x %s\n", PRT.sp_pend, s_stat(PRT.sp_pend));
	printf("\tsp_last_hi_ip 0x%x %s\n", PRT.sp_last_hi_ip, s_ip(PRT.sp_last_hi_ip));
	printf("\tsp_state 0x%x %s\n", PRT.sp_state, sp_state(PRT.sp_state));
	printf("\tsp_delta_overflows 0x%d\n", PRT.sp_delta_overflows);
}
Пример #3
0
pid_t*
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf,
			gint64 which, gint64 arg)
{
	DIR *proc;
	struct dirent *entry;
	char buffer [BUFSIZ];
	unsigned count, total, pid = 0, mask;
	pid_t pids [BLOCK_COUNT], *pids_chain = NULL;
	unsigned pids_size = 0, pids_offset = 0, new_size;
	struct stat statb;
	int len, ok;

	memset (buf, 0, sizeof (glibtop_proclist));
	mask = which & ~GLIBTOP_KERN_PROC_MASK;
	which &= GLIBTOP_KERN_PROC_MASK;

	/* Check if the user wanted only one process */

	if(which == GLIBTOP_KERN_PROC_PID)
	{
	   if(mask)
	   {
#ifdef HAVE_PROCFS_H
	      struct psinfo psinfo;
#else
	      struct prpsinfo psinfo;
#endif
	      if(glibtop_get_proc_data_psinfo_s(server, &psinfo, pid))
		 return NULL;
	      if(mask & GLIBTOP_EXCLUDE_IDLE && !psinfo.pr_pctcpu)
		 return NULL;
	      if(mask & GLIBTOP_EXCLUDE_SYSTEM && psinfo.pr_flag & SSYS)
		 return NULL;
	      if(mask & GLIBTOP_EXCLUDE_NOTTY && psinfo.pr_ttydev == PRNODEV)
		 return NULL;
	   }
	   else
	   {
	      sprintf(buffer, "/proc/%lld", arg);
	      if(s_stat(buffer, &statb) < 0)
		 return NULL;
	   }
	   pids_chain = g_malloc(sizeof(pid_t));
	   *pids_chain = pid;
	   return pids_chain;
	}

	proc = opendir ("/proc");
	if (!proc) return NULL;

	/* read every every entry in /proc */

	for (count = total = 0, entry = readdir (proc);
	     entry; entry = readdir (proc)) {
		ok = 1; len = strlen (entry->d_name);

		/* does it consist entirely of digits? */
		/* It does, except for "." and "..". Let's speed up */

		if(entry->d_name[0] == '.')
		   continue;

		/* convert it in a number */
		pid = (unsigned)atol(entry->d_name);

#ifdef HAVE_PROCFS_H

		/* Can we skip it based on the request? We have
		   RUID and RGID in struct stat. But we can't do it
		   like this for LP64 process, because stat() will fail.
		   XXX Unimplemented for now */

		if(!mask && which == GLIBTOP_KERN_PROC_RUID)
		{
		   sprintf (buffer, "/proc/%d", pid);
		   if (s_stat (buffer, &statb)) continue;

		   if (!S_ISDIR (statb.st_mode)) continue;

		   if(statb.st_uid != arg) continue;
		}

		if(mask || which != GLIBTOP_KERN_PROC_ALL)
		{
		   struct psinfo psinfo;

		   if(glibtop_get_proc_data_psinfo_s(server, &psinfo, pid))
		      continue;
		   if(mask)
		   {
		      if(mask & GLIBTOP_EXCLUDE_IDLE && !psinfo.pr_pctcpu)
			 continue;
		      if(mask & GLIBTOP_EXCLUDE_SYSTEM && psinfo.pr_flag & SSYS)
			 continue;
		      if(mask & GLIBTOP_EXCLUDE_NOTTY
			 && psinfo.pr_ttydev == PRNODEV)
			 continue;
		   }
		   switch(which)
		   {
		      case GLIBTOP_KERN_PROC_PGRP:    if(psinfo.pr_pgid != arg)
						         continue;
						      break;
		      case GLIBTOP_KERN_PROC_SESSION: if(psinfo.pr_sid != arg)
							 continue;
						      break;
		      case GLIBTOP_KERN_PROC_TTY:    if(psinfo.pr_ttydev != arg)
						         continue;
						      break;
		      case GLIBTOP_KERN_PROC_UID:     if(psinfo.pr_euid != arg)
							 continue;
						      break;
		      case GLIBTOP_KERN_PROC_RUID:    if(psinfo.pr_uid != arg)
						         continue;
						      break;
		      default:			      break;
		   }
		}
#endif
		/* Fine. Now we first try to store it in pids. If this buffer is
		 * full, we copy it to the pids_chain. */

		if (count >= BLOCK_COUNT) {
			/* The following call to g_realloc will be
			 * equivalent to g_malloc () if `pids_chain' is
			 * NULL. We just calculate the new size and copy `pids'
			 * to the beginning of the newly allocated block. */

			new_size = pids_size + BLOCK_SIZE;

			pids_chain = g_realloc (pids_chain, new_size);

			memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE);

			pids_size = new_size;

			pids_offset += BLOCK_COUNT;

			count = 0;
		}

		/* pids is now big enough to hold at least one single pid. */

		pids [count++] = pid;

		total++;
	}

	s_closedir (proc);

	/* count is only zero if an error occured (one a running Linux system,
	 * we have at least one single process). */

	if (!count) return NULL;

	/* The following call to g_realloc will be equivalent to
	 * g_malloc if pids_chain is NULL. We just calculate the
	 * new size and copy pids to the beginning of the newly allocated
	 * block. */

	new_size = pids_size + count * sizeof (pid_t);

	pids_chain = g_realloc (pids_chain, new_size);

	memcpy (pids_chain + pids_offset, pids, count * sizeof (pid_t));

	pids_size = new_size;

	pids_offset += BLOCK_COUNT;

	/* Since everything is ok now, we can set buf->flags, fill in the
	 * remaining fields and return the `pids_chain'. */

	buf->flags = _glibtop_sysdeps_proclist;

	buf->size = sizeof (pid_t);
	buf->number = total;

	buf->total = buf->number * buf->size;

	return pids_chain;
}