Add sysctls to read tk_{nin,nout,cancc,rawcc} (under a kern.tkstat node).
"extern" those variables in <sys/dkstat.h>, and add declarations for them in sys/tty.c
This commit is contained in:
parent
38691fa87a
commit
bfc71f3c10
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_sysctl.c,v 1.99 2002/01/27 13:33:36 lukem Exp $ */
|
||||
/* $NetBSD: kern_sysctl.c,v 1.100 2002/01/28 02:06:02 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -43,7 +43,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.99 2002/01/27 13:33:36 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.100 2002/01/28 02:06:02 simonb Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_insecure.h"
|
||||
|
@ -110,6 +110,7 @@ static int sysctl_sysvipc(int *, u_int, void *, size_t *);
|
|||
#endif
|
||||
static int sysctl_msgbuf(void *, size_t *);
|
||||
static int sysctl_doeproc(int *, u_int, void *, size_t *);
|
||||
static int sysctl_dotkstat(int *, u_int, void *, size_t *, void *);
|
||||
#ifdef MULTIPROCESSOR
|
||||
static int sysctl_docptime(void *, size_t *, void *);
|
||||
static int sysctl_ncpus(void);
|
||||
|
@ -333,6 +334,7 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
|||
case KERN_PROC_ARGS:
|
||||
case KERN_SYSVIPC_INFO:
|
||||
case KERN_PIPE:
|
||||
case KERN_TKSTAT:
|
||||
/* Not terminal. */
|
||||
break;
|
||||
default:
|
||||
|
@ -558,6 +560,9 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
|||
}
|
||||
return (error);
|
||||
}
|
||||
case KERN_TKSTAT:
|
||||
return (sysctl_dotkstat(name + 1, namelen - 1, oldp, oldlenp,
|
||||
newp));
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
|
@ -1882,3 +1887,29 @@ sysctl_pty(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
|
|||
return (error);
|
||||
}
|
||||
#endif /* NPTY > 0 */
|
||||
|
||||
static int
|
||||
sysctl_dotkstat(name, namelen, where, sizep, newp)
|
||||
int *name;
|
||||
u_int namelen;
|
||||
void *where;
|
||||
size_t *sizep;
|
||||
void *newp;
|
||||
{
|
||||
/* all sysctl names at this level are terminal */
|
||||
if (namelen != 1)
|
||||
return (ENOTDIR); /* overloaded */
|
||||
|
||||
switch (name[0]) {
|
||||
case KERN_TKSTAT_NIN:
|
||||
return (sysctl_rdquad(where, sizep, newp, tk_nin));
|
||||
case KERN_TKSTAT_NOUT:
|
||||
return (sysctl_rdquad(where, sizep, newp, tk_nout));
|
||||
case KERN_TKSTAT_CANCC:
|
||||
return (sysctl_rdquad(where, sizep, newp, tk_cancc));
|
||||
case KERN_TKSTAT_RAWCC:
|
||||
return (sysctl_rdquad(where, sizep, newp, tk_rawcc));
|
||||
default:
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty.c,v 1.129 2001/11/12 15:25:27 lukem Exp $ */
|
||||
/* $NetBSD: tty.c,v 1.130 2002/01/28 02:06:03 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1991, 1993
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.129 2001/11/12 15:25:27 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.130 2002/01/28 02:06:03 simonb Exp $");
|
||||
|
||||
#include "opt_uconsole.h"
|
||||
|
||||
|
@ -171,6 +171,11 @@ int tty_count;
|
|||
|
||||
struct pool tty_pool;
|
||||
|
||||
u_int64_t tk_cancc;
|
||||
u_int64_t tk_nin;
|
||||
u_int64_t tk_nout;
|
||||
u_int64_t tk_rawcc;
|
||||
|
||||
int
|
||||
ttyopen(struct tty *tp, int dialout, int nonblock)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dkstat.h,v 1.12 2000/06/03 20:42:44 thorpej Exp $ */
|
||||
/* $NetBSD: dkstat.h,v 1.13 2002/01/28 02:06:04 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
|
@ -44,12 +44,12 @@
|
|||
#define _SYS_DKSTAT_H_
|
||||
|
||||
#define DK_NDRIVE 8
|
||||
#ifdef _KERNEL
|
||||
|
||||
u_int64_t tk_cancc;
|
||||
u_int64_t tk_nin;
|
||||
u_int64_t tk_nout;
|
||||
u_int64_t tk_rawcc;
|
||||
#ifdef _KERNEL
|
||||
extern u_int64_t tk_cancc;
|
||||
extern u_int64_t tk_nin;
|
||||
extern u_int64_t tk_nout;
|
||||
extern u_int64_t tk_rawcc;
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_DKSTAT_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysctl.h,v 1.71 2002/01/27 12:41:08 simonb Exp $ */
|
||||
/* $NetBSD: sysctl.h,v 1.72 2002/01/28 02:06:04 simonb Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -176,7 +176,8 @@ struct ctlname {
|
|||
#define KERN_PIPE 56 /* node: pipe limits */
|
||||
#define KERN_MAXPHYS 57 /* int: kernel value of MAXPHYS */
|
||||
#define KERN_SBMAX 58 /* int: max socket buffer size */
|
||||
#define KERN_MAXID 59 /* number of valid kern ids */
|
||||
#define KERN_TKSTAT 59 /* tty in/out counters */
|
||||
#define KERN_MAXID 60 /* number of valid kern ids */
|
||||
|
||||
#define CTL_KERN_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
|
@ -238,6 +239,7 @@ struct ctlname {
|
|||
{ "pipe", CTLTYPE_NODE }, \
|
||||
{ "maxphys", CTLTYPE_INT }, \
|
||||
{ "sbmax", CTLTYPE_INT }, \
|
||||
{ "tkstat", CTLTYPE_NODE }, \
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -434,6 +436,24 @@ struct kinfo_proc2 {
|
|||
#define KERN_SYSVIPC_SEM_INFO 2 /* seminfo and semid_ds */
|
||||
#define KERN_SYSVIPC_SHM_INFO 3 /* shminfo and shmid_ds */
|
||||
|
||||
/*
|
||||
* tty counter sysctl variables
|
||||
*/
|
||||
#define KERN_TKSTAT_NIN 1 /* total input character */
|
||||
#define KERN_TKSTAT_NOUT 2 /* total output character */
|
||||
#define KERN_TKSTAT_CANCC 3 /* canonical input character */
|
||||
#define KERN_TKSTAT_RAWCC 4 /* raw input character */
|
||||
#define KERN_TKSTAT_MAXID 5 /* number of valid TKSTAT ids */
|
||||
|
||||
#define KERN_TKSTAT_NAMES { \
|
||||
{ 0, 0 }, \
|
||||
{ "nin", CTLTYPE_QUAD }, \
|
||||
{ "nout", CTLTYPE_QUAD }, \
|
||||
{ "cancc", CTLTYPE_QUAD }, \
|
||||
{ "rawcc", CTLTYPE_QUAD }, \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* CTL_HW identifiers
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue