Deleted Added
full compact
kern_ktrace.c (12819) kern_ktrace.c (13203)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93
34 * $Id: kern_ktrace.c,v 1.8 1995/12/02 18:58:47 bde Exp $
34 * $Id: kern_ktrace.c,v 1.9 1995/12/14 08:31:23 phk Exp $
35 */
36
35 */
36
37#ifdef KTRACE
37#include "opt_ktrace.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/sysproto.h>
42#include <sys/proc.h>
43#include <sys/file.h>
44#include <sys/namei.h>
45#include <sys/vnode.h>
46#include <sys/ktrace.h>
47#include <sys/malloc.h>
48#include <sys/syslog.h>
49
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/sysproto.h>
42#include <sys/proc.h>
43#include <sys/file.h>
44#include <sys/namei.h>
45#include <sys/vnode.h>
46#include <sys/ktrace.h>
47#include <sys/malloc.h>
48#include <sys/syslog.h>
49
50#ifdef KTRACE
50static struct ktr_header *ktrgetheader __P((int type));
51static void ktrwrite __P((struct vnode *, struct ktr_header *));
52static int ktrcanset __P((struct proc *,struct proc *));
53static int ktrsetchildren __P((struct proc *,struct proc *,int,int,struct vnode *));
54static int ktrops __P((struct proc *,struct proc *,int,int,struct vnode *));
55
56
57static struct ktr_header *

--- 162 unchanged lines hidden (view full) ---

220 kc.user = user;
221 kth->ktr_buf = (caddr_t)&kc;
222 kth->ktr_len = sizeof (struct ktr_csw);
223
224 ktrwrite(vp, kth);
225 FREE(kth, M_TEMP);
226 p->p_traceflag &= ~KTRFAC_ACTIVE;
227}
51static struct ktr_header *ktrgetheader __P((int type));
52static void ktrwrite __P((struct vnode *, struct ktr_header *));
53static int ktrcanset __P((struct proc *,struct proc *));
54static int ktrsetchildren __P((struct proc *,struct proc *,int,int,struct vnode *));
55static int ktrops __P((struct proc *,struct proc *,int,int,struct vnode *));
56
57
58static struct ktr_header *

--- 162 unchanged lines hidden (view full) ---

221 kc.user = user;
222 kth->ktr_buf = (caddr_t)&kc;
223 kth->ktr_len = sizeof (struct ktr_csw);
224
225 ktrwrite(vp, kth);
226 FREE(kth, M_TEMP);
227 p->p_traceflag &= ~KTRFAC_ACTIVE;
228}
229#endif
228
229/* Interface and common routines */
230
231/*
232 * ktrace system call
233 */
234#ifndef _SYS_SYSPROTO_H_
235struct ktrace_args {

--- 5 unchanged lines hidden (view full) ---

241#endif
242/* ARGSUSED */
243int
244ktrace(curp, uap, retval)
245 struct proc *curp;
246 register struct ktrace_args *uap;
247 int *retval;
248{
230
231/* Interface and common routines */
232
233/*
234 * ktrace system call
235 */
236#ifndef _SYS_SYSPROTO_H_
237struct ktrace_args {

--- 5 unchanged lines hidden (view full) ---

243#endif
244/* ARGSUSED */
245int
246ktrace(curp, uap, retval)
247 struct proc *curp;
248 register struct ktrace_args *uap;
249 int *retval;
250{
251#ifdef KTRACE
249 register struct vnode *vp = NULL;
250 register struct proc *p;
251 struct pgrp *pg;
252 int facs = uap->facs & ~KTRFAC_ROOT;
253 int ops = KTROP(uap->ops);
254 int descend = uap->ops & KTRFLAG_DESCEND;
255 int ret = 0;
256 int error = 0;

--- 76 unchanged lines hidden (view full) ---

333 }
334 if (!ret)
335 error = EPERM;
336done:
337 if (vp != NULL)
338 (void) vn_close(vp, FWRITE, curp->p_ucred, curp);
339 curp->p_traceflag &= ~KTRFAC_ACTIVE;
340 return (error);
252 register struct vnode *vp = NULL;
253 register struct proc *p;
254 struct pgrp *pg;
255 int facs = uap->facs & ~KTRFAC_ROOT;
256 int ops = KTROP(uap->ops);
257 int descend = uap->ops & KTRFLAG_DESCEND;
258 int ret = 0;
259 int error = 0;

--- 76 unchanged lines hidden (view full) ---

336 }
337 if (!ret)
338 error = EPERM;
339done:
340 if (vp != NULL)
341 (void) vn_close(vp, FWRITE, curp->p_ucred, curp);
342 curp->p_traceflag &= ~KTRFAC_ACTIVE;
343 return (error);
344#else
345 return ENOSYS;
346#endif
341}
342
347}
348
349#ifdef KTRACE
343static int
344ktrops(curp, p, ops, facs, vp)
345 struct proc *p, *curp;
346 int ops, facs;
347 struct vnode *vp;
348{
349
350 if (!ktrcanset(curp, p))

--- 130 unchanged lines hidden (view full) ---

481 target->p_rgid == target->p_svgid &&
482 (targetp->p_traceflag & KTRFAC_ROOT) == 0) ||
483 caller->pc_ucred->cr_uid == 0)
484 return (1);
485
486 return (0);
487}
488
350static int
351ktrops(curp, p, ops, facs, vp)
352 struct proc *p, *curp;
353 int ops, facs;
354 struct vnode *vp;
355{
356
357 if (!ktrcanset(curp, p))

--- 130 unchanged lines hidden (view full) ---

488 target->p_rgid == target->p_svgid &&
489 (targetp->p_traceflag & KTRFAC_ROOT) == 0) ||
490 caller->pc_ucred->cr_uid == 0)
491 return (1);
492
493 return (0);
494}
495
489#endif
496#endif /* KTRACE */