Clean up deleted files.

This commit is contained in:
mycroft 1994-05-07 00:47:19 +00:00
parent ebf440b13b
commit d714600da2
3 changed files with 0 additions and 521 deletions

View File

@ -1,337 +0,0 @@
/*
* Copyright (c) 1982, 1986, 1989 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)kern_kinfo.c 7.17 (Berkeley) 6/26/91
* $Id: kern_kinfo.c,v 1.16 1994/05/05 08:50:25 mycroft Exp $
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/kinfo.h>
#include <sys/ioctl.h>
#include <sys/tty.h>
#include <sys/buf.h>
#include <sys/file.h>
#include <vm/vm.h>
#include <sys/kinfo_proc.h>
#define snderr(e) { error = (e); goto release;}
extern int kinfo_doproc(), kinfo_rtable(), kinfo_vnode(), kinfo_file();
extern int kinfo_loadavg();
struct kinfo_lock kinfo_lock;
/* ARGSUSED */
struct getkerninfo_args {
int op;
char *where;
int *size;
int arg;
};
int
getkerninfo(p, uap, retval)
struct proc *p;
register struct getkerninfo_args *uap;
int *retval;
{
int bufsize; /* max size of users buffer */
int needed, locked, (*server)(), error = 0;
switch (ki_type(uap->op)) {
case KINFO_PROC:
server = kinfo_doproc;
break;
case KINFO_RT:
server = kinfo_rtable;
break;
case KINFO_VNODE:
server = kinfo_vnode;
break;
case KINFO_FILE:
server = kinfo_file;
break;
case KINFO_LOADAVG:
server = kinfo_loadavg;
break;
default:
error = EINVAL;
goto done;
}
if (uap->where == NULL || uap->size == NULL) {
error = (*server)(uap->op, NULL, NULL, uap->arg, &needed);
goto done;
}
if (error = copyin((caddr_t)uap->size, (caddr_t)&bufsize,
sizeof (bufsize)))
goto done;
while (kinfo_lock.kl_lock) {
kinfo_lock.kl_want++;
tsleep((caddr_t)&kinfo_lock, PRIBIO+1, "ki_lock", 0);
kinfo_lock.kl_want--;
kinfo_lock.kl_locked++;
}
kinfo_lock.kl_lock++;
if (!useracc(uap->where, bufsize, B_WRITE))
snderr(EFAULT);
if (server != kinfo_vnode) /* XXX */
vslock(uap->where, bufsize);
locked = bufsize;
error = (*server)(uap->op, uap->where, &bufsize, uap->arg, &needed);
if (server != kinfo_vnode) /* XXX */
vsunlock(uap->where, locked, B_WRITE);
if (error == 0)
error = copyout((caddr_t)&bufsize,
(caddr_t)uap->size, sizeof (bufsize));
release:
kinfo_lock.kl_lock--;
if (kinfo_lock.kl_want)
wakeup((caddr_t)&kinfo_lock);
done:
if (!error)
*retval = needed;
return (error);
}
/*
* try over estimating by 5 procs
*/
#define KINFO_PROCSLOP (5 * sizeof (struct kinfo_proc))
int
kinfo_doproc(op, where, acopysize, arg, aneeded)
int op;
char *where;
int *acopysize, *aneeded;
int arg;
{
register struct proc *p;
register struct kinfo_proc *dp = (struct kinfo_proc *)where;
register needed = 0;
int buflen;
int doingzomb;
struct eproc eproc;
int error = 0;
if (where != NULL)
buflen = *acopysize;
p = (struct proc *)allproc;
doingzomb = 0;
again:
for (; p != NULL; p = p->p_next) {
/*
* If process not yet fully-formed, skip it.
*/
if (p->p_stat == SIDL)
continue;
/*
* TODO - make more efficient (see notes below).
* do by session.
*/
switch (ki_op(op)) {
case KINFO_PROC_PID:
/* could do this with just a lookup */
if (p->p_pid != (pid_t)arg)
continue;
break;
case KINFO_PROC_PGRP:
/* could do this by traversing pgrp */
if (p->p_pgrp->pg_id != (pid_t)arg)
continue;
break;
case KINFO_PROC_TTY:
if ((p->p_flag&P_CONTROLT) == 0 ||
p->p_session->s_ttyp == NULL ||
p->p_session->s_ttyp->t_dev != (dev_t)arg)
continue;
break;
case KINFO_PROC_UID:
if (p->p_ucred->cr_uid != (uid_t)arg)
continue;
break;
case KINFO_PROC_RUID:
if (p->p_cred->p_ruid != (uid_t)arg)
continue;
break;
}
if (where != NULL && buflen >= sizeof (struct kinfo_proc)) {
fill_eproc(p, &eproc);
if (error = copyout((caddr_t)p, &dp->kp_proc,
sizeof (struct proc)))
return (error);
if (error = copyout((caddr_t)&eproc, &dp->kp_eproc,
sizeof (eproc)))
return (error);
dp++;
buflen -= sizeof (struct kinfo_proc);
}
needed += sizeof (struct kinfo_proc);
}
if (doingzomb == 0) {
p = zombproc;
doingzomb++;
goto again;
}
if (where != NULL)
*acopysize = (caddr_t)dp - where;
else
needed += KINFO_PROCSLOP;
*aneeded = needed;
return (0);
}
/*
* Fill in an eproc structure for the specified process.
*/
void
fill_eproc(p, ep)
register struct proc *p;
register struct eproc *ep;
{
register struct tty *tp;
ep->e_paddr = p;
ep->e_sess = p->p_pgrp->pg_session;
ep->e_pcred = *p->p_cred;
ep->e_ucred = *p->p_ucred;
if (p->p_stat == SIDL || p->p_stat == SZOMB)
bzero(&ep->e_vm, sizeof(ep->e_vm));
else
ep->e_vm = *p->p_vmspace;
#ifdef pmap_resident_count /* XXX */
ep->e_vm.vm_rssize = pmap_resident_count(&p->p_vmspace->vm_pmap);
#endif
if (p->p_pptr)
ep->e_ppid = p->p_pptr->p_pid;
else
ep->e_ppid = 0;
ep->e_pgid = p->p_pgrp->pg_id;
ep->e_jobc = p->p_pgrp->pg_jobc;
if ((p->p_flag&P_CONTROLT) &&
(tp = ep->e_sess->s_ttyp)) {
ep->e_tdev = tp->t_dev;
ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
ep->e_tsess = tp->t_session;
} else
ep->e_tdev = NODEV;
ep->e_flag = ep->e_sess->s_ttyvp ? EPROC_CTTY : 0;
if (SESS_LEADER(p))
ep->e_flag |= EPROC_SLEADER;
if (p->p_wmesg)
strncpy(ep->e_wmesg, p->p_wmesg, WMESGLEN);
ep->e_xsize = ep->e_xrssize = 0;
ep->e_xccount = ep->e_xswrss = 0;
}
/*
* Get file structures.
*/
int
kinfo_file(op, where, acopysize, arg, aneeded)
int op;
register char *where;
int *acopysize, *aneeded;
int arg;
{
int buflen, needed, error;
struct file *fp;
char *start = where;
if (where == NULL) {
/*
* overestimate by 10 files
*/
*aneeded = sizeof (filehead) +
(nfiles + 10) * sizeof (struct file);
return (0);
}
buflen = *acopysize;
needed = 0;
/*
* first copyout filehead
*/
if (buflen > sizeof (filehead)) {
if (error = copyout((caddr_t)&filehead, where,
sizeof (filehead)))
return (error);
buflen -= sizeof (filehead);
where += sizeof (filehead);
}
needed += sizeof (filehead);
/*
* followed by an array of file structures
*/
for (fp = filehead; fp != NULL; fp = fp->f_filef) {
if (buflen > sizeof (struct file)) {
if (error = copyout((caddr_t)fp, where,
sizeof (struct file)))
return (error);
buflen -= sizeof (struct file);
where += sizeof (struct file);
}
needed += sizeof (struct file);
}
*acopysize = where - start;
*aneeded = needed;
return (0);
}
/* XXX THE FOLLOWING DO NOT BELONG HERE */
char hostname[MAXHOSTNAMELEN];
int hostnamelen;
char domainname[MAXHOSTNAMELEN];
int domainnamelen;
long hostid;
int securelevel;

View File

@ -1,102 +0,0 @@
/*
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)kinfo.h 7.9 (Berkeley) 6/26/91
* $Id: kinfo.h,v 1.4 1994/01/28 04:50:16 cgd Exp $
*/
#ifndef _SYS_KINFO_H_
#define _SYS_KINFO_H_
/*
* Get kernel info
*/
#define ki_op(x) ((x)&0x0000ffff)
#define ki_type(x) ((x)&0x0000ff00)
/*
* proc info
*/
#define KINFO_PROC (0<<8)
#define KINFO_PROC_ALL (KINFO_PROC|0) /* everything */
#define KINFO_PROC_PID (KINFO_PROC|1) /* by process id */
#define KINFO_PROC_PGRP (KINFO_PROC|2) /* by process group id */
#define KINFO_PROC_SESSION (KINFO_PROC|3) /* by session of pid */
#define KINFO_PROC_TTY (KINFO_PROC|4) /* by controlling tty */
#define KINFO_PROC_UID (KINFO_PROC|5) /* by effective uid */
#define KINFO_PROC_RUID (KINFO_PROC|6) /* by real uid */
/*
* Routing table
*/
#define ki_af(x) (((x)&0x00ff0000) >> 16)
#define KINFO_RT (1<<8)
#define KINFO_RT_DUMP (KINFO_RT|1) /* dump; may limit to a.f. */
#define KINFO_RT_FLAGS (KINFO_RT|2) /* by flags, e.g. RESOLVING */
/*
* vnodes
*/
#define KINFO_VNODE (2<<8)
/*
* file structures
*/
#define KINFO_FILE (3<<8)
/*
* load average
*/
#define KINFO_LOADAVG (4<<8)
/*
* Locking and stats
*/
struct kinfo_lock {
int kl_lock;
int kl_want;
int kl_locked;
};
#ifdef KERNEL
extern struct kinfo_lock kinfo_lock;
#else
#include <sys/cdefs.h>
__BEGIN_DECLS
int getkerninfo __P((int, void *, int *, int));
__END_DECLS
#endif
#endif /* !_SYS_KINFO_H_ */

View File

@ -1,82 +0,0 @@
/*
* Copyright (c) 1991 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)kinfo_proc.h 7.1 (Berkeley) 5/9/91
* $Id: kinfo_proc.h,v 1.3 1993/05/20 16:22:31 cgd Exp $
*/
#ifndef _SYS_KINFO_PROC_H_
#define _SYS_KINFO_PROC_H_
#ifndef KERNEL
#include <sys/time.h>
#include <sys/ucred.h>
#include <sys/proc.h>
#include <vm/vm.h>
#endif
/*
* getkerninfo() proc ops return arrays of augmented proc structures:
*/
struct kinfo_proc {
struct proc kp_proc; /* proc structure */
struct eproc {
struct proc *e_paddr; /* address of proc */
struct session *e_sess; /* session pointer */
struct pcred e_pcred; /* process credentials */
struct ucred e_ucred; /* current credentials */
struct vmspace e_vm; /* address space */
pid_t e_ppid; /* parent process id */
pid_t e_pgid; /* process group id */
short e_jobc; /* job control counter */
dev_t e_tdev; /* controlling tty dev */
pid_t e_tpgid; /* tty process group id */
struct session *e_tsess; /* tty session pointer */
#define WMESGLEN 7
char e_wmesg[WMESGLEN+1]; /* wchan message */
segsz_t e_xsize; /* text size */
short e_xrssize; /* text rss */
short e_xccount; /* text references */
short e_xswrss;
long e_flag;
#define EPROC_CTTY 0x01 /* controlling tty vnode active */
#define EPROC_SLEADER 0x02 /* session leader */
char e_login[MAXLOGNAME]; /* setlogin() name */
long e_spare[4];
} kp_eproc;
};
#ifdef KERNEL
void fill_eproc __P((struct proc *, struct eproc *));
#endif
#endif /* !_SYS_KINFO_PROC_H_ */