convert to ANSI KNF

This commit is contained in:
lukem 2001-02-26 16:24:02 +00:00
parent 9af33798b8
commit 799d6eb9da
3 changed files with 378 additions and 355 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.121 2001/01/25 20:18:51 jdolecek Exp $ */
/* $NetBSD: proc.h,v 1.122 2001/02/26 16:32:48 lukem Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@ -50,7 +50,7 @@
#if defined(_KERNEL)
#include <machine/cpu.h> /* curcpu() and cpu_info */
#endif
#include <machine/proc.h> /* Machine-dependent proc substruct. */
#include <machine/proc.h> /* Machine-dependent proc substruct */
#include <sys/lock.h>
#include <sys/queue.h>
#include <sys/callout.h>
@ -59,24 +59,27 @@
/*
* One structure allocated per session.
*/
struct session {
int s_count; /* Ref cnt; pgrps in session. */
struct proc *s_leader; /* Session leader. */
struct vnode *s_ttyvp; /* Vnode of controlling terminal. */
struct tty *s_ttyp; /* Controlling terminal. */
char s_login[MAXLOGNAME]; /* Setlogin() name. */
pid_t s_sid; /* session ID (pid of leader) */
struct session {
int s_count; /* Ref cnt; pgrps in session */
struct proc *s_leader; /* Session leader */
struct vnode *s_ttyvp; /* Vnode of controlling terminal */
struct tty *s_ttyp; /* Controlling terminal */
char s_login[MAXLOGNAME]; /* Setlogin() name */
pid_t s_sid; /* Session ID (pid of leader) */
};
/*
* One structure allocated per process group.
*/
struct pgrp {
LIST_ENTRY(pgrp) pg_hash; /* Hash chain. */
LIST_HEAD(, proc) pg_members; /* Pointer to pgrp members. */
struct session *pg_session; /* Pointer to session. */
pid_t pg_id; /* Pgrp id. */
int pg_jobc; /* # procs qualifying pgrp for job control */
struct pgrp {
LIST_ENTRY(pgrp) pg_hash; /* Hash chain */
LIST_HEAD(, proc) pg_members; /* Pointer to pgrp members */
struct session *pg_session; /* Pointer to session */
pid_t pg_id; /* Pgrp id */
int pg_jobc; /*
* Number of processes qualifying
* pgrp for job control
*/
};
/*
@ -85,36 +88,38 @@ struct pgrp {
struct exec_package;
struct ps_strings;
struct emul {
const char *e_name; /* Symbolic name */
const char *e_path; /* Extra emulation path (NULL if none)*/
struct emul {
const char *e_name; /* Symbolic name */
const char *e_path; /* Extra emulation path (NULL if none)*/
#ifndef __HAVE_MINIMAL_EMUL
int e_flags; /* Miscellaneous flags */
int e_flags; /* Miscellaneous flags */
/* Syscall handling function */
const int *e_errno; /* Errno array */
int e_nosys; /* Offset of the nosys() syscall */
int e_nsysent; /* Number of system call entries */
const int *e_errno; /* Errno array */
int e_nosys; /* Offset of the nosys() syscall */
int e_nsysent; /* Number of system call entries */
#endif
const struct sysent *e_sysent; /* System call array */
const char * const *e_syscallnames; /* System call name array */
const char * const *e_syscallnames; /* System call name array */
/* Signal sending function */
void (*e_sendsig) __P((sig_t, int, sigset_t *, u_long));
char *e_sigcode; /* Start of sigcode */
char *e_esigcode; /* End of sigcode */
void (*e_sendsig) __P((sig_t, int, sigset_t *, u_long));
char *e_sigcode; /* Start of sigcode */
char *e_esigcode; /* End of sigcode */
/* Per-process hooks */
void (*e_proc_exec) __P((struct proc *, struct exec_package *));
void (*e_proc_fork) __P((struct proc *p, struct proc *parent));
void (*e_proc_exit) __P((struct proc *));
void (*e_proc_exec) __P((struct proc *,
struct exec_package *));
void (*e_proc_fork) __P((struct proc *p,
struct proc *parent));
void (*e_proc_exit) __P((struct proc *));
#ifdef __HAVE_SYSCALL_INTERN
void (*e_syscall_intern) __P((struct proc *));
void (*e_syscall_intern) __P((struct proc *));
#else
void (*e_syscall) __P((void));
void (*e_syscall) __P((void));
#endif
};
#define EMUL_HAS_SYS___syscall 0x001 /* has SYS___syscall */
#define EMUL_HAS_SYS___syscall 0x001 /* Has SYS___syscall */
/*
* Description of a process.
@ -127,104 +132,114 @@ struct emul {
* which might be addressible only on a processor on which the process
* is running.
*/
struct proc {
struct proc *p_forw; /* Doubly-linked run/sleep queue. */
struct proc *p_back;
LIST_ENTRY(proc) p_list; /* List of all processes. */
struct proc {
struct proc *p_forw; /* Doubly-linked run/sleep queue */
struct proc *p_back;
LIST_ENTRY(proc) p_list; /* List of all processes */
/* substructures: */
struct pcred *p_cred; /* Process owner's identity. */
struct filedesc *p_fd; /* Ptr to open files structure. */
struct cwdinfo *p_cwdi; /* cdir/rdir/cmask info */
struct pstats *p_stats; /* Accounting/statistics (PROC ONLY). */
struct plimit *p_limit; /* Process limits. */
struct vmspace *p_vmspace; /* Address space. */
struct sigacts *p_sigacts; /* Process sigactions (state is below)*/
/* Substructures: */
struct pcred *p_cred; /* Process owner's identity */
struct filedesc *p_fd; /* Ptr to open files structure */
struct cwdinfo *p_cwdi; /* cdir/rdir/cmask info */
struct pstats *p_stats; /* Accounting/statistics (PROC ONLY) */
struct plimit *p_limit; /* Process limits */
struct vmspace *p_vmspace; /* Address space */
struct sigacts *p_sigacts; /* Process sigactions (state is below)*/
#define p_ucred p_cred->pc_ucred
#define p_rlimit p_limit->pl_rlimit
int p_exitsig; /* signal to sent to parent on exit */
int p_flag; /* P_* flags. */
struct cpu_info * __volatile p_cpu; /* CPU we're running on if
SONPROC */
char p_stat; /* S* process status. */
char p_pad1[3];
int p_exitsig; /* Signal to sent to parent on exit */
int p_flag; /* P_* flags */
struct cpu_info * __volatile p_cpu;
/* CPU we're running on if SONPROC */
char p_stat; /* S* process status */
char p_pad1[3];
pid_t p_pid; /* Process identifier. */
LIST_ENTRY(proc) p_hash; /* Hash chain. */
LIST_ENTRY(proc) p_pglist; /* List of processes in pgrp. */
struct proc *p_pptr; /* Pointer to parent process. */
LIST_ENTRY(proc) p_sibling; /* List of sibling processes. */
LIST_HEAD(, proc) p_children; /* Pointer to list of children. */
pid_t p_pid; /* Process identifier */
LIST_ENTRY(proc) p_hash; /* Hash chain */
LIST_ENTRY(proc) p_pglist; /* List of processes in pgrp */
struct proc *p_pptr; /* Pointer to parent process */
LIST_ENTRY(proc) p_sibling; /* List of sibling processes */
LIST_HEAD(, proc) p_children; /* Pointer to list of children */
/* The following fields are all zeroed upon creation in fork. */
/*
* The following fields are all zeroed upon creation in fork.
*/
#define p_startzero p_oppid
pid_t p_oppid; /* Save parent pid during ptrace. XXX */
int p_dupfd; /* Sideways return value from filedescopen. XXX */
pid_t p_oppid; /* Save parent pid during ptrace. XXX */
int p_dupfd; /* Sideways return value from filedescopen. XXX */
/* scheduling */
u_int p_estcpu; /* Time averaged value of p_cpticks. XXX belongs in p_startcopy section */
int p_cpticks; /* Ticks of cpu time. */
fixpt_t p_pctcpu; /* %cpu for this process during p_swtime */
void *p_wchan; /* Sleep address. */
struct callout p_tsleep_ch;/* callout for tsleep */
const char *p_wmesg; /* Reason for sleep. */
u_int p_swtime; /* Time swapped in or out. */
u_int p_slptime; /* Time since last blocked. */
/* Scheduling */
u_int p_estcpu; /* Time averaged value of p_cpticks. XXX belongs in p_startcopy section */
int p_cpticks; /* Ticks of cpu time */
fixpt_t p_pctcpu; /* %cpu for this proc during p_swtime */
void *p_wchan; /* Sleep address */
struct callout p_tsleep_ch; /* Callout for tsleep */
const char *p_wmesg; /* Reason for sleep */
u_int p_swtime; /* Time swapped in or out */
u_int p_slptime; /* Time since last blocked */
struct callout p_realit_ch; /* real time callout */
struct itimerval p_realtimer; /* Alarm timer. */
struct timeval p_rtime; /* Real time. */
u_quad_t p_uticks; /* Statclock hits in user mode. */
u_quad_t p_sticks; /* Statclock hits in system mode. */
u_quad_t p_iticks; /* Statclock hits processing intr. */
struct callout p_realit_ch; /* Real time callout */
struct itimerval p_realtimer; /* Alarm timer */
struct timeval p_rtime; /* Real time */
u_quad_t p_uticks; /* Statclock hits in user mode */
u_quad_t p_sticks; /* Statclock hits in system mode */
u_quad_t p_iticks; /* Statclock hits processing intr */
int p_traceflag; /* Kernel trace points. */
struct file *p_tracep; /* Trace to file */
int p_traceflag; /* Kernel trace points */
struct file *p_tracep; /* Trace to file */
struct vnode *p_textvp; /* Vnode of executable. */
struct vnode *p_textvp; /* Vnode of executable */
int p_locks; /* DEBUG: lockmgr count of held locks */
int p_locks; /* DEBUG: lockmgr count of held locks */
int p_holdcnt; /* If non-zero, don't swap. */
int p_holdcnt; /* If non-zero, don't swap */
const struct emul *p_emul; /* Emulation information */
void *p_emuldata; /* Per-process emulation data, or NULL.
* Malloc type M_EMULDATA */
void *p_emuldata; /*
* Per-process emulation data, or NULL.
* Malloc type M_EMULDATA
*/
/* End area that is zeroed on creation. */
/*
* End area that is zeroed on creation
*/
#define p_endzero p_startcopy
/* The following fields are all copied upon creation in fork. */
/*
* The following fields are all copied upon creation in fork.
*/
#define p_startcopy p_sigctx.ps_startcopy
struct sigctx p_sigctx; /* Signal state. */
struct sigctx p_sigctx; /* Signal state */
u_char p_priority; /* Process priority. */
u_char p_usrpri; /* User-priority based on p_cpu and p_nice. */
u_char p_nice; /* Process "nice" value. */
char p_comm[MAXCOMLEN+1];
u_char p_priority; /* Process priority */
u_char p_usrpri; /* User-priority based on p_cpu and p_nice */
u_char p_nice; /* Process "nice" value */
char p_comm[MAXCOMLEN+1];
struct pgrp *p_pgrp; /* Pointer to process group. */
void *p_ctxlink; /* uc_link {get,set}context */
struct pgrp *p_pgrp; /* Pointer to process group */
void *p_ctxlink; /* uc_link {get,set}context */
struct ps_strings *p_psstr; /* address of process's ps_strings */
size_t p_psargv; /* offset of ps_argvstr in above */
size_t p_psnargv; /* offset of ps_nargvstr in above */
size_t p_psenv; /* offset of ps_envstr in above */
size_t p_psnenv; /* offset of ps_nenvstr in above */
struct ps_strings *p_psstr; /* Address of process's ps_strings */
size_t p_psargv; /* Offset of ps_argvstr in above */
size_t p_psnargv; /* Offset of ps_nargvstr in above */
size_t p_psenv; /* Offset of ps_envstr in above */
size_t p_psnenv; /* Offset of ps_nenvstr in above */
/* End area that is copied on creation. */
/*
* End area that is copied on creation
*/
#define p_endcopy p_thread
void *p_thread; /* Id for this "thread"; Mach glue. XXX */
struct user *p_addr; /* Kernel virtual addr of u-area (PROC ONLY). */
struct mdproc p_md; /* Any machine-dependent fields. */
void *p_thread; /* Id for this "thread"; Mach glue. XXX */
struct user *p_addr; /* Kernel virtual addr of u-area (PROC ONLY) */
struct mdproc p_md; /* Any machine-dependent fields */
u_short p_xstat; /* Exit status for wait; also stop signal. */
u_short p_acflag; /* Accounting flags. */
struct rusage *p_ru; /* Exit information. XXX */
u_short p_xstat; /* Exit status for wait; also stop signal */
u_short p_acflag; /* Accounting flags */
struct rusage *p_ru; /* Exit information. XXX */
};
#define p_session p_pgrp->pg_session
@ -238,37 +253,37 @@ struct proc {
* indicates that the process is actually executing on a CPU, i.e.
* it is no longer on a run queue.
*/
#define SIDL 1 /* Process being created by fork. */
#define SRUN 2 /* Currently runnable. */
#define SSLEEP 3 /* Sleeping on an address. */
#define SSTOP 4 /* Process debugging or suspension. */
#define SZOMB 5 /* Awaiting collection by parent. */
#define SDEAD 6 /* Process is almost a zombie. */
#define SONPROC 7 /* Process is currently on a CPU */
#define SIDL 1 /* Process being created by fork */
#define SRUN 2 /* Currently runnable */
#define SSLEEP 3 /* Sleeping on an address */
#define SSTOP 4 /* Process debugging or suspension */
#define SZOMB 5 /* Awaiting collection by parent */
#define SDEAD 6 /* Process is almost a zombie */
#define SONPROC 7 /* Process is currently on a CPU */
#define P_ZOMBIE(p) ((p)->p_stat == SZOMB || (p)->p_stat == SDEAD)
/* These flags are kept in p_flag. */
#define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock. */
#define P_CONTROLT 0x00002 /* Has a controlling terminal. */
#define P_INMEM 0x00004 /* Loaded into memory. */
#define P_NOCLDSTOP 0x00008 /* No SIGCHLD when children stop. */
#define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit. */
#define P_PROFIL 0x00020 /* Has started profiling. */
#define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger. */
#define P_SINTR 0x00080 /* Sleep is interruptible. */
#define P_SUGID 0x00100 /* Had set id privileges since last exec. */
#define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping. */
#define P_TIMEOUT 0x00400 /* Timing out during sleep. */
#define P_TRACED 0x00800 /* Debugged process being traced. */
#define P_WAITED 0x01000 /* Debugging process has waited for child. */
#define P_WEXIT 0x02000 /* Working on exiting. */
#define P_EXEC 0x04000 /* Process called exec. */
#define P_OWEUPC 0x08000 /* Owe process an addupc() call at next ast. */
#define P_ADVLOCK 0x00001 /* Process may hold a POSIX advisory lock */
#define P_CONTROLT 0x00002 /* Has a controlling terminal */
#define P_INMEM 0x00004 /* Loaded into memory */
#define P_NOCLDSTOP 0x00008 /* No SIGCHLD when children stop */
#define P_PPWAIT 0x00010 /* Parent is waiting for child to exec/exit */
#define P_PROFIL 0x00020 /* Has started profiling */
#define P_SELECT 0x00040 /* Selecting; wakeup/waiting danger */
#define P_SINTR 0x00080 /* Sleep is interruptible */
#define P_SUGID 0x00100 /* Had set id privileges since last exec */
#define P_SYSTEM 0x00200 /* System proc: no sigs, stats or swapping */
#define P_TIMEOUT 0x00400 /* Timing out during sleep */
#define P_TRACED 0x00800 /* Debugged process being traced */
#define P_WAITED 0x01000 /* Debugging process has waited for child */
#define P_WEXIT 0x02000 /* Working on exiting */
#define P_EXEC 0x04000 /* Process called exec */
#define P_OWEUPC 0x08000 /* Owe process an addupc() call at next ast */
#define P_FSTRACE 0x10000 /* Debugger process being traced by procfs */
#define P_NOCLDWAIT 0x20000 /* No zombies if child dies */
#define P_32 0x40000 /* 32-bit process (used on 64-bit kernels) */
#define P_BIGLOCK 0x80000 /* Process needs kernel "big lock" to run */
#define P_BIGLOCK 0x80000 /* Process needs kernel "big lock" to run */
/*
@ -284,22 +299,22 @@ struct proc {
* to the current user credentials as well as real and saved ids that may be
* used to change ids.
*/
struct pcred {
struct ucred *pc_ucred; /* Current credentials. */
uid_t p_ruid; /* Real user id. */
uid_t p_svuid; /* Saved effective user id. */
gid_t p_rgid; /* Real group id. */
gid_t p_svgid; /* Saved effective group id. */
int p_refcnt; /* Number of references. */
struct pcred {
struct ucred *pc_ucred; /* Current credentials */
uid_t p_ruid; /* Real user id */
uid_t p_svuid; /* Saved effective user id */
gid_t p_rgid; /* Real group id */
gid_t p_svgid; /* Saved effective group id */
int p_refcnt; /* Number of references */
};
LIST_HEAD(proclist, proc); /* a list of processes */
LIST_HEAD(proclist, proc); /* A list of processes */
/*
* This structure associates a proclist with its lock.
*/
struct proclist_desc {
struct proclist *pd_list; /* the list */
struct proclist *pd_list; /* The list */
/*
* XXX Add a pointer to the proclist's lock eventually.
*/
@ -313,35 +328,37 @@ struct proclist_desc {
#define PID_MAX 30000
#define NO_PID 30001
#define SESS_LEADER(p) ((p)->p_session->s_leader == (p))
#define SESS_LEADER(p) ((p)->p_session->s_leader == (p))
#define SESSHOLD(s) ((s)->s_count++)
#define SESSRELE(s) { \
#define SESSRELE(s) \
do { \
if (--(s)->s_count == 0) \
FREE(s, M_SESSION); \
}
} while (0)
#define PHOLD(p) { \
#define PHOLD(p) \
do { \
if ((p)->p_holdcnt++ == 0 && ((p)->p_flag & P_INMEM) == 0) \
uvm_swapin(p); \
}
} while (0)
#define PRELE(p) (--(p)->p_holdcnt)
/*
* Flags passed to fork1().
*/
#define FORK_PPWAIT 0x01 /* block parent until child exit */
#define FORK_SHAREVM 0x02 /* share vmspace with parent */
#define FORK_SHARECWD 0x04 /* share cdir/rdir/cmask */
#define FORK_SHAREFILES 0x08 /* share file descriptors */
#define FORK_SHARESIGS 0x10 /* share signal actions */
#define FORK_PPWAIT 0x01 /* Block parent until child exit */
#define FORK_SHAREVM 0x02 /* Share vmspace with parent */
#define FORK_SHARECWD 0x04 /* Share cdir/rdir/cmask */
#define FORK_SHAREFILES 0x08 /* Share file descriptors */
#define FORK_SHARESIGS 0x10 /* Share signal actions */
#define PIDHASH(pid) (&pidhashtbl[(pid) & pidhash])
extern LIST_HEAD(pidhashhead, proc) *pidhashtbl;
extern u_long pidhash;
extern u_long pidhash;
#define PGRPHASH(pgid) (&pgrphashtbl[(pgid) & pgrphash])
extern LIST_HEAD(pgrphashhead, pgrp) *pgrphashtbl;
extern u_long pgrphash;
extern u_long pgrphash;
/*
* Allow machine-dependent code to override curproc in <machine/cpu.h> for
@ -349,82 +366,82 @@ extern u_long pgrphash;
*/
#if !defined(curproc)
#if defined(MULTIPROCESSOR)
#define curproc curcpu()->ci_curproc /* Current running proc. */
#define curproc curcpu()->ci_curproc /* Current running proc */
#else
extern struct proc *curproc; /* Current running proc. */
extern struct proc *curproc; /* Current running proc */
#endif /* MULTIPROCESSOR */
#endif /* ! curproc */
extern struct proc proc0; /* Process slot for swapper. */
extern int nprocs, maxproc; /* Current and max number of procs. */
extern struct proc proc0; /* Process slot for swapper */
extern int nprocs, maxproc; /* Current and max number of procs */
/* Process list lock; see kern_proc.c for locking protocol details. */
extern struct lock proclist_lock;
/* Process list lock; see kern_proc.c for locking protocol details */
extern struct lock proclist_lock;
extern struct proclist allproc; /* List of all processes. */
extern struct proclist zombproc; /* List of zombie processes. */
extern struct proclist allproc; /* List of all processes */
extern struct proclist zombproc; /* List of zombie processes */
extern struct proclist deadproc; /* List of dead processes. */
extern struct proclist deadproc; /* List of dead processes */
extern struct simplelock deadproc_slock;
extern struct proc *initproc; /* Process slots for init, pager. */
extern struct proc *initproc; /* Process slots for init, pager */
extern const struct proclist_desc proclists[];
extern struct pool proc_pool; /* memory pool for procs */
extern struct pool pcred_pool; /* memory pool for pcreds */
extern struct pool plimit_pool; /* memory pool for plimits */
extern struct pool rusage_pool; /* memory pool for rusages */
extern struct pool proc_pool; /* Memory pool for procs */
extern struct pool pcred_pool; /* Memory pool for pcreds */
extern struct pool plimit_pool; /* Memory pool for plimits */
extern struct pool rusage_pool; /* Memory pool for rusages */
struct proc *pfind __P((pid_t)); /* Find process by id. */
struct pgrp *pgfind __P((pid_t)); /* Find process group by id. */
struct proc *pfind(pid_t); /* Find process by id */
struct pgrp *pgfind(pid_t); /* Find process group by id */
struct simplelock;
int chgproccnt __P((uid_t uid, int diff));
int enterpgrp __P((struct proc *p, pid_t pgid, int mksess));
void fixjobc __P((struct proc *p, struct pgrp *pgrp, int entering));
int inferior __P((struct proc *p, struct proc *q));
int leavepgrp __P((struct proc *p));
void yield __P((void));
void preempt __P((struct proc *));
void mi_switch __P((struct proc *));
void pgdelete __P((struct pgrp *pgrp));
void procinit __P((void));
void remrunqueue __P((struct proc *));
void resetpriority __P((struct proc *));
void setrunnable __P((struct proc *));
void setrunqueue __P((struct proc *));
void suspendsched __P((void));
int ltsleep __P((void *chan, int pri, const char *wmesg, int timo,
__volatile struct simplelock *));
void unsleep __P((struct proc *));
void wakeup __P((void *chan));
void wakeup_one __P((void *chan));
void reaper __P((void *));
void exit1 __P((struct proc *, int));
void exit2 __P((struct proc *));
int fork1 __P((struct proc *, int, int, void *, size_t,
void (*)(void *), void *, register_t *, struct proc **));
void rqinit __P((void));
int groupmember __P((gid_t, struct ucred *));
void cpu_switch __P((struct proc *));
void cpu_wait __P((struct proc *));
void cpu_exit __P((struct proc *));
void cpu_fork __P((struct proc *, struct proc *, void *, size_t,
void (*)(void *), void *));
int chgproccnt(uid_t uid, int diff);
int enterpgrp(struct proc *p, pid_t pgid, int mksess);
void fixjobc(struct proc *p, struct pgrp *pgrp, int entering);
int inferior(struct proc *p, struct proc *q);
int leavepgrp(struct proc *p);
void yield(void);
void preempt(struct proc *);
void mi_switch(struct proc *);
void pgdelete(struct pgrp *pgrp);
void procinit(void);
void remrunqueue(struct proc *);
void resetpriority(struct proc *);
void setrunnable(struct proc *);
void setrunqueue(struct proc *);
void suspendsched(void);
int ltsleep(void *chan, int pri, const char *wmesg, int timo,
__volatile struct simplelock *);
void unsleep(struct proc *);
void wakeup(void *chan);
void wakeup_one(void *chan);
void reaper(void *);
void exit1(struct proc *, int);
void exit2(struct proc *);
int fork1(struct proc *, int, int, void *, size_t,
void (*)(void *), void *, register_t *, struct proc **);
void rqinit(void);
int groupmember(gid_t, struct ucred *);
void cpu_switch(struct proc *);
void cpu_wait(struct proc *);
void cpu_exit(struct proc *);
void cpu_fork(struct proc *, struct proc *, void *, size_t,
void (*)(void *), void *);
void child_return __P((void *));
void child_return(void *);
int proc_isunder __P((struct proc *, struct proc*));
int proc_isunder(struct proc *, struct proc*);
void proclist_lock_read __P((void));
void proclist_unlock_read __P((void));
int proclist_lock_write __P((void));
void proclist_unlock_write __P((int));
void p_sugid __P((struct proc*));
void proclist_lock_read(void);
void proclist_unlock_read(void);
int proclist_lock_write(void);
void proclist_unlock_write(int);
void p_sugid(struct proc*);
/* Compatbility with old, non-interlocked tsleep call. */
/* Compatibility with old, non-interlocked tsleep call */
#define tsleep(chan, pri, wmesg, timo) \
ltsleep(chan, pri, wmesg, timo, NULL)

View File

@ -1,4 +1,4 @@
/* $NetBSD: select.h,v 1.10 1995/03/26 20:24:38 jtc Exp $ */
/* $NetBSD: select.h,v 1.11 2001/02/26 16:26:54 lukem Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -43,16 +43,16 @@
* notified when I/O becomes possible.
*/
struct selinfo {
pid_t si_pid; /* process to be notified */
short si_flags; /* see below */
pid_t si_pid; /* process to be notified */
short si_flags; /* see below */
};
#define SI_COLL 0x0001 /* collision occurred */
#define SI_COLL 0x0001 /* collision occurred */
#ifdef _KERNEL
struct proc;
void selrecord __P((struct proc *selector, struct selinfo *));
void selwakeup __P((struct selinfo *));
void selrecord(struct proc *selector, struct selinfo *);
void selwakeup(struct selinfo *);
#endif
#endif /* !_SYS_SELECT_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: socketvar.h,v 1.41 2000/12/10 23:13:42 fvdl Exp $ */
/* $NetBSD: socketvar.h,v 1.42 2001/02/26 16:24:02 lukem Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1993
@ -36,7 +36,7 @@
*/
#ifndef _SYS_SOCKETVAR_H_
#define _SYS_SOCKETVAR_H_
#define _SYS_SOCKETVAR_H_
#include <sys/select.h> /* for struct selinfo */
#include <sys/queue.h>
@ -54,12 +54,12 @@ TAILQ_HEAD(soqhead, socket);
* private data and error information.
*/
struct socket {
short so_type; /* generic type, see socket.h */
short so_options; /* from socket call, see socket.h */
short so_linger; /* time to linger while closing */
short so_state; /* internal state flags SS_*, below */
void *so_pcb; /* protocol control block */
struct protosw *so_proto; /* protocol handle */
short so_type; /* generic type, see socket.h */
short so_options; /* from socket call, see socket.h */
short so_linger; /* time to linger while closing */
short so_state; /* internal state flags SS_*, below */
void *so_pcb; /* protocol control block */
struct protosw *so_proto; /* protocol handle */
/*
* Variables for connection queueing.
* Socket where accepts occur is so_head in all subsidiary sockets.
@ -71,29 +71,29 @@ struct socket {
* We allow connections to queue up based on current queue lengths
* and limit on number of queued connections for this socket.
*/
struct socket *so_head; /* back pointer to accept socket */
struct soqhead *so_onq; /* queue (q or q0) that we're on */
struct soqhead so_q0; /* queue of partial connections */
struct soqhead so_q; /* queue of incoming connections */
struct socket *so_head; /* back pointer to accept socket */
struct soqhead *so_onq; /* queue (q or q0) that we're on */
struct soqhead so_q0; /* queue of partial connections */
struct soqhead so_q; /* queue of incoming connections */
TAILQ_ENTRY(socket) so_qe; /* our queue entry (q or q0) */
short so_q0len; /* partials on so_q0 */
short so_qlen; /* number of connections on so_q */
short so_qlimit; /* max number queued connections */
short so_timeo; /* connection timeout */
u_short so_error; /* error affecting connection */
pid_t so_pgid; /* pgid for signals */
u_long so_oobmark; /* chars to oob mark */
short so_q0len; /* partials on so_q0 */
short so_qlen; /* number of connections on so_q */
short so_qlimit; /* max number queued connections */
short so_timeo; /* connection timeout */
u_short so_error; /* error affecting connection */
pid_t so_pgid; /* pgid for signals */
u_long so_oobmark; /* chars to oob mark */
/*
* Variables for socket buffering.
*/
struct sockbuf {
struct sockbuf {
u_long sb_cc; /* actual chars in buffer */
u_long sb_hiwat; /* max actual char count */
u_long sb_mbcnt; /* chars of mbufs used */
u_long sb_mbmax; /* max chars of mbufs to use */
long sb_lowat; /* low water mark */
struct mbuf *sb_mb; /* the mbuf chain */
struct selinfo sb_sel; /* process selecting read/write */
struct mbuf *sb_mb; /* the mbuf chain */
struct selinfo sb_sel; /* process selecting read/write */
short sb_flags; /* flags, see below */
short sb_timeo; /* timeout for read/write */
} so_rcv, so_snd;
@ -110,16 +110,18 @@ struct socket {
#define SB_UPCALL 0x20 /* someone wants an upcall */
#define SB_NOINTR 0x40 /* operations not interruptible */
void *so_internal; /* Space for svr4 stream data */
void (*so_upcall) __P((struct socket *so, caddr_t arg, int waitf));
caddr_t so_upcallarg; /* Arg for above */
int (*so_send) __P((struct socket *so, struct mbuf *addr,
struct uio *uio, struct mbuf *top,
struct mbuf *control, int flags));
int (*so_receive) __P((struct socket *so, struct mbuf **paddr,
struct uio *uio, struct mbuf **mp0,
struct mbuf **controlp, int *flagsp));
uid_t so_uid; /* who opened the socket */
void *so_internal; /* Space for svr4 stream data */
void (*so_upcall) __P((struct socket *so, caddr_t arg,
int waitf));
caddr_t so_upcallarg; /* Arg for above */
int (*so_send) __P((struct socket *so, struct mbuf *addr,
struct uio *uio, struct mbuf *top,
struct mbuf *control, int flags));
int (*so_receive) __P((struct socket *so,
struct mbuf **paddr,
struct uio *uio, struct mbuf **mp0,
struct mbuf **controlp, int *flagsp));
uid_t so_uid; /* who opened the socket */
};
/*
@ -137,8 +139,10 @@ struct socket {
#define SS_NBIO 0x080 /* non-blocking ops */
#define SS_ASYNC 0x100 /* async i/o notify */
#define SS_ISCONFIRMING 0x200 /* deciding to accept connection req */
#define SS_MORETOCOME 0x400 /* hint from sosend to lower layer;
more data coming */
#define SS_MORETOCOME 0x400 /*
* hint from sosend to lower layer;
* more data coming
*/
/*
@ -148,7 +152,8 @@ struct socket {
/*
* Do we need to notify the other side when I/O is possible?
*/
#define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT|SB_SEL|SB_ASYNC|SB_UPCALL)) != 0)
#define sb_notify(sb) (((sb)->sb_flags & \
(SB_WAIT | SB_SEL | SB_ASYNC | SB_UPCALL)) != 0)
/*
* How much space is there in a socket buffer (so->so_snd or so->so_rcv)?
@ -157,80 +162,86 @@ struct socket {
* overflow and return 0. Should use "lmin" but it doesn't exist now.
*/
#define sbspace(sb) \
((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \
((long) imin((int)((sb)->sb_hiwat - (sb)->sb_cc), \
(int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
/* do we have to send all at once on a socket? */
#define sosendallatonce(so) \
((so)->so_proto->pr_flags & PR_ATOMIC)
((so)->so_proto->pr_flags & PR_ATOMIC)
/* can we read something from so? */
#define soreadable(so) \
((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
((so)->so_state & SS_CANTRCVMORE) || \
(so)->so_qlen || (so)->so_error)
((so)->so_rcv.sb_cc >= (so)->so_rcv.sb_lowat || \
((so)->so_state & SS_CANTRCVMORE) || \
(so)->so_qlen || (so)->so_error)
/* can we write something to so? */
#define sowriteable(so) \
((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
(((so)->so_state&SS_ISCONNECTED) || \
((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
((so)->so_state & SS_CANTSENDMORE) || \
(so)->so_error)
((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
(((so)->so_state&SS_ISCONNECTED) || \
((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
((so)->so_state & SS_CANTSENDMORE) || \
(so)->so_error)
/* adjust counters in sb reflecting allocation of m */
#define sballoc(sb, m) { \
(sb)->sb_cc += (m)->m_len; \
(sb)->sb_mbcnt += MSIZE; \
if ((m)->m_flags & M_EXT) \
(sb)->sb_mbcnt += (m)->m_ext.ext_size; \
}
#define sballoc(sb, m) \
do { \
(sb)->sb_cc += (m)->m_len; \
(sb)->sb_mbcnt += MSIZE; \
if ((m)->m_flags & M_EXT) \
(sb)->sb_mbcnt += (m)->m_ext.ext_size; \
} while (0)
/* adjust counters in sb reflecting freeing of m */
#define sbfree(sb, m) { \
(sb)->sb_cc -= (m)->m_len; \
(sb)->sb_mbcnt -= MSIZE; \
if ((m)->m_flags & M_EXT) \
(sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
}
#define sbfree(sb, m) \
do { \
(sb)->sb_cc -= (m)->m_len; \
(sb)->sb_mbcnt -= MSIZE; \
if ((m)->m_flags & M_EXT) \
(sb)->sb_mbcnt -= (m)->m_ext.ext_size; \
} while (0)
/*
* Set lock on sockbuf sb; sleep if lock is already held.
* Unless SB_NOINTR is set on sockbuf, sleep is interruptible.
* Returns error without lock if sleep is interrupted.
*/
#define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
(((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
((sb)->sb_flags |= SB_LOCK), 0)
#define sblock(sb, wf) \
((sb)->sb_flags & SB_LOCK ? \
(((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
((sb)->sb_flags |= SB_LOCK), 0)
/* release lock on sockbuf sb */
#define sbunlock(sb) { \
(sb)->sb_flags &= ~SB_LOCK; \
if ((sb)->sb_flags & SB_WANT) { \
(sb)->sb_flags &= ~SB_WANT; \
wakeup((caddr_t)&(sb)->sb_flags); \
} \
}
#define sbunlock(sb) \
do { \
(sb)->sb_flags &= ~SB_LOCK; \
if ((sb)->sb_flags & SB_WANT) { \
(sb)->sb_flags &= ~SB_WANT; \
wakeup((caddr_t)&(sb)->sb_flags); \
} \
} while (0)
#define sorwakeup(so) do { \
if (sb_notify(&(so)->so_rcv)) \
sowakeup((so), &(so)->so_rcv); \
} while (0)
#define sorwakeup(so) \
do { \
if (sb_notify(&(so)->so_rcv)) \
sowakeup((so), &(so)->so_rcv); \
} while (0)
#define sowwakeup(so) do { \
if (sb_notify(&(so)->so_snd)) \
sowakeup((so), &(so)->so_snd); \
} while (0)
#define sowwakeup(so) \
do { \
if (sb_notify(&(so)->so_snd)) \
sowakeup((so), &(so)->so_snd); \
} while (0)
#ifdef _KERNEL
extern u_long sb_max;
extern u_long sb_max;
/* to catch callers missing new second argument to sonewconn: */
#define sonewconn(head, connstatus) sonewconn1((head), (connstatus))
/* strings for sleep message: */
extern const char netio[], netcon[], netcls[];
extern const char netio[], netcon[], netcls[];
extern struct pool socket_pool;
extern struct pool socket_pool;
struct mbuf;
struct sockaddr;
@ -241,77 +252,72 @@ struct stat;
/*
* File operations on sockets.
*/
int soo_read __P((struct file *fp, off_t *offset, struct uio *uio,
struct ucred *cred, int flags));
int soo_write __P((struct file *fp, off_t *offset, struct uio *uio,
struct ucred *cred, int flags));
int soo_fcntl __P((struct file *fp, u_int cmd, caddr_t data,
struct proc *p));
int soo_ioctl __P((struct file *fp, u_long cmd, caddr_t data,
struct proc *p));
int soo_poll __P((struct file *fp, int events, struct proc *p));
int soo_close __P((struct file *fp, struct proc *p));
int soo_stat __P((struct socket *, struct stat *));
int uipc_usrreq __P((struct socket *, int , struct mbuf *,
struct mbuf *, struct mbuf *, struct proc *));
int uipc_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
void sbappend __P((struct sockbuf *sb, struct mbuf *m));
int sbappendaddr __P((struct sockbuf *sb, struct sockaddr *asa,
struct mbuf *m0, struct mbuf *control));
int sbappendcontrol __P((struct sockbuf *sb, struct mbuf *m0,
struct mbuf *control));
void sbappendrecord __P((struct sockbuf *sb, struct mbuf *m0));
void sbcheck __P((struct sockbuf *sb));
void sbcompress __P((struct sockbuf *sb, struct mbuf *m, struct mbuf *n));
int soo_read(struct file *fp, off_t *offset, struct uio *uio,
struct ucred *cred, int flags);
int soo_write(struct file *fp, off_t *offset, struct uio *uio,
struct ucred *cred, int flags);
int soo_fcntl(struct file *fp, u_int cmd, caddr_t data, struct proc *p);
int soo_ioctl(struct file *fp, u_long cmd, caddr_t data, struct proc *p);
int soo_poll(struct file *fp, int events, struct proc *p);
int soo_close(struct file *fp, struct proc *p);
int soo_stat(struct socket *, struct stat *);
int uipc_usrreq(struct socket *, int , struct mbuf *,
struct mbuf *, struct mbuf *, struct proc *);
int uipc_ctloutput(int, struct socket *, int, int, struct mbuf **);
void sbappend(struct sockbuf *sb, struct mbuf *m);
int sbappendaddr(struct sockbuf *sb, struct sockaddr *asa,
struct mbuf *m0, struct mbuf *control);
int sbappendcontrol(struct sockbuf *sb, struct mbuf *m0,
struct mbuf *control);
void sbappendrecord(struct sockbuf *sb, struct mbuf *m0);
void sbcheck(struct sockbuf *sb);
void sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n);
struct mbuf *
sbcreatecontrol __P((caddr_t p, int size, int type, int level));
void sbdrop __P((struct sockbuf *sb, int len));
void sbdroprecord __P((struct sockbuf *sb));
void sbflush __P((struct sockbuf *sb));
void sbinsertoob __P((struct sockbuf *sb, struct mbuf *m0));
void sbrelease __P((struct sockbuf *sb));
int sbreserve __P((struct sockbuf *sb, u_long cc));
int sbwait __P((struct sockbuf *sb));
int sb_lock __P((struct sockbuf *sb));
void soinit __P((void));
int soabort __P((struct socket *so));
int soaccept __P((struct socket *so, struct mbuf *nam));
int sobind __P((struct socket *so, struct mbuf *nam, struct proc *));
void socantrcvmore __P((struct socket *so));
void socantsendmore __P((struct socket *so));
int soclose __P((struct socket *so));
int soconnect __P((struct socket *so, struct mbuf *nam));
int soconnect2 __P((struct socket *so1, struct socket *so2));
int socreate __P((int dom, struct socket **aso, int type, int proto));
int sodisconnect __P((struct socket *so));
void sofree __P((struct socket *so));
int sogetopt __P((struct socket *so, int level, int optname,
struct mbuf **mp));
void sohasoutofband __P((struct socket *so));
void soisconnected __P((struct socket *so));
void soisconnecting __P((struct socket *so));
void soisdisconnected __P((struct socket *so));
void soisdisconnecting __P((struct socket *so));
int solisten __P((struct socket *so, int backlog));
sbcreatecontrol(caddr_t p, int size, int type, int level);
void sbdrop(struct sockbuf *sb, int len);
void sbdroprecord(struct sockbuf *sb);
void sbflush(struct sockbuf *sb);
void sbinsertoob(struct sockbuf *sb, struct mbuf *m0);
void sbrelease(struct sockbuf *sb);
int sbreserve(struct sockbuf *sb, u_long cc);
int sbwait(struct sockbuf *sb);
int sb_lock(struct sockbuf *sb);
void soinit(void);
int soabort(struct socket *so);
int soaccept(struct socket *so, struct mbuf *nam);
int sobind(struct socket *so, struct mbuf *nam, struct proc *);
void socantrcvmore(struct socket *so);
void socantsendmore(struct socket *so);
int soclose(struct socket *so);
int soconnect(struct socket *so, struct mbuf *nam);
int soconnect2(struct socket *so1, struct socket *so2);
int socreate(int dom, struct socket **aso, int type, int proto);
int sodisconnect(struct socket *so);
void sofree(struct socket *so);
int sogetopt(struct socket *so, int level, int optname, struct mbuf **mp);
void sohasoutofband(struct socket *so);
void soisconnected(struct socket *so);
void soisconnecting(struct socket *so);
void soisdisconnected(struct socket *so);
void soisdisconnecting(struct socket *so);
int solisten(struct socket *so, int backlog);
struct socket *
sonewconn1 __P((struct socket *head, int connstatus));
void soqinsque __P((struct socket *head, struct socket *so, int q));
int soqremque __P((struct socket *so, int q));
int soreceive __P((struct socket *so, struct mbuf **paddr, struct uio *uio,
struct mbuf **mp0, struct mbuf **controlp, int *flagsp));
int soreserve __P((struct socket *so, u_long sndcc, u_long rcvcc));
void sorflush __P((struct socket *so));
int sosend __P((struct socket *so, struct mbuf *addr, struct uio *uio,
struct mbuf *top, struct mbuf *control, int flags));
int sosetopt __P((struct socket *so, int level, int optname,
struct mbuf *m0));
int soshutdown __P((struct socket *so, int how));
void sowakeup __P((struct socket *so, struct sockbuf *sb));
int sockargs __P((struct mbuf **, const void *, int, int));
sonewconn1(struct socket *head, int connstatus);
void soqinsque(struct socket *head, struct socket *so, int q);
int soqremque(struct socket *so, int q);
int soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
struct mbuf **mp0, struct mbuf **controlp, int *flagsp);
int soreserve(struct socket *so, u_long sndcc, u_long rcvcc);
void sorflush(struct socket *so);
int sosend(struct socket *so, struct mbuf *addr, struct uio *uio,
struct mbuf *top, struct mbuf *control, int flags);
int sosetopt(struct socket *so, int level, int optname, struct mbuf *m0);
int soshutdown(struct socket *so, int how);
void sowakeup(struct socket *so, struct sockbuf *sb);
int sockargs(struct mbuf **, const void *, int, int);
int sendit __P((struct proc *, int, struct msghdr *, int, register_t *));
int recvit __P((struct proc *, int, struct msghdr *, caddr_t,
register_t *));
int sendit(struct proc *, int, struct msghdr *, int, register_t *);
int recvit(struct proc *, int, struct msghdr *, caddr_t, register_t *);
#endif /* _KERNEL */