shuffle (sort)

This commit is contained in:
cgd 1999-05-05 01:51:31 +00:00
parent a94b4b4c49
commit 3b5a8a7db7
14 changed files with 734 additions and 730 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_descrip.c,v 1.2 1999/05/04 02:12:15 cgd Exp $ */
/* $NetBSD: osf1_descrip.c,v 1.3 1999/05/05 01:51:31 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -84,46 +84,6 @@
#include <compat/osf1/osf1_syscallargs.h>
#include <compat/osf1/osf1_cvt.h>
/*
* Return status information about a file descriptor.
*/
int
osf1_sys_fstat(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_fstat_args *uap = v;
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct stat ub;
struct osf1_stat oub;
int error;
if ((unsigned)SCARG(uap, fd) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
return (EBADF);
switch (fp->f_type) {
case DTYPE_VNODE:
error = vn_stat((struct vnode *)fp->f_data, &ub, p);
break;
case DTYPE_SOCKET:
error = soo_stat((struct socket *)fp->f_data, &ub);
break;
default:
panic("ofstat");
/*NOTREACHED*/
}
osf1_cvt_stat_from_native(&ub, &oub);
if (error == 0)
error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb),
sizeof (oub));
return (error);
}
int
osf1_sys_fcntl(p, v, retval)
struct proc *p;
@ -214,39 +174,6 @@ osf1_sys_fcntl(p, v, retval)
return error;
}
int
osf1_sys_lseek(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_lseek_args *uap = v;
struct sys_lseek_args a;
SCARG(&a, fd) = SCARG(uap, fd);
SCARG(&a, pad) = 0;
SCARG(&a, offset) = SCARG(uap, offset);
SCARG(&a, whence) = SCARG(uap, whence);
return sys_lseek(p, &a, retval);
}
int
osf1_sys_ftruncate(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_ftruncate_args *uap = v;
struct sys_ftruncate_args a;
SCARG(&a, fd) = SCARG(uap, fd);
SCARG(&a, pad) = 0;
SCARG(&a, length) = SCARG(uap, length);
return sys_ftruncate(p, &a, retval);
}
int
osf1_sys_fpathconf(p, v, retval)
struct proc *p;
@ -267,3 +194,76 @@ osf1_sys_fpathconf(p, v, retval)
return (error);
}
/*
* Return status information about a file descriptor.
*/
int
osf1_sys_fstat(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_fstat_args *uap = v;
struct filedesc *fdp = p->p_fd;
struct file *fp;
struct stat ub;
struct osf1_stat oub;
int error;
if ((unsigned)SCARG(uap, fd) >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
return (EBADF);
switch (fp->f_type) {
case DTYPE_VNODE:
error = vn_stat((struct vnode *)fp->f_data, &ub, p);
break;
case DTYPE_SOCKET:
error = soo_stat((struct socket *)fp->f_data, &ub);
break;
default:
panic("ofstat");
/*NOTREACHED*/
}
osf1_cvt_stat_from_native(&ub, &oub);
if (error == 0)
error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb),
sizeof (oub));
return (error);
}
int
osf1_sys_ftruncate(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_ftruncate_args *uap = v;
struct sys_ftruncate_args a;
SCARG(&a, fd) = SCARG(uap, fd);
SCARG(&a, pad) = 0;
SCARG(&a, length) = SCARG(uap, length);
return sys_ftruncate(p, &a, retval);
}
int
osf1_sys_lseek(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_lseek_args *uap = v;
struct sys_lseek_args a;
SCARG(&a, fd) = SCARG(uap, fd);
SCARG(&a, pad) = 0;
SCARG(&a, offset) = SCARG(uap, offset);
SCARG(&a, whence) = SCARG(uap, whence);
return sys_lseek(p, &a, retval);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_exec.c,v 1.8 1999/05/01 02:57:10 cgd Exp $ */
/* $NetBSD: osf1_exec.c,v 1.9 1999/05/05 01:51:32 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -145,6 +145,80 @@ osf1_exec_ecoff_hook(struct proc *p, struct exec_package *epp)
return (error);
}
/*
* copy arguments onto the stack in the normal way, then copy out
* any ELF-like AUX entries used by the dynamic loading scheme.
*/
static void *
osf1_copyargs(pack, arginfo, stack, argp)
struct exec_package *pack;
struct ps_strings *arginfo;
void *stack;
void *argp;
{
struct proc *p = curproc; /* XXX !!! */
struct osf1_exec_emul_arg *emul_arg = pack->ep_emul_arg;
struct osf1_auxv ai[MAX_AUX_ENTRIES], *a;
char *prognameloc, *loadernameloc;
size_t len;
stack = copyargs(pack, arginfo, stack, argp);
if (!stack)
goto bad;
a = ai;
memset(ai, 0, sizeof ai);
prognameloc = (char *)stack + sizeof ai;
if (copyoutstr(emul_arg->exec_name, prognameloc, MAXPATHLEN + 1, NULL))
goto bad;
a->a_type = OSF1_AT_EXEC_FILENAME;
a->a_un.a_ptr = prognameloc;
a++;
/*
* if there's a loader, push additional auxv entries on the stack.
*/
if (emul_arg->flags & OSF1_EXEC_EMUL_FLAGS_HAVE_LOADER) {
loadernameloc = prognameloc + MAXPATHLEN + 1;
if (copyoutstr(emul_arg->loader_name, loadernameloc,
MAXPATHLEN + 1, NULL))
goto bad;
a->a_type = OSF1_AT_EXEC_LOADER_FILENAME;
a->a_un.a_ptr = loadernameloc;
a++;
a->a_type = OSF1_AT_EXEC_LOADER_FLAGS;
a->a_un.a_val = 0;
if (pack->ep_vap->va_mode & S_ISUID)
a->a_un.a_val |= OSF1_LDR_EXEC_SETUID_F;
if (pack->ep_vap->va_mode & S_ISGID)
a->a_un.a_val |= OSF1_LDR_EXEC_SETGID_F;
if (p->p_flag & P_TRACED)
a->a_un.a_val |= OSF1_LDR_EXEC_PTRACE_F;
a++;
}
a->a_type = OSF1_AT_NULL;
a->a_un.a_val = 0;
a++;
len = (a - ai) * sizeof(struct osf1_auxv);
if (copyout(ai, stack, len))
goto bad;
stack = (caddr_t)stack + len;
out:
free(pack->ep_emul_arg, M_TEMP);
pack->ep_emul_arg = NULL;
return stack;
bad:
stack = NULL;
goto out;
}
static int
osf1_exec_ecoff_dynamic(struct proc *p, struct exec_package *epp)
{
@ -269,77 +343,3 @@ bad:
vrele(ldr_vp);
return (error);
}
/*
* copy arguments onto the stack in the normal way, then copy out
* any ELF-like AUX entries used by the dynamic loading scheme.
*/
static void *
osf1_copyargs(pack, arginfo, stack, argp)
struct exec_package *pack;
struct ps_strings *arginfo;
void *stack;
void *argp;
{
struct proc *p = curproc; /* XXX !!! */
struct osf1_exec_emul_arg *emul_arg = pack->ep_emul_arg;
struct osf1_auxv ai[MAX_AUX_ENTRIES], *a;
char *prognameloc, *loadernameloc;
size_t len;
stack = copyargs(pack, arginfo, stack, argp);
if (!stack)
goto bad;
a = ai;
memset(ai, 0, sizeof ai);
prognameloc = (char *)stack + sizeof ai;
if (copyoutstr(emul_arg->exec_name, prognameloc, MAXPATHLEN + 1, NULL))
goto bad;
a->a_type = OSF1_AT_EXEC_FILENAME;
a->a_un.a_ptr = prognameloc;
a++;
/*
* if there's a loader, push additional auxv entries on the stack.
*/
if (emul_arg->flags & OSF1_EXEC_EMUL_FLAGS_HAVE_LOADER) {
loadernameloc = prognameloc + MAXPATHLEN + 1;
if (copyoutstr(emul_arg->loader_name, loadernameloc,
MAXPATHLEN + 1, NULL))
goto bad;
a->a_type = OSF1_AT_EXEC_LOADER_FILENAME;
a->a_un.a_ptr = loadernameloc;
a++;
a->a_type = OSF1_AT_EXEC_LOADER_FLAGS;
a->a_un.a_val = 0;
if (pack->ep_vap->va_mode & S_ISUID)
a->a_un.a_val |= OSF1_LDR_EXEC_SETUID_F;
if (pack->ep_vap->va_mode & S_ISGID)
a->a_un.a_val |= OSF1_LDR_EXEC_SETGID_F;
if (p->p_flag & P_TRACED)
a->a_un.a_val |= OSF1_LDR_EXEC_PTRACE_F;
a++;
}
a->a_type = OSF1_AT_NULL;
a->a_un.a_val = 0;
a++;
len = (a - ai) * sizeof(struct osf1_auxv);
if (copyout(ai, stack, len))
goto bad;
stack = (caddr_t)stack + len;
out:
free(pack->ep_emul_arg, M_TEMP);
pack->ep_emul_arg = NULL;
return stack;
bad:
stack = NULL;
goto out;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_file.c,v 1.4 1999/05/04 02:45:35 cgd Exp $ */
/* $NetBSD: osf1_file.c,v 1.5 1999/05/05 01:51:32 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -86,77 +86,48 @@
#include <compat/osf1/osf1_cvt.h>
int
osf1_sys_open(p, v, retval)
osf1_sys_access(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_open_args *uap = v;
struct sys_open_args a;
const char *path;
caddr_t sg;
struct osf1_sys_access_args *uap = v;
struct sys_access_args a;
unsigned long leftovers;
#ifdef SYSCALL_DEBUG
char pnbuf[1024];
if (scdebug &&
copyinstr(SCARG(uap, path), pnbuf, sizeof pnbuf, NULL) == 0)
printf("osf1_open: open: %s\n", pnbuf);
#endif
sg = stackgap_init(p->p_emul);
/* translate flags */
SCARG(&a, flags) = emul_flags_translate(osf1_open_flags_xtab,
SCARG(uap, flags), &leftovers);
if (leftovers != 0)
return (EINVAL);
/* copy mode, no translation necessary */
SCARG(&a, mode) = SCARG(uap, mode);
/* pick appropriate path */
path = SCARG(uap, path);
if (SCARG(&a, flags) & O_CREAT)
OSF1_CHECK_ALT_CREAT(p, &sg, path);
else
OSF1_CHECK_ALT_EXIST(p, &sg, path);
SCARG(&a, path) = path;
return sys_open(p, &a, retval);
}
/*
* Get file status; this version follows links.
*/
/* ARGSUSED */
int
osf1_sys_stat(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_stat_args *uap = v;
struct stat sb;
struct osf1_stat osb;
int error;
struct nameidata nd;
caddr_t sg;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
if ((error = namei(&nd)))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
if (error)
return (error);
osf1_cvt_stat_from_native(&sb, &osb);
error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
return (error);
SCARG(&a, path) = SCARG(uap, path);
/* translate flags */
SCARG(&a, flags) = emul_flags_translate(osf1_access_flags_xtab,
SCARG(uap, flags), &leftovers);
if (leftovers != 0)
return (EINVAL);
return sys_access(p, &a, retval);
}
int
osf1_sys_execve(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_execve_args *uap = v;
struct sys_execve_args ap;
caddr_t sg;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
SCARG(&ap, path) = SCARG(uap, path);
SCARG(&ap, argp) = SCARG(uap, argp);
SCARG(&ap, envp) = SCARG(uap, envp);
return sys_execve(p, &ap, retval);
}
/*
@ -212,6 +183,105 @@ osf1_sys_mknod(p, v, retval)
return sys_mknod(p, &a, retval);
}
int
osf1_sys_open(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_open_args *uap = v;
struct sys_open_args a;
const char *path;
caddr_t sg;
unsigned long leftovers;
#ifdef SYSCALL_DEBUG
char pnbuf[1024];
if (scdebug &&
copyinstr(SCARG(uap, path), pnbuf, sizeof pnbuf, NULL) == 0)
printf("osf1_open: open: %s\n", pnbuf);
#endif
sg = stackgap_init(p->p_emul);
/* translate flags */
SCARG(&a, flags) = emul_flags_translate(osf1_open_flags_xtab,
SCARG(uap, flags), &leftovers);
if (leftovers != 0)
return (EINVAL);
/* copy mode, no translation necessary */
SCARG(&a, mode) = SCARG(uap, mode);
/* pick appropriate path */
path = SCARG(uap, path);
if (SCARG(&a, flags) & O_CREAT)
OSF1_CHECK_ALT_CREAT(p, &sg, path);
else
OSF1_CHECK_ALT_EXIST(p, &sg, path);
SCARG(&a, path) = path;
return sys_open(p, &a, retval);
}
int
osf1_sys_pathconf(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_pathconf_args *uap = v;
struct sys_pathconf_args a;
caddr_t sg;
int error;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
SCARG(&a, path) = SCARG(uap, path);
error = osf1_cvt_pathconf_name_to_native(SCARG(uap, name),
&SCARG(&a, name));
if (error == 0)
error = sys_pathconf(p, &a, retval);
return (error);
}
/*
* Get file status; this version follows links.
*/
/* ARGSUSED */
int
osf1_sys_stat(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_stat_args *uap = v;
struct stat sb;
struct osf1_stat osb;
int error;
struct nameidata nd;
caddr_t sg;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
if ((error = namei(&nd)))
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
if (error)
return (error);
osf1_cvt_stat_from_native(&sb, &osb);
error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
return (error);
}
int
osf1_sys_truncate(p, v, retval)
struct proc *p;
@ -232,51 +302,6 @@ osf1_sys_truncate(p, v, retval)
return sys_truncate(p, &a, retval);
}
int
osf1_sys_execve(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_execve_args *uap = v;
struct sys_execve_args ap;
caddr_t sg;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
SCARG(&ap, path) = SCARG(uap, path);
SCARG(&ap, argp) = SCARG(uap, argp);
SCARG(&ap, envp) = SCARG(uap, envp);
return sys_execve(p, &ap, retval);
}
int
osf1_sys_access(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_access_args *uap = v;
struct sys_access_args a;
unsigned long leftovers;
caddr_t sg;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
SCARG(&a, path) = SCARG(uap, path);
/* translate flags */
SCARG(&a, flags) = emul_flags_translate(osf1_access_flags_xtab,
SCARG(uap, flags), &leftovers);
if (leftovers != 0)
return (EINVAL);
return sys_access(p, &a, retval);
}
int
osf1_sys_utimes(p, v, retval)
struct proc *p;
@ -321,28 +346,3 @@ osf1_sys_utimes(p, v, retval)
return (error);
}
int
osf1_sys_pathconf(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_pathconf_args *uap = v;
struct sys_pathconf_args a;
caddr_t sg;
int error;
sg = stackgap_init(p->p_emul);
OSF1_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
SCARG(&a, path) = SCARG(uap, path);
error = osf1_cvt_pathconf_name_to_native(SCARG(uap, name),
&SCARG(&a, name));
if (error == 0)
error = sys_pathconf(p, &a, retval);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_generic.c,v 1.1 1999/05/01 05:06:46 cgd Exp $ */
/* $NetBSD: osf1_generic.c,v 1.2 1999/05/05 01:51:32 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -121,50 +121,6 @@ punt:
return (error);
}
int
osf1_sys_writev(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_writev_args *uap = v;
struct sys_writev_args a;
struct osf1_iovec *oio;
struct iovec *nio;
caddr_t sg = stackgap_init(p->p_emul);
int error, osize, nsize, i;
if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec)))
return (EINVAL);
osize = SCARG(uap, iovcnt) * sizeof (struct osf1_iovec);
nsize = SCARG(uap, iovcnt) * sizeof (struct iovec);
oio = malloc(osize, M_TEMP, M_WAITOK);
nio = malloc(nsize, M_TEMP, M_WAITOK);
error = 0;
if ((error = copyin(SCARG(uap, iovp), oio, osize)))
goto punt;
for (i = 0; i < SCARG(uap, iovcnt); i++) {
nio[i].iov_base = oio[i].iov_base;
nio[i].iov_len = oio[i].iov_len;
}
SCARG(&a, fd) = SCARG(uap, fd);
SCARG(&a, iovp) = stackgap_alloc(&sg, nsize);
SCARG(&a, iovcnt) = SCARG(uap, iovcnt);
if ((error = copyout(nio, (caddr_t)SCARG(&a, iovp), nsize)))
goto punt;
error = sys_writev(p, &a, retval);
punt:
free(oio, M_TEMP);
free(nio, M_TEMP);
return (error);
}
int
osf1_sys_select(p, v, retval)
struct proc *p;
@ -210,3 +166,47 @@ osf1_sys_select(p, v, retval)
return (error);
}
int
osf1_sys_writev(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_writev_args *uap = v;
struct sys_writev_args a;
struct osf1_iovec *oio;
struct iovec *nio;
caddr_t sg = stackgap_init(p->p_emul);
int error, osize, nsize, i;
if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec)))
return (EINVAL);
osize = SCARG(uap, iovcnt) * sizeof (struct osf1_iovec);
nsize = SCARG(uap, iovcnt) * sizeof (struct iovec);
oio = malloc(osize, M_TEMP, M_WAITOK);
nio = malloc(nsize, M_TEMP, M_WAITOK);
error = 0;
if ((error = copyin(SCARG(uap, iovp), oio, osize)))
goto punt;
for (i = 0; i < SCARG(uap, iovcnt); i++) {
nio[i].iov_base = oio[i].iov_base;
nio[i].iov_len = oio[i].iov_len;
}
SCARG(&a, fd) = SCARG(uap, fd);
SCARG(&a, iovp) = stackgap_alloc(&sg, nsize);
SCARG(&a, iovcnt) = SCARG(uap, iovcnt);
if ((error = copyout(nio, (caddr_t)SCARG(&a, iovp), nsize)))
goto punt;
error = sys_writev(p, &a, retval);
punt:
free(oio, M_TEMP);
free(nio, M_TEMP);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_ioctl.c,v 1.10 1999/04/29 17:34:49 cgd Exp $ */
/* $NetBSD: osf1_ioctl.c,v 1.11 1999/05/05 01:51:33 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -73,11 +73,11 @@
extern int scdebug;
#endif
int osf1_ioctl_f __P((struct proc *p, struct sys_ioctl_args *nuap,
static int osf1_ioctl_f __P((struct proc *p, struct sys_ioctl_args *nuap,
register_t *retval, int cmd, int dir, int len));
int osf1_ioctl_i __P((struct proc *p, struct sys_ioctl_args *nuap,
static int osf1_ioctl_i __P((struct proc *p, struct sys_ioctl_args *nuap,
register_t *retval, int cmd, int dir, int len));
int osf1_ioctl_t __P((struct proc *p, struct sys_ioctl_args *nuap,
static int osf1_ioctl_t __P((struct proc *p, struct sys_ioctl_args *nuap,
register_t *retval, int cmd, int dir, int len));
int
@ -150,7 +150,7 @@ osf1_sys_ioctl(p, v, retval)
}
}
int
static int
osf1_ioctl_f(p, uap, retval, cmd, dir, len)
struct proc *p;
struct sys_ioctl_args *uap;
@ -178,7 +178,7 @@ osf1_ioctl_f(p, uap, retval, cmd, dir, len)
return sys_ioctl(p, uap, retval);
}
int
static int
osf1_ioctl_i(p, uap, retval, cmd, dir, len)
struct proc *p;
struct sys_ioctl_args *uap;
@ -212,7 +212,7 @@ osf1_ioctl_i(p, uap, retval, cmd, dir, len)
return sys_ioctl(p, uap, retval);
}
int
static int
osf1_ioctl_t(p, uap, retval, cmd, dir, len)
struct proc *p;
struct sys_ioctl_args *uap;

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_misc.c,v 1.50 1999/05/04 05:17:22 cgd Exp $ */
/* $NetBSD: osf1_misc.c,v 1.51 1999/05/05 01:51:33 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -92,52 +92,14 @@ extern int scdebug;
const char osf1_emul_path[] = "/emul/osf1";
int
osf1_sys_setsysinfo(p, v, retval)
osf1_sys_classcntl(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
/* XXX */
return (0);
}
int
osf1_sys_usleep_thread(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_usleep_thread_args *uap = v;
struct osf1_timeval otv, endotv;
struct timeval tv, endtv;
u_long ticks;
int error, s;
if ((error = copyin(SCARG(uap, sleep), &otv, sizeof otv)))
return (error);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
ticks = ((u_long)tv.tv_sec * 1000000 + tv.tv_usec) / tick;
s = splclock();
tv = time;
splx(s);
tsleep(p, PUSER|PCATCH, "OSF/1", ticks); /* XXX */
if (SCARG(uap, slept) != NULL) {
s = splclock();
timersub(&time, &tv, &endtv);
splx(s);
if (endtv.tv_sec < 0 || endtv.tv_usec < 0)
endtv.tv_sec = endtv.tv_usec = 0;
endotv.tv_sec = endtv.tv_sec;
endotv.tv_usec = endtv.tv_usec;
error = copyout(&endotv, SCARG(uap, slept), sizeof endotv);
}
return (error);
return (ENOSYS);
}
int
@ -161,37 +123,6 @@ osf1_sys_reboot(p, v, retval)
return sys_reboot(p, &a, retval);
}
int
osf1_sys_uname(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_uname_args *uap = v;
struct osf1_utsname u;
char *cp, *dp, *ep;
extern char ostype[], osrelease[];
/* XXX would use stackgap, but our struct utsname is too big! */
strncpy(u.sysname, ostype, sizeof(u.sysname));
strncpy(u.nodename, hostname, sizeof(u.nodename));
strncpy(u.release, osrelease, sizeof(u.release));
dp = u.version;
ep = &u.version[sizeof(u.version) - 1];
for (cp = version; *cp && *cp != '('; cp++)
;
for (cp++; *cp && *cp != ')' && dp < ep; cp++)
*dp++ = *cp;
for (; *cp && *cp != '#'; cp++)
;
for (; *cp && *cp != ':' && dp < ep; cp++)
*dp++ = *cp;
*dp = '\0';
strncpy(u.machine, MACHINE, sizeof(u.machine));
return (copyout((caddr_t)&u, (caddr_t)SCARG(uap, name), sizeof u));
}
int
osf1_sys_set_program_attributes(p, v, retval)
struct proc *p;
@ -217,6 +148,17 @@ osf1_sys_set_program_attributes(p, v, retval)
return (0);
}
int
osf1_sys_setsysinfo(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
/* XXX */
return (0);
}
int
osf1_sys_sysinfo(p, v, retval)
struct proc *p;
@ -289,6 +231,75 @@ dont_care:
return (error);
}
int
osf1_sys_uname(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_uname_args *uap = v;
struct osf1_utsname u;
char *cp, *dp, *ep;
extern char ostype[], osrelease[];
/* XXX would use stackgap, but our struct utsname is too big! */
strncpy(u.sysname, ostype, sizeof(u.sysname));
strncpy(u.nodename, hostname, sizeof(u.nodename));
strncpy(u.release, osrelease, sizeof(u.release));
dp = u.version;
ep = &u.version[sizeof(u.version) - 1];
for (cp = version; *cp && *cp != '('; cp++)
;
for (cp++; *cp && *cp != ')' && dp < ep; cp++)
*dp++ = *cp;
for (; *cp && *cp != '#'; cp++)
;
for (; *cp && *cp != ':' && dp < ep; cp++)
*dp++ = *cp;
*dp = '\0';
strncpy(u.machine, MACHINE, sizeof(u.machine));
return (copyout((caddr_t)&u, (caddr_t)SCARG(uap, name), sizeof u));
}
int
osf1_sys_usleep_thread(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_usleep_thread_args *uap = v;
struct osf1_timeval otv, endotv;
struct timeval tv, endtv;
u_long ticks;
int error, s;
if ((error = copyin(SCARG(uap, sleep), &otv, sizeof otv)))
return (error);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
ticks = ((u_long)tv.tv_sec * 1000000 + tv.tv_usec) / tick;
s = splclock();
tv = time;
splx(s);
tsleep(p, PUSER|PCATCH, "OSF/1", ticks); /* XXX */
if (SCARG(uap, slept) != NULL) {
s = splclock();
timersub(&time, &tv, &endtv);
splx(s);
if (endtv.tv_sec < 0 || endtv.tv_usec < 0)
endtv.tv_sec = endtv.tv_usec = 0;
endotv.tv_sec = endtv.tv_sec;
endotv.tv_usec = endtv.tv_usec;
error = copyout(&endotv, SCARG(uap, slept), sizeof endotv);
}
return (error);
}
int
osf1_sys_wait4(p, v, retval)
struct proc *p;
@ -334,14 +345,3 @@ osf1_sys_wait4(p, v, retval)
return (error);
}
int
osf1_sys_classcntl(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
/* XXX */
return (ENOSYS);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_mmap.c,v 1.2 1999/05/01 04:38:39 cgd Exp $ */
/* $NetBSD: osf1_mmap.c,v 1.3 1999/05/05 01:51:34 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -43,6 +43,72 @@
#include <compat/osf1/osf1_syscallargs.h>
#include <compat/osf1/osf1_cvt.h>
int
osf1_sys_madvise(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_madvise_args *uap = v;
struct sys_madvise_args a;
int error;
SCARG(&a, addr) = SCARG(uap, addr);
SCARG(&a, len) = SCARG(uap, len);
error = 0;
switch (SCARG(uap, behav)) {
case OSF1_MADV_NORMAL:
SCARG(&a, behav) = MADV_NORMAL;
break;
case OSF1_MADV_RANDOM:
SCARG(&a, behav) = MADV_RANDOM;
break;
case OSF1_MADV_SEQUENTIAL:
SCARG(&a, behav) = MADV_SEQUENTIAL;
break;
case OSF1_MADV_WILLNEED:
SCARG(&a, behav) = MADV_WILLNEED;
break;
case OSF1_MADV_DONTNEED_COMPAT:
SCARG(&a, behav) = MADV_DONTNEED;
break;
case OSF1_MADV_SPACEAVAIL:
SCARG(&a, behav) = MADV_SPACEAVAIL;
break;
case OSF1_MADV_DONTNEED:
/*
* XXX not supported. In Digital UNIX, this flushes all
* XXX data in the region and replaces it with ZFOD pages.
*/
error = EINVAL;
break;
default:
error = EINVAL;
break;
}
if (error == 0) {
error = sys_madvise(p, &a, retval);
/*
* NetBSD madvise() currently always returns ENOSYS.
* Digital UNIX says that non-operational requests (i.e.
* valid, but unimplemented 'behav') will return success.
*/
if (error == ENOSYS)
error = 0;
}
return (error);
}
int
osf1_sys_mmap(p, v, retval)
struct proc *p;
@ -160,69 +226,3 @@ osf1_sys_mprotect(p, v, retval)
return sys_mprotect(p, &a, retval);
}
int
osf1_sys_madvise(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_madvise_args *uap = v;
struct sys_madvise_args a;
int error;
SCARG(&a, addr) = SCARG(uap, addr);
SCARG(&a, len) = SCARG(uap, len);
error = 0;
switch (SCARG(uap, behav)) {
case OSF1_MADV_NORMAL:
SCARG(&a, behav) = MADV_NORMAL;
break;
case OSF1_MADV_RANDOM:
SCARG(&a, behav) = MADV_RANDOM;
break;
case OSF1_MADV_SEQUENTIAL:
SCARG(&a, behav) = MADV_SEQUENTIAL;
break;
case OSF1_MADV_WILLNEED:
SCARG(&a, behav) = MADV_WILLNEED;
break;
case OSF1_MADV_DONTNEED_COMPAT:
SCARG(&a, behav) = MADV_DONTNEED;
break;
case OSF1_MADV_SPACEAVAIL:
SCARG(&a, behav) = MADV_SPACEAVAIL;
break;
case OSF1_MADV_DONTNEED:
/*
* XXX not supported. In Digital UNIX, this flushes all
* XXX data in the region and replaces it with ZFOD pages.
*/
error = EINVAL;
break;
default:
error = EINVAL;
break;
}
if (error == 0) {
error = sys_madvise(p, &a, retval);
/*
* NetBSD madvise() currently always returns ENOSYS.
* Digital UNIX says that non-operational requests (i.e.
* valid, but unimplemented 'behav') will return success.
*/
if (error == ENOSYS)
error = 0;
}
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_mount.c,v 1.13 1999/05/01 02:57:11 cgd Exp $ */
/* $NetBSD: osf1_mount.c,v 1.14 1999/05/05 01:51:34 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -99,37 +99,10 @@
#define OSF1_UNMOUNT_FLAGS (OSF1_MNT_FORCE|OSF1_MNT_NOFORCE)
int osf1_mount_mfs __P((struct proc *, struct osf1_sys_mount_args *,
struct sys_mount_args *));
int osf1_mount_nfs __P((struct proc *, struct osf1_sys_mount_args *,
struct sys_mount_args *));
int
osf1_sys_statfs(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_statfs_args *uap = v;
struct mount *mp;
struct statfs *sp;
struct osf1_statfs osfs;
int error;
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
if ((error = namei(&nd)))
return (error);
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
if ((error = VFS_STATFS(mp, sp, p)))
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
osf1_cvt_statfs_from_native(sp, &osfs);
return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
SCARG(uap, len)));
}
static int osf1_mount_mfs __P((struct proc *,
struct osf1_sys_mount_args *, struct sys_mount_args *));
static int osf1_mount_nfs __P((struct proc *,
struct osf1_sys_mount_args *, struct sys_mount_args *));
int
osf1_sys_fstatfs(p, v, retval)
@ -204,27 +177,6 @@ osf1_sys_getfsstat(p, v, retval)
return (0);
}
int
osf1_sys_unmount(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_unmount_args *uap = v;
struct sys_unmount_args a;
SCARG(&a, path) = SCARG(uap, path);
if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS)
return (EINVAL);
SCARG(&a, flags) = 0;
if ((SCARG(uap, flags) & OSF1_MNT_FORCE) &&
(SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0)
SCARG(&a, flags) |= MNT_FORCE;
return sys_unmount(p, &a, retval);
}
int
osf1_sys_mount(p, v, retval)
struct proc *p;
@ -260,6 +212,54 @@ osf1_sys_mount(p, v, retval)
}
int
osf1_sys_statfs(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_statfs_args *uap = v;
struct mount *mp;
struct statfs *sp;
struct osf1_statfs osfs;
int error;
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
if ((error = namei(&nd)))
return (error);
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
if ((error = VFS_STATFS(mp, sp, p)))
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
osf1_cvt_statfs_from_native(sp, &osfs);
return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
SCARG(uap, len)));
}
int
osf1_sys_unmount(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_unmount_args *uap = v;
struct sys_unmount_args a;
SCARG(&a, path) = SCARG(uap, path);
if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS)
return (EINVAL);
SCARG(&a, flags) = 0;
if ((SCARG(uap, flags) & OSF1_MNT_FORCE) &&
(SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0)
SCARG(&a, flags) |= MNT_FORCE;
return sys_unmount(p, &a, retval);
}
static int
osf1_mount_mfs(p, osf_argp, bsd_argp)
struct proc *p;
struct osf1_sys_mount_args *osf_argp;
@ -292,7 +292,7 @@ osf1_mount_mfs(p, osf_argp, bsd_argp)
return 0;
}
int
static int
osf1_mount_nfs(p, osf_argp, bsd_argp)
struct proc *p;
struct osf1_sys_mount_args *osf_argp;

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_prot.c,v 1.1 1999/05/01 05:49:02 cgd Exp $ */
/* $NetBSD: osf1_prot.c,v 1.2 1999/05/05 01:51:35 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -67,6 +67,38 @@
#include <compat/osf1/osf1_syscallargs.h>
#include <compat/osf1/osf1_cvt.h>
/*
* OSF/1 defines _POSIX_SAVED_IDS, which means that our normal
* setgid() won't work.
*
* If you change "uid" to "gid" in the discussion, below, about
* setuid(), you'll get a correct description of setgid().
*/
int
osf1_sys_setgid(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_setgid_args *uap = v;
struct pcred *pc = p->p_cred;
gid_t gid = SCARG(uap, gid);
int error;
if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 &&
gid != pc->p_rgid && gid != pc->p_svgid)
return (error);
pc->pc_ucred = crcopy(pc->pc_ucred);
pc->pc_ucred->cr_gid = gid;
if (error == 0) {
pc->p_rgid = gid;
pc->p_svgid = gid;
}
p->p_flag |= P_SUGID;
return (0);
}
/*
* OSF/1 defines _POSIX_SAVED_IDS, which means that our normal
* setuid() won't work.
@ -107,35 +139,3 @@ osf1_sys_setuid(p, v, retval)
p->p_flag |= P_SUGID;
return (0);
}
/*
* OSF/1 defines _POSIX_SAVED_IDS, which means that our normal
* setgid() won't work.
*
* If you change "uid" to "gid" in the discussion, above, about
* setuid(), you'll get a correct description of setgid().
*/
int
osf1_sys_setgid(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_setgid_args *uap = v;
struct pcred *pc = p->p_cred;
gid_t gid = SCARG(uap, gid);
int error;
if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 &&
gid != pc->p_rgid && gid != pc->p_svgid)
return (error);
pc->pc_ucred = crcopy(pc->pc_ucred);
pc->pc_ucred->cr_gid = gid;
if (error == 0) {
pc->p_rgid = gid;
pc->p_svgid = gid;
}
p->p_flag |= P_SUGID;
return (0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_resource.c,v 1.1 1999/05/01 05:41:56 cgd Exp $ */
/* $NetBSD: osf1_resource.c,v 1.2 1999/05/05 01:51:35 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -84,48 +84,6 @@ osf1_sys_getrlimit(p, v, retval)
return sys_getrlimit(p, &a, retval);
}
int
osf1_sys_setrlimit(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_setrlimit_args *uap = v;
struct sys_setrlimit_args a;
switch (SCARG(uap, which)) {
case OSF1_RLIMIT_CPU:
SCARG(&a, which) = RLIMIT_CPU;
break;
case OSF1_RLIMIT_FSIZE:
SCARG(&a, which) = RLIMIT_FSIZE;
break;
case OSF1_RLIMIT_DATA:
SCARG(&a, which) = RLIMIT_DATA;
break;
case OSF1_RLIMIT_STACK:
SCARG(&a, which) = RLIMIT_STACK;
break;
case OSF1_RLIMIT_CORE:
SCARG(&a, which) = RLIMIT_CORE;
break;
case OSF1_RLIMIT_RSS:
SCARG(&a, which) = RLIMIT_RSS;
break;
case OSF1_RLIMIT_NOFILE:
SCARG(&a, which) = RLIMIT_NOFILE;
break;
case OSF1_RLIMIT_AS: /* unhandled */
default:
return (EINVAL);
}
/* XXX should translate */
SCARG(&a, rlp) = SCARG(uap, rlp);
return sys_setrlimit(p, &a, retval);
}
int
osf1_sys_getrusage(p, v, retval)
struct proc *p;
@ -168,3 +126,45 @@ osf1_sys_getrusage(p, v, retval)
return (error);
}
int
osf1_sys_setrlimit(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_setrlimit_args *uap = v;
struct sys_setrlimit_args a;
switch (SCARG(uap, which)) {
case OSF1_RLIMIT_CPU:
SCARG(&a, which) = RLIMIT_CPU;
break;
case OSF1_RLIMIT_FSIZE:
SCARG(&a, which) = RLIMIT_FSIZE;
break;
case OSF1_RLIMIT_DATA:
SCARG(&a, which) = RLIMIT_DATA;
break;
case OSF1_RLIMIT_STACK:
SCARG(&a, which) = RLIMIT_STACK;
break;
case OSF1_RLIMIT_CORE:
SCARG(&a, which) = RLIMIT_CORE;
break;
case OSF1_RLIMIT_RSS:
SCARG(&a, which) = RLIMIT_RSS;
break;
case OSF1_RLIMIT_NOFILE:
SCARG(&a, which) = RLIMIT_NOFILE;
break;
case OSF1_RLIMIT_AS: /* unhandled */
default:
return (EINVAL);
}
/* XXX should translate */
SCARG(&a, rlp) = SCARG(uap, rlp);
return sys_setrlimit(p, &a, retval);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_signal.c,v 1.15 1999/05/05 00:57:43 cgd Exp $ */
/* $NetBSD: osf1_signal.c,v 1.16 1999/05/05 01:51:36 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -50,6 +50,22 @@
#include <compat/osf1/osf1_util.h>
#include <compat/osf1/osf1_cvt.h>
#if 0
int
osf1_sys_kill(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_kill_args *uap = v;
struct sys_kill_args ka;
SCARG(&ka, pid) = SCARG(uap, pid);
SCARG(&ka, signum) = osf1_signal_xlist[SCARG(uap, signum)];
return sys_kill(p, &ka, retval);
}
#endif
int
osf1_sys_sigaction(p, v, retval)
struct proc *p;
@ -270,6 +286,22 @@ osf1_sys_signal(p, v, retval)
}
}
int
osf1_sys_sigpending(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_sigpending_args *uap = v;
sigset_t bss;
osf1_sigset_t oss;
bss = p->p_siglist & p->p_sigmask;
osf1_cvt_sigset_from_native(&bss, &oss);
return copyout(&oss, SCARG(uap, mask), sizeof(oss));
}
int
osf1_sys_sigprocmask(p, v, retval)
struct proc *p;
@ -322,22 +354,6 @@ osf1_sys_sigprocmask(p, v, retval)
return error;
}
int
osf1_sys_sigpending(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_sigpending_args *uap = v;
sigset_t bss;
osf1_sigset_t oss;
bss = p->p_siglist & p->p_sigmask;
osf1_cvt_sigset_from_native(&bss, &oss);
return copyout(&oss, SCARG(uap, mask), sizeof(oss));
}
int
osf1_sys_sigsuspend(p, v, retval)
struct proc *p;
@ -358,18 +374,4 @@ osf1_sys_sigsuspend(p, v, retval)
SCARG(&sa, mask) = bss;
return sys_sigsuspend(p, &sa, retval);
}
int
osf1_sys_kill(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_kill_args *uap = v;
struct sys_kill_args ka;
SCARG(&ka, pid) = SCARG(uap, pid);
SCARG(&ka, signum) = osf1_signal_xlist[SCARG(uap, signum)];
return sys_kill(p, &ka, retval);
}
#endif

View File

@ -1,4 +1,6 @@
/* $NetBSD: osf1_signal.h,v 1.5 1999/05/01 02:57:11 cgd Exp $ */
/* $NetBSD: osf1_signal.h,v 1.6 1999/05/05 01:51:36 cgd Exp $ */
/* XXX OUT OF DATE, some of the non-signal number bits here don't belong */
#ifndef _OSF1_SIGNAL_H
#define _OSF1_SIGNAL_H

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_socket.c,v 1.2 1999/05/04 02:45:35 cgd Exp $ */
/* $NetBSD: osf1_socket.c,v 1.3 1999/05/05 01:51:37 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -71,27 +71,6 @@
#include <compat/osf1/osf1_util.h>
#include <compat/osf1/osf1_cvt.h>
int
osf1_sys_socket(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_socket_args *uap = v;
struct sys_socket_args a;
/* XXX TRANSLATE */
if (SCARG(uap, type) > AF_LINK)
return (EINVAL); /* XXX After AF_LINK, divergence. */
SCARG(&a, domain) = SCARG(uap, domain);
SCARG(&a, type) = SCARG(uap, type);
SCARG(&a, protocol) = SCARG(uap, protocol);
return sys_socket(p, &a, retval);
}
int
osf1_sys_sendto(p, v, retval)
struct proc *p;
@ -116,3 +95,24 @@ osf1_sys_sendto(p, v, retval)
return sys_sendto(p, &a, retval);
}
int
osf1_sys_socket(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_socket_args *uap = v;
struct sys_socket_args a;
/* XXX TRANSLATE */
if (SCARG(uap, type) > AF_LINK)
return (EINVAL); /* XXX After AF_LINK, divergence. */
SCARG(&a, domain) = SCARG(uap, domain);
SCARG(&a, type) = SCARG(uap, type);
SCARG(&a, protocol) = SCARG(uap, protocol);
return sys_socket(p, &a, retval);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: osf1_time.c,v 1.1 1999/05/01 05:25:37 cgd Exp $ */
/* $NetBSD: osf1_time.c,v 1.2 1999/05/05 01:51:37 cgd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@ -96,68 +96,6 @@ osf1_sys_gettimeofday(p, v, retval)
return (error);
}
int
osf1_sys_settimeofday(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_settimeofday_args *uap = v;
struct sys_settimeofday_args a;
struct osf1_timeval otv;
struct osf1_timezone otz;
struct timeval tv;
struct timezone tz;
int error;
caddr_t sg;
sg = stackgap_init(p->p_emul);
if (SCARG(uap, tv) == NULL)
SCARG(&a, tv) = NULL;
else {
SCARG(&a, tv) = stackgap_alloc(&sg, sizeof tv);
/* get the OSF/1 timeval argument */
error = copyin((caddr_t)SCARG(uap, tv),
(caddr_t)&otv, sizeof otv);
if (error == 0) {
/* fill in and copy out the NetBSD timeval */
memset(&tv, 0, sizeof tv);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
error = copyout((caddr_t)&tv,
(caddr_t)SCARG(&a, tv), sizeof tv);
}
}
if (SCARG(uap, tzp) == NULL)
SCARG(&a, tzp) = NULL;
else {
SCARG(&a, tzp) = stackgap_alloc(&sg, sizeof tz);
/* get the OSF/1 timeval argument */
error = copyin((caddr_t)SCARG(uap, tzp),
(caddr_t)&otz, sizeof otz);
if (error == 0) {
/* fill in and copy out the NetBSD timezone */
memset(&tz, 0, sizeof tz);
tz.tz_minuteswest = otz.tz_minuteswest;
tz.tz_dsttime = otz.tz_dsttime;
error = copyout((caddr_t)&tz,
(caddr_t)SCARG(&a, tzp), sizeof tz);
}
}
if (error == 0)
error = sys_settimeofday(p, &a, retval);
return (error);
}
int
osf1_sys_setitimer(p, v, retval)
struct proc *p;
@ -236,3 +174,65 @@ osf1_sys_setitimer(p, v, retval)
return (error);
}
int
osf1_sys_settimeofday(p, v, retval)
struct proc *p;
void *v;
register_t *retval;
{
struct osf1_sys_settimeofday_args *uap = v;
struct sys_settimeofday_args a;
struct osf1_timeval otv;
struct osf1_timezone otz;
struct timeval tv;
struct timezone tz;
int error;
caddr_t sg;
sg = stackgap_init(p->p_emul);
if (SCARG(uap, tv) == NULL)
SCARG(&a, tv) = NULL;
else {
SCARG(&a, tv) = stackgap_alloc(&sg, sizeof tv);
/* get the OSF/1 timeval argument */
error = copyin((caddr_t)SCARG(uap, tv),
(caddr_t)&otv, sizeof otv);
if (error == 0) {
/* fill in and copy out the NetBSD timeval */
memset(&tv, 0, sizeof tv);
tv.tv_sec = otv.tv_sec;
tv.tv_usec = otv.tv_usec;
error = copyout((caddr_t)&tv,
(caddr_t)SCARG(&a, tv), sizeof tv);
}
}
if (SCARG(uap, tzp) == NULL)
SCARG(&a, tzp) = NULL;
else {
SCARG(&a, tzp) = stackgap_alloc(&sg, sizeof tz);
/* get the OSF/1 timeval argument */
error = copyin((caddr_t)SCARG(uap, tzp),
(caddr_t)&otz, sizeof otz);
if (error == 0) {
/* fill in and copy out the NetBSD timezone */
memset(&tz, 0, sizeof tz);
tz.tz_minuteswest = otz.tz_minuteswest;
tz.tz_dsttime = otz.tz_dsttime;
error = copyout((caddr_t)&tz,
(caddr_t)SCARG(&a, tzp), sizeof tz);
}
}
if (error == 0)
error = sys_settimeofday(p, &a, retval);
return (error);
}