diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-07-01 01:54:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-07-01 01:54:39 +0000 |
commit | fe6905360db9a75c12cccb97100615bb7718b4c2 (patch) | |
tree | 9cc363a5b3754577b85446393782d0c074e0f287 /sys/compat/common | |
parent | 90dc06c1276ef0d223448a92f27201d740ba39cc (diff) |
compat_o43 and compat_23 can die
Diffstat (limited to 'sys/compat/common')
-rw-r--r-- | sys/compat/common/kern_ipc_23.c | 210 | ||||
-rw-r--r-- | sys/compat/common/vfs_syscalls_o43.c | 259 |
2 files changed, 0 insertions, 469 deletions
diff --git a/sys/compat/common/kern_ipc_23.c b/sys/compat/common/kern_ipc_23.c deleted file mode 100644 index 490362363e0..00000000000 --- a/sys/compat/common/kern_ipc_23.c +++ /dev/null @@ -1,210 +0,0 @@ -/* $OpenBSD: kern_ipc_23.c,v 1.5 2004/07/15 11:25:59 millert Exp $ */ - -/* - * Copyright (c) 2004 Todd C. Miller <Todd.Miller@courtesan.com> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/msg.h> -#include <sys/sem.h> -#include <sys/shm.h> - -#include <sys/mount.h> -#include <sys/syscallargs.h> - -/* - * Convert between new and old struct {msq,sem,shm}id_ds (both ways) - */ -#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM) -#define cvt_ds(to, from, type, base) do { \ - (to)->type##_perm.cuid = (from)->type##_perm.cuid; \ - (to)->type##_perm.cgid = (from)->type##_perm.cgid; \ - (to)->type##_perm.uid = (from)->type##_perm.uid; \ - (to)->type##_perm.gid = (from)->type##_perm.gid; \ - (to)->type##_perm.mode = (from)->type##_perm.mode & 0xffffU; \ - (to)->type##_perm.seq = (from)->type##_perm.seq; \ - (to)->type##_perm.key = (from)->type##_perm.key; \ - bcopy((caddr_t)&(from)->base, (caddr_t)&(to)->base, \ - sizeof(*(to)) - ((caddr_t)&(to)->base - (caddr_t)to)); \ -} while (0) -#endif /* SYSVMSG || SYSVSEM || SYSVSHM */ - -#ifdef SYSVMSG -/* - * Copy a struct msqid_ds23 from userland and convert to struct msqid_ds - */ -static int -msqid_copyin(const void *uaddr, void *kaddr, size_t len) -{ - struct msqid_ds *msqbuf = kaddr; - struct msqid_ds23 omsqbuf; - int error; - - if (len != sizeof(struct msqid_ds)) - return (EFAULT); - if ((error = copyin(uaddr, &omsqbuf, sizeof(omsqbuf))) == 0) - cvt_ds(msqbuf, &omsqbuf, msg, msg_first); - return (error); -} - -/* - * Convert a struct msqid_ds to struct msqid_ds23 and copy to userland - */ -static int -msqid_copyout(const void *kaddr, void *uaddr, size_t len) -{ - const struct msqid_ds *msqbuf = kaddr; - struct msqid_ds23 omsqbuf; - - if (len != sizeof(struct msqid_ds)) - return (EFAULT); - cvt_ds(&omsqbuf, msqbuf, msg, msg_first); - return (copyout(&omsqbuf, uaddr, sizeof(omsqbuf))); -} - -/* - * OpenBSD 2.3 msgctl(2) with 16bit values in struct ipcperm. - */ -int -compat_23_sys_msgctl(struct proc *p, void *v, register_t *retval) -{ - struct compat_23_sys_msgctl_args /* { - syscallarg(int) msqid; - syscallarg(int) cmd; - syscallarg(struct msqid_ds23 *) buf; - } */ *uap = v; - - return (msgctl1(p, SCARG(uap, msqid), SCARG(uap, cmd), - (caddr_t)SCARG(uap, buf), msqid_copyin, msqid_copyout)); -} -#endif /* SYSVMSG */ - -#ifdef SYSVSEM -/* - * Copy a struct semid_ds23 from userland and convert to struct semid_ds - */ -static int -semid_copyin(const void *uaddr, void *kaddr, size_t len) -{ - struct semid_ds *sembuf = kaddr; - struct semid_ds23 osembuf; - int error; - - if (len != sizeof(struct semid_ds)) - return (EFAULT); - if ((error = copyin(uaddr, &osembuf, sizeof(osembuf))) == 0) - cvt_ds(sembuf, &osembuf, sem, sem_base); - return (error); -} - -/* - * Convert a struct semid_ds to struct semid_ds23 and copy to userland - */ -static int -semid_copyout(const void *kaddr, void *uaddr, size_t len) -{ - const struct semid_ds *sembuf = kaddr; - struct semid_ds23 osembuf; - - if (len != sizeof(struct semid_ds)) - return (EFAULT); - cvt_ds(&osembuf, sembuf, sem, sem_base); - return (copyout(&osembuf, uaddr, sizeof(osembuf))); -} - -/* - * OpenBSD 2.3 semctl(2) with 16bit values in struct ipcperm. - */ -int -compat_23_sys___semctl(struct proc *p, void *v, register_t *retval) -{ - struct compat_23_sys___semctl_args /* { - syscallarg(int) semid; - syscallarg(int) semnum; - syscallarg(int) cmd; - syscallarg(union semun *) arg; - } */ *uap = v; - union semun arg; - int error = 0, cmd = SCARG(uap, cmd); - - switch (cmd) { - case IPC_SET: - case IPC_STAT: - case GETALL: - case SETVAL: - case SETALL: - error = copyin(SCARG(uap, arg), &arg, sizeof(arg)); - break; - } - if (error == 0) { - error = semctl1(p, SCARG(uap, semid), SCARG(uap, semnum), - cmd, &arg, retval, semid_copyin, semid_copyout); - } - return (error); -} -#endif /* SYSVSEM */ - -#ifdef SYSVSHM -/* - * Copy a struct shmid_ds23 from userland and convert to struct shmid_ds - */ -static int -shmid_copyin(const void *uaddr, void *kaddr, size_t len) -{ - struct shmid_ds *shmbuf = kaddr; - struct shmid_ds23 oshmbuf; - int error; - - if (len != sizeof(struct shmid_ds)) - return (EFAULT); - if ((error = copyin(uaddr, &oshmbuf, sizeof(oshmbuf))) == 0) - cvt_ds(shmbuf, &oshmbuf, shm, shm_segsz); - return (error); -} - -/* - * Convert a struct shmid_ds to struct shmid_ds23 and copy to userland - */ -static int -shmid_copyout(const void *kaddr, void *uaddr, size_t len) -{ - const struct shmid_ds *shmbuf = kaddr; - struct shmid_ds23 oshmbuf; - - if (len != sizeof(struct shmid_ds)) - return (EFAULT); - cvt_ds(&oshmbuf, shmbuf, shm, shm_segsz); - return (copyout(&oshmbuf, uaddr, sizeof(oshmbuf))); -} - -/* - * OpenBSD 2.3 shmctl(2) with 16bit values in struct ipcperm. - */ -int -compat_23_sys_shmctl(struct proc *p, void *v, register_t *retval) -{ - struct compat_23_sys_shmctl_args /* { - syscallarg(int) shmid; - syscallarg(int) cmd; - syscallarg(struct shmid_ds23 *) buf; - } */ *uap = v; - - return (shmctl1(p, SCARG(uap, shmid), SCARG(uap, cmd), - (caddr_t)SCARG(uap, buf), shmid_copyin, shmid_copyout)); -} -#endif /* SYSVSHM */ diff --git a/sys/compat/common/vfs_syscalls_o43.c b/sys/compat/common/vfs_syscalls_o43.c deleted file mode 100644 index f7b08a471ef..00000000000 --- a/sys/compat/common/vfs_syscalls_o43.c +++ /dev/null @@ -1,259 +0,0 @@ -/* $OpenBSD: vfs_syscalls_o43.c,v 1.1 2008/03/16 19:42:56 otto Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)vfs_syscalls.c 8.28 (Berkeley) 12/10/94 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/namei.h> -#include <sys/filedesc.h> -#include <sys/kernel.h> -#include <sys/file.h> -#include <sys/vnode.h> -#include <sys/mount.h> -#include <sys/proc.h> -#include <sys/uio.h> -#include <sys/dirent.h> - -#include <sys/syscallargs.h> - -void statfs_to_o43statfs(struct proc *, struct mount *, struct statfs *, - struct o43statfs *); - -/* - * Convert struct statfs -> struct ostatfs - */ -void -statfs_to_o43statfs(p, mp, sp, osp) - struct proc *p; - struct mount *mp; - struct statfs *sp; - struct o43statfs *osp; -{ - osp->f_flags = mp->mnt_flag; - osp->f_bsize = sp->f_bsize; - osp->f_iosize = sp->f_iosize; - osp->f_blocks = sp->f_blocks; - osp->f_bfree = sp->f_bfree; - osp->f_bavail = sp->f_bavail; - osp->f_files = sp->f_files; - osp->f_ffree = sp->f_ffree; - /* Don't let non-root see filesystem id (for NFS security) */ - if (suser(p, 0)) - osp->f_fsid.val[0] = osp->f_fsid.val[1] = 0; - else - bcopy(&sp->f_fsid, &osp->f_fsid, sizeof(osp->f_fsid)); - osp->f_owner = sp->f_owner; - osp->f_syncwrites = sp->f_syncwrites; - osp->f_asyncwrites = sp->f_asyncwrites; - osp->f_ctime = sp->f_ctime; - bcopy(sp->f_fstypename, osp->f_fstypename, MFSNAMELEN); - bcopy(sp->f_mntonname, osp->f_mntonname, MNAMELEN); - bcopy(sp->f_mntfromname, osp->f_mntfromname, MNAMELEN); - bcopy(&sp->mount_info, &osp->mount_info, sizeof(union mount_info)); -} - -/* - * Get filesystem statistics. - */ -/* ARGSUSED */ -int -compat_o43_sys_statfs(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct compat_o43_sys_statfs_args /* { - syscallarg(char *) path; - syscallarg(struct o43statfs *) buf; - } */ *uap = v; - register struct mount *mp; - register struct statfs *sp; - struct o43statfs osb; - int error; - struct nameidata nd; - - NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p); - if ((error = namei(&nd)) != 0) - return (error); - mp = nd.ni_vp->v_mount; - sp = &mp->mnt_stat; - vrele(nd.ni_vp); - if ((error = VFS_STATFS(mp, sp, p)) != 0) - return (error); - - statfs_to_o43statfs(p, mp, sp, &osb); - return (copyout((caddr_t)&osb, (caddr_t)SCARG(uap, buf), sizeof(osb))); -} - -/* - * Get filesystem statistics. - */ -/* ARGSUSED */ -int -compat_o43_sys_fstatfs(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct compat_o43_sys_fstatfs_args /* { - syscallarg(int) fd; - syscallarg(struct ostatfs *) buf; - } */ *uap = v; - struct file *fp; - struct mount *mp; - struct statfs *sp; - struct o43statfs osb; - int error; - - if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) - return (error); - mp = ((struct vnode *)fp->f_data)->v_mount; - sp = &mp->mnt_stat; - error = VFS_STATFS(mp, sp, p); - FRELE(fp); - if (error) - return (error); - - statfs_to_o43statfs(p, mp, sp, &osb); - return (copyout((caddr_t)&osb, (caddr_t)SCARG(uap, buf), sizeof(osb))); -} - -/* - * Get statistics on all filesystems. - */ -int -compat_o43_sys_getfsstat(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - register struct compat_o43_sys_getfsstat_args /* { - syscallarg(struct o43statfs *) buf; - syscallarg(long) bufsize; - syscallarg(int) flags; - } */ *uap = v; - register struct mount *mp, *nmp; - register struct statfs *sp; - struct o43statfs osb; - caddr_t sfsp; - long count, maxcount; - int error, flags = SCARG(uap, flags); - - maxcount = SCARG(uap, bufsize) / sizeof(struct ostatfs); - sfsp = (caddr_t)SCARG(uap, buf); - count = 0; - - for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist); - mp = nmp) { - if (vfs_busy(mp, VB_READ|VB_NOWAIT)) { - nmp = CIRCLEQ_NEXT(mp, mnt_list); - continue; - } - if (sfsp && count < maxcount) { - sp = &mp->mnt_stat; - - /* Refresh stats unless MNT_NOWAIT is specified */ - if (flags != MNT_NOWAIT && - flags != MNT_LAZY && - (flags == MNT_WAIT || - flags == 0) && - (error = VFS_STATFS(mp, sp, p))) { - nmp = CIRCLEQ_NEXT(mp, mnt_list); - vfs_unbusy(mp); - continue; - } - - statfs_to_o43statfs(p, mp, sp, &osb); - error = copyout((caddr_t)&osb, sfsp, sizeof(osb)); - if (error) { - vfs_unbusy(mp); - return (error); - } - sfsp += sizeof(osb); - } - count++; - nmp = CIRCLEQ_NEXT(mp, mnt_list); - vfs_unbusy(mp); - } - - if (sfsp && count > maxcount) - *retval = maxcount; - else - *retval = count; - - return (0); -} - - -/* ARGSUSED */ -int -compat_o43_sys_fhstatfs(struct proc *p, void *v, register_t *retval) -{ - struct sys_fhstatfs_args /* - syscallarg(const fhandle_t *) fhp; - syscallarg(struct o43statfs *) buf; - } */ *uap = v; - struct statfs *sp; - struct o43statfs osb; - fhandle_t fh; - struct mount *mp; - struct vnode *vp; - int error; - - /* - * Must be super user - */ - if ((error = suser(p, 0))) - return (error); - - if ((error = copyin(SCARG(uap, fhp), &fh, sizeof(fhandle_t))) != 0) - return (error); - - if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL) - return (ESTALE); - if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp))) - return (error); - mp = vp->v_mount; - sp = &mp->mnt_stat; - vput(vp); - if ((error = VFS_STATFS(mp, sp, p)) != 0) - return (error); - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; - statfs_to_o43statfs(p, mp, sp, &osb); - return copyout((caddr_t)&osb, SCARG(uap, buf), sizeof(osb)); -} - |