SCCS-vsn: sys/kern/kern_descrip.c 8.8
SCCS-vsn: sys/kern/kern_fork.c 8.8
SCCS-vsn: sys/kern/kern_proc.c 8.7
SCCS-vsn: sys/kern/kern_subr.c 8.4
SCCS-vsn: sys/kern/kern_synch.c 8.8
SCCS-vsn: sys/kern/kern_time.c 8.3
SCCS-vsn: sys/kern/kern_xxx.c 8.3
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_descrip.c 8.7 (Berkeley) %G%
+ * @(#)kern_descrip.c 8.8 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#include <sys/unistd.h>
#include <sys/resourcevar.h>
#include <sys/unistd.h>
#include <sys/resourcevar.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
/*
* Descriptor management.
*/
/*
* Descriptor management.
*/
/*
* System calls on descriptors.
*/
/*
* System calls on descriptors.
*/
-struct getdtablesize_args {
- int dummy;
-};
getdtablesize(p, uap, retval)
struct proc *p;
getdtablesize(p, uap, retval)
struct proc *p;
- struct getdtablesize_args *uap;
- int *retval;
+ void *uap;
+ register_t *retval;
{
*retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles);
{
*retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles);
/*
* Duplicate a file descriptor.
*/
/*
* Duplicate a file descriptor.
*/
-struct dup_args {
- u_int fd;
-};
dup(p, uap, retval)
struct proc *p;
dup(p, uap, retval)
struct proc *p;
- struct dup_args *uap;
- int *retval;
+ struct dup_args /* {
+ syscallarg(u_int) fd;
+ } */ *uap;
+ register_t *retval;
{
register struct filedesc *fdp;
u_int old;
int new, error;
{
register struct filedesc *fdp;
u_int old;
int new, error;
/*
* XXX Compatibility
*/
/*
* XXX Compatibility
*/
- if (old &~ 077) { uap->fd &= 077; return (dup2(p, uap, retval)); }
+ if (old &~ 077) {
+ SCARG(uap, fd) &= 077;
+ return (dup2(p, uap, retval));
+ }
fdp = p->p_fd;
if (old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL)
fdp = p->p_fd;
if (old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL)
/*
* Duplicate a file descriptor to a particular value.
*/
/*
* Duplicate a file descriptor to a particular value.
*/
-struct dup2_args {
- u_int from;
- u_int to;
-};
dup2(p, uap, retval)
struct proc *p;
dup2(p, uap, retval)
struct proc *p;
- struct dup2_args *uap;
- int *retval;
+ struct dup2_args /* {
+ syscallarg(u_int) from;
+ syscallarg(u_int) to;
+ } */ *uap;
+ register_t *retval;
{
register struct filedesc *fdp = p->p_fd;
{
register struct filedesc *fdp = p->p_fd;
- register u_int old = uap->from, new = uap->to;
+ register int old = SCARG(uap, from), new = SCARG(uap, to);
int i, error;
if (old >= fdp->fd_nfiles ||
int i, error;
if (old >= fdp->fd_nfiles ||
/*
* The file control system call.
*/
/*
* The file control system call.
*/
-struct fcntl_args {
- int fd;
- int cmd;
- int arg;
-};
fcntl(p, uap, retval)
struct proc *p;
fcntl(p, uap, retval)
struct proc *p;
- register struct fcntl_args *uap;
- int *retval;
+ register struct fcntl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+ } */ *uap;
+ register_t *retval;
+ int fd = SCARG(uap, fd);
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register char *pop;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register char *pop;
struct flock fl;
u_int newmin;
struct flock fl;
u_int newmin;
- if ((unsigned)uap->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fd]) == NULL)
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
- pop = &fdp->fd_ofileflags[uap->fd];
- switch (uap->cmd) {
+ pop = &fdp->fd_ofileflags[fd];
+ switch (SCARG(uap, cmd)) {
+ newmin = (long)SCARG(uap, arg);
if (newmin >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur ||
newmin >= maxfiles)
return (EINVAL);
if (error = fdalloc(p, newmin, &i))
return (error);
if (newmin >= p->p_rlimit[RLIMIT_NOFILE].rlim_cur ||
newmin >= maxfiles)
return (EINVAL);
if (error = fdalloc(p, newmin, &i))
return (error);
- return (finishdup(fdp, uap->fd, i, retval));
+ return (finishdup(fdp, fd, i, retval));
case F_GETFD:
*retval = *pop & 1;
return (0);
case F_SETFD:
case F_GETFD:
*retval = *pop & 1;
return (0);
case F_SETFD:
- *pop = (*pop &~ 1) | (uap->arg & 1);
+ *pop = (*pop &~ 1) | ((long)SCARG(uap, arg) & 1);
return (0);
case F_GETFL:
return (0);
case F_GETFL:
case F_SETFL:
fp->f_flag &= ~FCNTLFLAGS;
case F_SETFL:
fp->f_flag &= ~FCNTLFLAGS;
- fp->f_flag |= FFLAGS(uap->arg) & FCNTLFLAGS;
+ fp->f_flag |= FFLAGS((long)SCARG(uap, arg)) & FCNTLFLAGS;
tmp = fp->f_flag & FNONBLOCK;
error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&tmp, p);
if (error)
tmp = fp->f_flag & FNONBLOCK;
error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&tmp, p);
if (error)
return (0);
}
error = (*fp->f_ops->fo_ioctl)
return (0);
}
error = (*fp->f_ops->fo_ioctl)
- (fp, (int)TIOCGPGRP, (caddr_t)retval, p);
+ (fp, TIOCGPGRP, (caddr_t)retval, p);
*retval = -*retval;
return (error);
case F_SETOWN:
if (fp->f_type == DTYPE_SOCKET) {
*retval = -*retval;
return (error);
case F_SETOWN:
if (fp->f_type == DTYPE_SOCKET) {
- ((struct socket *)fp->f_data)->so_pgid = uap->arg;
+ ((struct socket *)fp->f_data)->so_pgid =
+ (long)SCARG(uap, arg);
- if (uap->arg <= 0) {
- uap->arg = -uap->arg;
+ if ((long)SCARG(uap, arg) <= 0) {
+ SCARG(uap, arg) = (void *)(-(long)SCARG(uap, arg));
- struct proc *p1 = pfind(uap->arg);
+ struct proc *p1 = pfind((long)SCARG(uap, arg));
if (p1 == 0)
return (ESRCH);
if (p1 == 0)
return (ESRCH);
- uap->arg = p1->p_pgrp->pg_id;
+ SCARG(uap, arg) = (void *)(long)p1->p_pgrp->pg_id;
}
return ((*fp->f_ops->fo_ioctl)
}
return ((*fp->f_ops->fo_ioctl)
- (fp, (int)TIOCSPGRP, (caddr_t)&uap->arg, p));
+ (fp, TIOCSPGRP, (caddr_t)&SCARG(uap, arg), p));
case F_SETLKW:
flg |= F_WAIT;
case F_SETLKW:
flg |= F_WAIT;
return (EBADF);
vp = (struct vnode *)fp->f_data;
/* Copy in the lock structure */
return (EBADF);
vp = (struct vnode *)fp->f_data;
/* Copy in the lock structure */
- error = copyin((caddr_t)uap->arg, (caddr_t)&fl, sizeof (fl));
+ error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&fl,
+ sizeof (fl));
if (error)
return (error);
if (fl.l_whence == SEEK_CUR)
if (error)
return (error);
if (fl.l_whence == SEEK_CUR)
return (EBADF);
vp = (struct vnode *)fp->f_data;
/* Copy in the lock structure */
return (EBADF);
vp = (struct vnode *)fp->f_data;
/* Copy in the lock structure */
- error = copyin((caddr_t)uap->arg, (caddr_t)&fl, sizeof (fl));
+ error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&fl,
+ sizeof (fl));
if (error)
return (error);
if (fl.l_whence == SEEK_CUR)
fl.l_start += fp->f_offset;
if (error = VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX))
return (error);
if (error)
return (error);
if (fl.l_whence == SEEK_CUR)
fl.l_start += fp->f_offset;
if (error = VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX))
return (error);
- return (copyout((caddr_t)&fl, (caddr_t)uap->arg, sizeof (fl)));
+ return (copyout((caddr_t)&fl, (caddr_t)SCARG(uap, arg),
+ sizeof (fl)));
default:
return (EINVAL);
default:
return (EINVAL);
int
finishdup(fdp, old, new, retval)
register struct filedesc *fdp;
int
finishdup(fdp, old, new, retval)
register struct filedesc *fdp;
- register int old, new, *retval;
+ register int old, new;
+ register_t *retval;
{
register struct file *fp;
{
register struct file *fp;
/*
* Close a file descriptor.
*/
/*
* Close a file descriptor.
*/
-struct close_args {
- int fd;
-};
close(p, uap, retval)
struct proc *p;
close(p, uap, retval)
struct proc *p;
- struct close_args *uap;
- int *retval;
+ struct close_args /* {
+ syscallarg(int) fd;
+ } */ *uap;
+ register_t *retval;
+ int fd = SCARG(uap, fd);
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
- register int fd = uap->fd;
- if ((unsigned)fd >= fdp->fd_nfiles ||
+ if ((u_int)fd >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
pf = (u_char *)&fdp->fd_ofileflags[fd];
(fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
pf = (u_char *)&fdp->fd_ofileflags[fd];
/*
* Return status information about a file descriptor.
*/
/*
* Return status information about a file descriptor.
*/
-struct ofstat_args {
- int fd;
- struct ostat *sb;
-};
+int
+compat_43_fstat(p, uap, retval)
- register struct ofstat_args *uap;
- int *retval;
+ register struct compat_43_fstat_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct ostat *) sb;
+ } */ *uap;
+ register_t *retval;
+ int fd = SCARG(uap, fd);
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct stat ub;
struct ostat oub;
int error;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct stat ub;
struct ostat oub;
int error;
- if ((unsigned)uap->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fd]) == NULL)
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
switch (fp->f_type) {
return (EBADF);
switch (fp->f_type) {
}
cvtstat(&ub, &oub);
if (error == 0)
}
cvtstat(&ub, &oub);
if (error == 0)
- error = copyout((caddr_t)&oub, (caddr_t)uap->sb, sizeof (oub));
+ error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb),
+ sizeof (oub));
return (error);
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
return (error);
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
/*
* Return status information about a file descriptor.
*/
/*
* Return status information about a file descriptor.
*/
-struct fstat_args {
- int fd;
- struct stat *sb;
-};
fstat(p, uap, retval)
struct proc *p;
fstat(p, uap, retval)
struct proc *p;
- register struct fstat_args *uap;
- int *retval;
+ register struct fstat_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct stat *) sb;
+ } */ *uap;
+ register_t *retval;
+ int fd = SCARG(uap, fd);
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct stat ub;
int error;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct stat ub;
int error;
- if ((unsigned)uap->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fd]) == NULL)
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
switch (fp->f_type) {
return (EBADF);
switch (fp->f_type) {
/*NOTREACHED*/
}
if (error == 0)
/*NOTREACHED*/
}
if (error == 0)
- error = copyout((caddr_t)&ub, (caddr_t)uap->sb, sizeof (ub));
+ error = copyout((caddr_t)&ub, (caddr_t)SCARG(uap, sb),
+ sizeof (ub));
return (error);
}
/*
* Return pathconf information about a file descriptor.
*/
return (error);
}
/*
* Return pathconf information about a file descriptor.
*/
-struct fpathconf_args {
- int fd;
- int name;
-};
fpathconf(p, uap, retval)
struct proc *p;
fpathconf(p, uap, retval)
struct proc *p;
- register struct fpathconf_args *uap;
- int *retval;
+ register struct fpathconf_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) name;
+ } */ *uap;
+ register_t *retval;
+ int fd = SCARG(uap, fd);
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct vnode *vp;
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct vnode *vp;
- if ((unsigned)uap->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fd]) == NULL)
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
switch (fp->f_type) {
case DTYPE_SOCKET:
return (EBADF);
switch (fp->f_type) {
case DTYPE_SOCKET:
- if (uap->name != _PC_PIPE_BUF)
+ if (SCARG(uap, name) != _PC_PIPE_BUF)
return (EINVAL);
*retval = PIPE_BUF;
return (0);
case DTYPE_VNODE:
vp = (struct vnode *)fp->f_data;
return (EINVAL);
*retval = PIPE_BUF;
return (0);
case DTYPE_VNODE:
vp = (struct vnode *)fp->f_data;
- return (VOP_PATHCONF(vp, uap->name, retval));
+ return (VOP_PATHCONF(vp, SCARG(uap, name), retval));
default:
panic("fpathconf");
default:
panic("fpathconf");
fdalloc(p, want, result)
struct proc *p;
int want;
fdalloc(p, want, result)
struct proc *p;
int want;
* Check to see whether n user file descriptors
* are available to the process p.
*/
* Check to see whether n user file descriptors
* are available to the process p.
*/
fdavail(p, n)
struct proc *p;
register int n;
fdavail(p, n)
struct proc *p;
register int n;
* Create a new open file structure and allocate
* a file decriptor for the process that refers to it.
*/
* Create a new open file structure and allocate
* a file decriptor for the process that refers to it.
*/
falloc(p, resultfp, resultfd)
register struct proc *p;
struct file **resultfp;
falloc(p, resultfp, resultfd)
register struct proc *p;
struct file **resultfp;
/*
* Free a file descriptor.
*/
/*
* Free a file descriptor.
*/
ffree(fp)
register struct file *fp;
{
ffree(fp)
register struct file *fp;
{
* Note: p may be NULL when closing a file
* that was being passed in a message.
*/
* Note: p may be NULL when closing a file
* that was being passed in a message.
*/
closef(fp, p)
register struct file *fp;
register struct proc *p;
closef(fp, p)
register struct file *fp;
register struct proc *p;
* Just attempt to get a record lock of the requested type on
* the entire file (l_whence = SEEK_SET, l_start = 0, l_len = 0).
*/
* Just attempt to get a record lock of the requested type on
* the entire file (l_whence = SEEK_SET, l_start = 0, l_len = 0).
*/
-struct flock_args {
- int fd;
- int how;
-};
flock(p, uap, retval)
struct proc *p;
flock(p, uap, retval)
struct proc *p;
- register struct flock_args *uap;
- int *retval;
+ register struct flock_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) how;
+ } */ *uap;
+ register_t *retval;
+ int fd = SCARG(uap, fd);
+ int how = SCARG(uap, how);
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct vnode *vp;
struct flock lf;
register struct filedesc *fdp = p->p_fd;
register struct file *fp;
struct vnode *vp;
struct flock lf;
- if ((unsigned)uap->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[uap->fd]) == NULL)
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
return (EBADF);
if (fp->f_type != DTYPE_VNODE)
return (EOPNOTSUPP);
return (EBADF);
if (fp->f_type != DTYPE_VNODE)
return (EOPNOTSUPP);
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
- if (uap->how & LOCK_UN) {
lf.l_type = F_UNLCK;
fp->f_flag &= ~FHASLOCK;
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK));
}
lf.l_type = F_UNLCK;
fp->f_flag &= ~FHASLOCK;
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK));
}
- if (uap->how & LOCK_EX)
- else if (uap->how & LOCK_SH)
+ else if (how & LOCK_SH)
lf.l_type = F_RDLCK;
else
return (EBADF);
fp->f_flag |= FHASLOCK;
lf.l_type = F_RDLCK;
else
return (EBADF);
fp->f_flag |= FHASLOCK;
- if (uap->how & LOCK_NB)
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK));
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK|F_WAIT));
}
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK));
return (VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, F_FLOCK|F_WAIT));
}
* references to this file will be direct to the other driver.
*/
/* ARGSUSED */
* references to this file will be direct to the other driver.
*/
/* ARGSUSED */
fdopen(dev, mode, type, p)
dev_t dev;
int mode, type;
fdopen(dev, mode, type, p)
dev_t dev;
int mode, type;
/*
* Duplicate the specified descriptor to a free descriptor.
*/
/*
* Duplicate the specified descriptor to a free descriptor.
*/
dupfdopen(fdp, indx, dfd, mode, error)
register struct filedesc *fdp;
register int indx, dfd;
dupfdopen(fdp, indx, dfd, mode, error)
register struct filedesc *fdp;
register int indx, dfd;
{
register struct file *wfp;
struct file *fp;
{
register struct file *wfp;
struct file *fp;
/*
* If the to-be-dup'd fd number is greater than the allowed number
* of file descriptors, or the fd to be dup'd has already been
/*
* If the to-be-dup'd fd number is greater than the allowed number
* of file descriptors, or the fd to be dup'd has already been
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_fork.c 8.7 (Berkeley) %G%
+ * @(#)kern_fork.c 8.8 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#include <sys/acct.h>
#include <sys/ktrace.h>
#include <sys/acct.h>
#include <sys/ktrace.h>
-struct fork_args {
- int dummy;
-};
/* ARGSUSED */
fork(p, uap, retval)
struct proc *p;
/* ARGSUSED */
fork(p, uap, retval)
struct proc *p;
- struct fork_args *uap;
- int retval[];
+ void *uap;
+ register_t *retval;
{
return (fork1(p, 0, retval));
{
return (fork1(p, 0, retval));
/* ARGSUSED */
vfork(p, uap, retval)
struct proc *p;
/* ARGSUSED */
vfork(p, uap, retval)
struct proc *p;
- struct fork_args *uap;
- int retval[];
+ void *uap;
+ register_t *retval;
{
return (fork1(p, 1, retval));
{
return (fork1(p, 1, retval));
fork1(p1, isvfork, retval)
register struct proc *p1;
fork1(p1, isvfork, retval)
register struct proc *p1;
+ int isvfork;
+ register_t *retval;
{
register struct proc *p2;
register uid_t uid;
{
register struct proc *p2;
register uid_t uid;
tablefull("proc");
return (EAGAIN);
}
tablefull("proc");
return (EAGAIN);
}
/*
* Increment the count of procs running with this uid. Don't allow
* a nonprivileged user to exceed their current limit.
/*
* Increment the count of procs running with this uid. Don't allow
* a nonprivileged user to exceed their current limit.
nprocs++;
p2 = newproc;
p2->p_stat = SIDL; /* protect against others */
nprocs++;
p2 = newproc;
p2->p_stat = SIDL; /* protect against others */
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_proc.c 8.6 (Berkeley) %G%
+ * @(#)kern_proc.c 8.7 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
/*
* Move p to a new or existing process group (and session)
*/
/*
* Move p to a new or existing process group (and session)
*/
enterpgrp(p, pgid, mksess)
register struct proc *p;
pid_t pgid;
int mksess;
{
register struct pgrp *pgrp = pgfind(pgid);
enterpgrp(p, pgid, mksess)
register struct proc *p;
pid_t pgid;
int mksess;
{
register struct pgrp *pgrp = pgfind(pgid);
#ifdef DIAGNOSTIC
if (pgrp != NULL && mksess) /* firewalls */
#ifdef DIAGNOSTIC
if (pgrp != NULL && mksess) /* firewalls */
/*
* remove process from process group
*/
/*
* remove process from process group
*/
leavepgrp(p)
register struct proc *p;
{
leavepgrp(p)
register struct proc *p;
{
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_subr.c 8.3 (Berkeley) %G%
+ * @(#)kern_subr.c 8.4 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/queue.h>
#include <sys/malloc.h>
#include <sys/queue.h>
uiomove(cp, n, uio)
register caddr_t cp;
register int n;
uiomove(cp, n, uio)
register caddr_t cp;
register int n;
/*
* Give next character to user as result of read.
*/
/*
* Give next character to user as result of read.
*/
ureadc(c, uio)
register int c;
register struct uio *uio;
{
register struct iovec *iov;
ureadc(c, uio)
register int c;
register struct uio *uio;
{
register struct iovec *iov;
+ if (uio->uio_resid <= 0)
+ panic("ureadc: non-positive resid");
- if (uio->uio_iovcnt == 0 || uio->uio_resid == 0)
- panic("ureadc");
+ if (uio->uio_iovcnt <= 0)
+ panic("ureadc: non-positive iovcnt");
- if (iov->iov_len == 0) {
+ if (iov->iov_len <= 0) {
uio->uio_iovcnt--;
uio->uio_iov++;
goto again;
uio->uio_iovcnt--;
uio->uio_iov++;
goto again;
/*
* Get next character written in by user from uio.
*/
/*
* Get next character written in by user from uio.
*/
uwritec(uio)
struct uio *uio;
{
uwritec(uio)
struct uio *uio;
{
return (-1);
again:
if (uio->uio_iovcnt <= 0)
return (-1);
again:
if (uio->uio_iovcnt <= 0)
+ panic("uwritec: non-positive iovcnt");
iov = uio->uio_iov;
if (iov->iov_len == 0) {
uio->uio_iov++;
iov = uio->uio_iov;
if (iov->iov_len == 0) {
uio->uio_iov++;
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_synch.c 8.7 (Berkeley) %G%
+ * @(#)kern_synch.c 8.8 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
* of 2. Shift right by 8, i.e. drop the bottom 256 worth.
*/
#define TABLESIZE 128
* of 2. Shift right by 8, i.e. drop the bottom 256 worth.
*/
#define TABLESIZE 128
-#define LOOKUP(x) (((int)(x) >> 8) & (TABLESIZE - 1))
+#define LOOKUP(x) (((long)(x) >> 8) & (TABLESIZE - 1))
struct slpque {
struct proc *sq_head;
struct proc **sq_tailp;
struct slpque {
struct proc *sq_head;
struct proc **sq_tailp;
* Initialize the (doubly-linked) run queues
* to be empty.
*/
* Initialize the (doubly-linked) run queues
* to be empty.
*/
rqinit()
{
register int i;
rqinit()
{
register int i;
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_time.c 8.2 (Berkeley) %G%
+ * @(#)kern_time.c 8.3 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/proc.h>
#include <sys/vnode.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
/*
* Time of day and interval timer support.
/*
* Time of day and interval timer support.
* timers when they expire.
*/
* timers when they expire.
*/
-struct gettimeofday_args {
- struct timeval *tp;
- struct timezone *tzp;
-};
gettimeofday(p, uap, retval)
struct proc *p;
gettimeofday(p, uap, retval)
struct proc *p;
- register struct gettimeofday_args *uap;
- int *retval;
+ register struct gettimeofday_args /* {
+ syscallarg(struct timeval *) tp;
+ syscallarg(struct timezone *) tzp;
+ } */ *uap;
+ register_t *retval;
{
struct timeval atv;
int error = 0;
{
struct timeval atv;
int error = 0;
- if (error = copyout((caddr_t)&atv, (caddr_t)uap->tp,
+ if (error = copyout((caddr_t)&atv, (caddr_t)SCARG(uap, tp),
sizeof (atv)))
return (error);
}
sizeof (atv)))
return (error);
}
- if (uap->tzp)
- error = copyout((caddr_t)&tz, (caddr_t)uap->tzp,
+ if (SCARG(uap, tzp))
+ error = copyout((caddr_t)&tz, (caddr_t)SCARG(uap, tzp),
sizeof (tz));
return (error);
}
sizeof (tz));
return (error);
}
-struct settimeofday_args {
- struct timeval *tv;
- struct timezone *tzp;
-};
settimeofday(p, uap, retval)
struct proc *p;
settimeofday(p, uap, retval)
struct proc *p;
- struct settimeofday_args *uap;
- int *retval;
+ struct settimeofday_args /* {
+ syscallarg(struct timeval *) tv;
+ syscallarg(struct timezone *) tzp;
+ } */ *uap;
+ register_t *retval;
{
struct timeval atv, delta;
struct timezone atz;
{
struct timeval atv, delta;
struct timezone atz;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
/* Verify all parameters before changing time. */
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
/* Verify all parameters before changing time. */
- if (uap->tv &&
- (error = copyin((caddr_t)uap->tv, (caddr_t)&atv, sizeof(atv))))
+ if (SCARG(uap, tv) && (error = copyin((caddr_t)SCARG(uap, tv),
+ (caddr_t)&atv, sizeof(atv))))
- if (uap->tzp &&
- (error = copyin((caddr_t)uap->tzp, (caddr_t)&atz, sizeof(atz))))
+ if (SCARG(uap, tzp) && (error = copyin((caddr_t)SCARG(uap, tzp),
+ (caddr_t)&atz, sizeof(atz))))
/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
s = splclock();
/* nb. delta.tv_usec may be < 0, but this is OK here */
/* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
s = splclock();
/* nb. delta.tv_usec may be < 0, but this is OK here */
long timedelta; /* unapplied time correction, us. */
long bigadj = 1000000; /* use 10x skew above bigadj us. */
long timedelta; /* unapplied time correction, us. */
long bigadj = 1000000; /* use 10x skew above bigadj us. */
-struct adjtime_args {
- struct timeval *delta;
- struct timeval *olddelta;
-};
adjtime(p, uap, retval)
struct proc *p;
adjtime(p, uap, retval)
struct proc *p;
- register struct adjtime_args *uap;
- int *retval;
+ register struct adjtime_args /* {
+ syscallarg(struct timeval *) delta;
+ syscallarg(struct timeval *) olddelta;
+ } */ *uap;
+ register_t *retval;
{
struct timeval atv;
register long ndelta, ntickdelta, odelta;
{
struct timeval atv;
register long ndelta, ntickdelta, odelta;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
- if (error =
- copyin((caddr_t)uap->delta, (caddr_t)&atv, sizeof(struct timeval)))
+ if (error = copyin((caddr_t)SCARG(uap, delta), (caddr_t)&atv,
+ sizeof(struct timeval)))
tickdelta = ntickdelta;
splx(s);
tickdelta = ntickdelta;
splx(s);
+ if (SCARG(uap, olddelta)) {
atv.tv_sec = odelta / 1000000;
atv.tv_usec = odelta % 1000000;
atv.tv_sec = odelta / 1000000;
atv.tv_usec = odelta % 1000000;
- (void) copyout((caddr_t)&atv, (caddr_t)uap->olddelta,
+ (void) copyout((caddr_t)&atv, (caddr_t)SCARG(uap, olddelta),
sizeof(struct timeval));
}
return (0);
sizeof(struct timeval));
}
return (0);
* real time timers .it_interval. Rather, we compute the next time in
* absolute time the timer should go off.
*/
* real time timers .it_interval. Rather, we compute the next time in
* absolute time the timer should go off.
*/
-struct getitimer_args {
- u_int which;
- struct itimerval *itv;
-};
getitimer(p, uap, retval)
struct proc *p;
getitimer(p, uap, retval)
struct proc *p;
- register struct getitimer_args *uap;
- int *retval;
+ register struct getitimer_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct itimerval *) itv;
+ } */ *uap;
+ register_t *retval;
{
struct itimerval aitv;
int s;
{
struct itimerval aitv;
int s;
- if (uap->which > ITIMER_PROF)
+ if (SCARG(uap, which) > ITIMER_PROF)
return (EINVAL);
s = splclock();
return (EINVAL);
s = splclock();
- if (uap->which == ITIMER_REAL) {
+ if (SCARG(uap, which) == ITIMER_REAL) {
- * Convert from absoulte to relative time in .it_value
+ * Convert from absolute to relative time in .it_value
* part of real time timer. If time for real time timer
* has passed return 0, else return difference between
* current time and time for the timer to go off.
* part of real time timer. If time for real time timer
* has passed return 0, else return difference between
* current time and time for the timer to go off.
timevalsub(&aitv.it_value,
(struct timeval *)&time);
} else
timevalsub(&aitv.it_value,
(struct timeval *)&time);
} else
- aitv = p->p_stats->p_timer[uap->which];
+ aitv = p->p_stats->p_timer[SCARG(uap, which)];
- return (copyout((caddr_t)&aitv, (caddr_t)uap->itv,
+ return (copyout((caddr_t)&aitv, (caddr_t)SCARG(uap, itv),
sizeof (struct itimerval)));
}
sizeof (struct itimerval)));
}
-struct setitimer_args {
- u_int which;
- struct itimerval *itv, *oitv;
-};
setitimer(p, uap, retval)
struct proc *p;
setitimer(p, uap, retval)
struct proc *p;
- register struct setitimer_args *uap;
- int *retval;
+ register struct setitimer_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct itimerval *) itv;
+ syscallarg(struct itimerval *) oitv;
+ } */ *uap;
+ register_t *retval;
{
struct itimerval aitv;
register struct itimerval *itvp;
int s, error;
{
struct itimerval aitv;
register struct itimerval *itvp;
int s, error;
- if (uap->which > ITIMER_PROF)
+ if (SCARG(uap, which) > ITIMER_PROF)
+ itvp = SCARG(uap, itv);
if (itvp && (error = copyin((caddr_t)itvp, (caddr_t)&aitv,
sizeof(struct itimerval))))
return (error);
if (itvp && (error = copyin((caddr_t)itvp, (caddr_t)&aitv,
sizeof(struct itimerval))))
return (error);
- if ((uap->itv = uap->oitv) && (error = getitimer(p, uap, retval)))
+ if ((SCARG(uap, itv) = SCARG(uap, oitv)) &&
+ (error = getitimer(p, uap, retval)))
return (error);
if (itvp == 0)
return (0);
if (itimerfix(&aitv.it_value) || itimerfix(&aitv.it_interval))
return (EINVAL);
s = splclock();
return (error);
if (itvp == 0)
return (0);
if (itimerfix(&aitv.it_value) || itimerfix(&aitv.it_interval))
return (EINVAL);
s = splclock();
- if (uap->which == ITIMER_REAL) {
+ if (SCARG(uap, which) == ITIMER_REAL) {
untimeout(realitexpire, (caddr_t)p);
if (timerisset(&aitv.it_value)) {
timevaladd(&aitv.it_value, (struct timeval *)&time);
untimeout(realitexpire, (caddr_t)p);
if (timerisset(&aitv.it_value)) {
timevaladd(&aitv.it_value, (struct timeval *)&time);
}
p->p_realtimer = aitv;
} else
}
p->p_realtimer = aitv;
} else
- p->p_stats->p_timer[uap->which] = aitv;
+ p->p_stats->p_timer[SCARG(uap, which)] = aitv;
* fix it to have at least minimal value (i.e. if it is less
* than the resolution of the clock, round it up.)
*/
* fix it to have at least minimal value (i.e. if it is less
* than the resolution of the clock, round it up.)
*/
itimerfix(tv)
struct timeval *tv;
{
itimerfix(tv)
struct timeval *tv;
{
* that it is called in a context where the timers
* on which it is operating cannot change in value.
*/
* that it is called in a context where the timers
* on which it is operating cannot change in value.
*/
itimerdecr(itp, usec)
register struct itimerval *itp;
int usec;
itimerdecr(itp, usec)
register struct itimerval *itp;
int usec;
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_xxx.c 8.2 (Berkeley) %G%
+ * @(#)kern_xxx.c 8.3 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
-struct reboot_args {
- int opt;
-};
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
reboot(p, uap, retval)
struct proc *p;
reboot(p, uap, retval)
struct proc *p;
- struct reboot_args *uap;
- int *retval;
+ struct reboot_args /* {
+ syscallarg(int) opt;
+ } */ *uap;
+ register_t *retval;
{
int error;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
{
int error;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
return (0);
}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
return (0);
}
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-struct gethostname_args {
- char *hostname;
- u_int len;
-};
-ogethostname(p, uap, retval)
+int
+compat_43_gethostname(p, uap, retval)
- struct gethostname_args *uap;
- int *retval;
+ struct compat_43_gethostname_args /* {
+ syscallarg(char *) hostname;
+ syscallarg(u_int) len;
+ } */ *uap;
+ register_t *retval;
{
int name;
name = KERN_HOSTNAME;
{
int name;
name = KERN_HOSTNAME;
- return (kern_sysctl(&name, 1, uap->hostname, &uap->len, 0, 0));
+ return (kern_sysctl(&name, 1, SCARG(uap, hostname), &SCARG(uap, len),
+ 0, 0));
-struct sethostname_args {
- char *hostname;
- u_int len;
-};
-osethostname(p, uap, retval)
+int
+compat_43_sethostname(p, uap, retval)
- register struct sethostname_args *uap;
- int *retval;
+ register struct compat_43_sethostname_args /* {
+ syscallarg(char *) hostname;
+ syscallarg(u_int) len;
+ } */ *uap;
+ register_t *retval;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
name = KERN_HOSTNAME;
if (error = suser(p->p_ucred, &p->p_acflag))
return (error);
name = KERN_HOSTNAME;
- return (kern_sysctl(&name, 1, 0, 0, uap->hostname, uap->len));
+ return (kern_sysctl(&name, 1, 0, 0, SCARG(uap, hostname),
+ SCARG(uap, len)));
-extern long hostid;
-
-struct gethostid_args {
- int dummy;
-};
-ogethostid(p, uap, retval)
+int
+compat_43_gethostid(p, uap, retval)
- struct gethostid_args *uap;
- int *retval;
+ void *uap;
+ register_t *retval;
- *(long *)retval = hostid;
+ *(int32_t *)retval = hostid;
return (0);
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
#ifdef COMPAT_43
return (0);
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
#ifdef COMPAT_43
-struct sethostid_args {
- long hostid;
-};
-osethostid(p, uap, retval)
+int
+compat_43_sethostid(p, uap, retval)
- struct sethostid_args *uap;
- int *retval;
+ struct compat_43_sethostid_args /* {
+ syscallarg(int32_t) hostid;
+ } */ *uap;
+ register_t *retval;
+int
+compat_43_quota(p, uap, retval)
+ struct proc *p;
+ void *uap;
+ register_t *retval;