summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2003-01-13 06:04:17 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2003-01-13 06:04:17 +0000
commit21d25482d2965ab0b066f34ab793a1a228e116c3 (patch)
tree3af4ace10db5f58762155a467632401d016aed73
parentc3a48830f93b1368c52396ab7fc5b1316c84ab94 (diff)
Sysctls for fetching intrcnt.
-rw-r--r--sys/kern/kern_sysctl.c44
-rw-r--r--sys/sys/sysctl.h21
2 files changed, 62 insertions, 3 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index cd07eeb4ae7..a363787c4c2 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.76 2002/12/17 23:11:31 millert Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.77 2003/01/13 06:04:16 art Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -93,6 +93,7 @@ extern long numvnodes;
int sysctl_diskinit(int, struct proc *);
int sysctl_proc_args(int *, u_int, void *, size_t *, struct proc *);
+int sysctl_intrcnt(int *, u_int, void *, size_t *);
/*
* Lock to avoid too many processes vslocking a large amount of memory
@@ -267,6 +268,7 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
case KERN_SYSVIPC_INFO:
case KERN_SEMINFO:
case KERN_SHMINFO:
+ case KERN_INTRCNT:
break;
default:
return (ENOTDIR); /* overloaded */
@@ -476,6 +478,8 @@ kern_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
return (sysctl_sysvshm(name + 1, namelen - 1, oldp, oldlenp,
newp, newlen));
#endif
+ case KERN_INTRCNT:
+ return (sysctl_intrcnt(name + 1, namelen - 1, oldp, oldlenp));
default:
return (EOPNOTSUPP);
}
@@ -1443,3 +1447,41 @@ sysctl_sysvipc(name, namelen, where, sizep)
return (error ? error : ret);
}
#endif /* SYSVMSG || SYSVSEM || SYSVSHM */
+
+int
+sysctl_intrcnt(int *name, u_int namelen, void *oldp, size_t *oldlenp)
+{
+ extern int intrcnt[], eintrcnt[];
+ extern char intrnames[], eintrnames[];
+ char *intrname;
+ int nintr, i;
+
+ nintr = (off_t)(eintrcnt - intrcnt);
+
+ if (name[0] != KERN_INTRCNT_NUM) {
+ if (namelen != 2)
+ return (ENOTDIR);
+ if (name[1] < 0 || name[1] >= nintr)
+ return (EINVAL);
+ i = name[1];
+ }
+
+ switch (name[0]) {
+ case KERN_INTRCNT_NUM:
+ return (sysctl_rdint(oldp, oldlenp, NULL, nintr));
+ break;
+ case KERN_INTRCNT_CNT:
+ return (sysctl_rdint(oldp, oldlenp, NULL, intrcnt[i]));
+ case KERN_INTRCNT_NAME:
+ intrname = intrnames;
+ while (i > 0) {
+ intrname += strlen(intrname) + 1;
+ i--;
+ if (intrname > eintrnames)
+ return (EINVAL);
+ }
+ return (sysctl_rdstring(oldp, oldlenp, NULL, intrname));
+ default:
+ return (EOPNOTSUPP);
+ }
+}
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 5b1a2ca39aa..609767bb855 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.60 2002/12/17 23:11:31 millert Exp $ */
+/* $OpenBSD: sysctl.h,v 1.61 2003/01/13 06:04:16 art Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -179,7 +179,8 @@ struct ctlname {
#define KERN_USERASYMCRYPTO 60 /* int: usercrypto */
#define KERN_SEMINFO 61 /* struct: SysV struct seminfo */
#define KERN_SHMINFO 62 /* struct: SysV struct shminfo */
-#define KERN_MAXID 63 /* number of valid kern ids */
+#define KERN_INTRCNT 63 /* node: interrupt counters */
+#define KERN_MAXID 64 /* number of valid kern ids */
#define CTL_KERN_NAMES { \
{ 0, 0 }, \
@@ -245,6 +246,7 @@ struct ctlname {
{ "userasymcrypto", CTLTYPE_INT }, \
{ "seminfo", CTLTYPE_STRUCT }, \
{ "shminfo", CTLTYPE_STRUCT }, \
+ { "intrcnt", CTLTYPE_NODE }, \
}
/*
@@ -310,6 +312,21 @@ struct kinfo_proc {
};
/*
+ * KERN_INTR_CNT
+ */
+#define KERN_INTRCNT_NUM 1 /* int: # intrcnt */
+#define KERN_INTRCNT_CNT 2 /* node: intrcnt */
+#define KERN_INTRCNT_NAME 3 /* node: names */
+#define KERN_INTRCNT_MAXID 4
+
+#define CTL_KERN_INTRCNT_NAMES { \
+ { 0, 0 }, \
+ { "nintrcnt", CTLTYPE_INT }, \
+ { "intrcnt", CTLTYPE_NODE }, \
+ { "intrname", CTLTYPE_NODE }, \
+}
+
+/*
* CTL_FS identifiers
*/
#define FS_POSIX 1 /* POSIX flags */