diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_sysctl.c | 26 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 22 |
2 files changed, 25 insertions, 23 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 9b2179f0947..d0560f54e28 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.232 2013/03/20 03:43:08 deraadt Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.233 2013/03/23 21:22:20 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -121,6 +121,10 @@ int sysctl_sensors(int *, u_int, void *, size_t *, void *, size_t); int sysctl_emul(int *, u_int, void *, size_t *, void *, size_t); int sysctl_cptime2(int *, u_int, void *, size_t *, void *, size_t); +void fill_file2(struct kinfo_file2 *, struct file *, struct filedesc *, + int, struct vnode *, struct proc *, struct proc *, int); +void fill_kproc(struct proc *, struct kinfo_proc *, int, int); + int (*cpu_cpuspeed)(int *); void (*cpu_setperf)(int); int perflevel = 100; @@ -1058,10 +1062,10 @@ sysctl_file(char *where, size_t *sizep, struct proc *p) #ifndef SMALL_KERNEL void fill_file2(struct kinfo_file2 *kf, struct file *fp, struct filedesc *fdp, - int fd, struct vnode *vp, struct proc *pp, struct proc *p) + int fd, struct vnode *vp, struct proc *pp, struct proc *p, + int show_pointers) { struct vattr va; - int show_pointers = suser(curproc, 0) == 0; memset(kf, 0, sizeof(*kf)); @@ -1240,6 +1244,7 @@ sysctl_file2(int *name, u_int namelen, char *where, size_t *sizep, char *dp = where; int arg, i, error = 0, needed = 0; u_int op; + int show_pointers; if (namelen > 4) return (ENOTDIR); @@ -1256,11 +1261,13 @@ sysctl_file2(int *name, u_int namelen, char *where, size_t *sizep, if (elem_size < 1) return (EINVAL); + show_pointers = suser(curproc, 0) == 0; + kf = malloc(sizeof(*kf), M_TEMP, M_WAITOK); #define FILLIT(fp, fdp, i, vp, pp) do { \ if (buflen >= elem_size && elem_count > 0) { \ - fill_file2(kf, fp, fdp, i, vp, pp, p); \ + fill_file2(kf, fp, fdp, i, vp, pp, p, show_pointers); \ error = copyout(kf, dp, outsize); \ if (error) \ break; \ @@ -1383,6 +1390,7 @@ sysctl_doproc(int *name, u_int namelen, char *where, size_t *sizep) int arg, buflen, doingzomb, elem_size, elem_count; int error, needed, op; int dothreads = 0; + int show_pointers; dp = where; buflen = where != NULL ? *sizep : 0; @@ -1399,6 +1407,8 @@ sysctl_doproc(int *name, u_int namelen, char *where, size_t *sizep) dothreads = op & KERN_PROC_SHOW_THREADS; op &= ~KERN_PROC_SHOW_THREADS; + show_pointers = suser(curproc, 0) == 0; + if (where != NULL) kproc = malloc(sizeof(*kproc), M_TEMP, M_WAITOK); @@ -1473,7 +1483,7 @@ again: if ((p->p_flag & P_THREAD) == 0) { if (buflen >= elem_size && elem_count > 0) { - fill_kproc(p, kproc, 0); + fill_kproc(p, kproc, 0, show_pointers); /* Update %cpu for all threads */ if (!dothreads) { TAILQ_FOREACH(pp, &pr->ps_threads, @@ -1497,7 +1507,7 @@ again: continue; if (buflen >= elem_size && elem_count > 0) { - fill_kproc(p, kproc, 1); + fill_kproc(p, kproc, 1, show_pointers); error = copyout(kproc, dp, elem_size); if (error) goto err; @@ -1532,13 +1542,13 @@ err: * Fill in a kproc structure for the specified process. */ void -fill_kproc(struct proc *p, struct kinfo_proc *ki, int isthread) +fill_kproc(struct proc *p, struct kinfo_proc *ki, int isthread, + int show_pointers) { struct process *pr = p->p_p; struct session *s = pr->ps_session; struct tty *tp; struct timeval ut, st; - int show_pointers = suser(curproc, 0) == 0; FILL_KPROC(ki, strlcpy, p, pr, p->p_cred, p->p_ucred, pr->ps_pgrp, p, pr, s, p->p_vmspace, pr->ps_limit, p->p_sigacts, isthread, diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index c66c5895316..8255c424679 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.129 2013/03/20 04:26:11 deraadt Exp $ */ +/* $OpenBSD: sysctl.h,v 1.130 2013/03/23 21:22:20 tedu Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -467,19 +467,16 @@ struct kinfo_proc { do { \ memset((kp), 0, sizeof(*(kp))); \ \ - if (show_addresses) \ + if (show_addresses) { \ (kp)->p_paddr = PTRTOINT64(paddr); \ - (kp)->p_fd = PTRTOINT64((p)->p_fd); \ - (kp)->p_stats = 0; \ - (kp)->p_limit = PTRTOINT64((pr)->ps_limit); \ - (kp)->p_vmspace = PTRTOINT64((p)->p_vmspace); \ - if (show_addresses) \ + (kp)->p_fd = PTRTOINT64((p)->p_fd); \ + (kp)->p_stats = 0; \ + (kp)->p_limit = PTRTOINT64((pr)->ps_limit); \ + (kp)->p_vmspace = PTRTOINT64((p)->p_vmspace); \ (kp)->p_sigacts = PTRTOINT64((p)->p_sigacts); \ - if (show_addresses) \ (kp)->p_sess = PTRTOINT64((pg)->pg_session); \ - if (show_addresses) \ (kp)->p_ru = PTRTOINT64((pr)->ps_ru); \ - \ + } \ (kp)->p_exitsig = (p)->p_exitsig; \ (kp)->p_flag = (p)->p_flag | (pr)->ps_flags | P_INMEM; \ \ @@ -941,11 +938,6 @@ int sysctl_doprof(int *, u_int, void *, size_t *, void *, size_t); #endif int sysctl_dopool(int *, u_int, char *, size_t *); -void fill_file2(struct kinfo_file2 *, struct file *, struct filedesc *, - int, struct vnode *, struct proc *, struct proc *); - -void fill_kproc(struct proc *, struct kinfo_proc *, int); - int kern_sysctl(int *, u_int, void *, size_t *, void *, size_t, struct proc *); int hw_sysctl(int *, u_int, void *, size_t *, void *, size_t, |