Index: head/sys/compat/linux/linux_file.c =================================================================== --- head/sys/compat/linux/linux_file.c (revision 68518) +++ head/sys/compat/linux/linux_file.c (revision 68519) @@ -1,874 +1,870 @@ /*- * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include "opt_compat.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#ifdef __alpha__ #include -#else -#include -#endif #include #ifndef __alpha__ int linux_creat(struct proc *p, struct linux_creat_args *args) { struct open_args /* { char *path; int flags; int mode; } */ bsd_open_args; caddr_t sg; sg = stackgap_init(); CHECKALTCREAT(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): creat(%s, %d)\n", p->p_pid, args->path, args->mode); #endif bsd_open_args.path = args->path; bsd_open_args.mode = args->mode; bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC; return open(p, &bsd_open_args); } #endif /*!__alpha__*/ int linux_open(struct proc *p, struct linux_open_args *args) { struct open_args /* { char *path; int flags; int mode; } */ bsd_open_args; int error; caddr_t sg; sg = stackgap_init(); if (args->flags & LINUX_O_CREAT) CHECKALTCREAT(p, &sg, args->path); else CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): open(%s, 0x%x, 0x%x)\n", p->p_pid, args->path, args->flags, args->mode); #endif bsd_open_args.flags = 0; if (args->flags & LINUX_O_RDONLY) bsd_open_args.flags |= O_RDONLY; if (args->flags & LINUX_O_WRONLY) bsd_open_args.flags |= O_WRONLY; if (args->flags & LINUX_O_RDWR) bsd_open_args.flags |= O_RDWR; if (args->flags & LINUX_O_NDELAY) bsd_open_args.flags |= O_NONBLOCK; if (args->flags & LINUX_O_APPEND) bsd_open_args.flags |= O_APPEND; if (args->flags & LINUX_O_SYNC) bsd_open_args.flags |= O_FSYNC; if (args->flags & LINUX_O_NONBLOCK) bsd_open_args.flags |= O_NONBLOCK; if (args->flags & LINUX_FASYNC) bsd_open_args.flags |= O_ASYNC; if (args->flags & LINUX_O_CREAT) bsd_open_args.flags |= O_CREAT; if (args->flags & LINUX_O_TRUNC) bsd_open_args.flags |= O_TRUNC; if (args->flags & LINUX_O_EXCL) bsd_open_args.flags |= O_EXCL; if (args->flags & LINUX_O_NOCTTY) bsd_open_args.flags |= O_NOCTTY; bsd_open_args.path = args->path; bsd_open_args.mode = args->mode; error = open(p, &bsd_open_args); if (!error && !(bsd_open_args.flags & O_NOCTTY) && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct filedesc *fdp = p->p_fd; struct file *fp = fdp->fd_ofiles[p->p_retval[0]]; if (fp->f_type == DTYPE_VNODE) fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p); } #ifdef DEBUG printf("Linux-emul(%d): open returns error %d\n", p->p_pid, error); #endif return error; } struct linux_flock { short l_type; short l_whence; linux_off_t l_start; linux_off_t l_len; linux_pid_t l_pid; }; static void linux_to_bsd_flock(struct linux_flock *linux_flock, struct flock *bsd_flock) { switch (linux_flock->l_type) { case LINUX_F_RDLCK: bsd_flock->l_type = F_RDLCK; break; case LINUX_F_WRLCK: bsd_flock->l_type = F_WRLCK; break; case LINUX_F_UNLCK: bsd_flock->l_type = F_UNLCK; break; default: bsd_flock->l_type = -1; break; } bsd_flock->l_whence = linux_flock->l_whence; bsd_flock->l_start = (off_t)linux_flock->l_start; bsd_flock->l_len = (off_t)linux_flock->l_len; bsd_flock->l_pid = (pid_t)linux_flock->l_pid; } static void bsd_to_linux_flock(struct flock *bsd_flock, struct linux_flock *linux_flock) { switch (bsd_flock->l_type) { case F_RDLCK: linux_flock->l_type = LINUX_F_RDLCK; break; case F_WRLCK: linux_flock->l_type = LINUX_F_WRLCK; break; case F_UNLCK: linux_flock->l_type = LINUX_F_UNLCK; break; } linux_flock->l_whence = bsd_flock->l_whence; linux_flock->l_start = (linux_off_t)bsd_flock->l_start; linux_flock->l_len = (linux_off_t)bsd_flock->l_len; linux_flock->l_pid = (linux_pid_t)bsd_flock->l_pid; } int linux_fcntl(struct proc *p, struct linux_fcntl_args *args) { int error, result; struct fcntl_args /* { int fd; int cmd; int arg; } */ fcntl_args; struct linux_flock linux_flock; struct flock *bsd_flock; caddr_t sg; sg = stackgap_init(); bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock)); #ifdef DEBUG printf("Linux-emul(%d): fcntl(%d, %08x, *)\n", p->p_pid, args->fd, args->cmd); #endif fcntl_args.fd = args->fd; switch (args->cmd) { case LINUX_F_DUPFD: fcntl_args.cmd = F_DUPFD; fcntl_args.arg = args->arg; return fcntl(p, &fcntl_args); case LINUX_F_GETFD: fcntl_args.cmd = F_GETFD; return fcntl(p, &fcntl_args); case LINUX_F_SETFD: fcntl_args.cmd = F_SETFD; fcntl_args.arg = args->arg; return fcntl(p, &fcntl_args); case LINUX_F_GETFL: fcntl_args.cmd = F_GETFL; error = fcntl(p, &fcntl_args); result = p->p_retval[0]; p->p_retval[0] = 0; if (result & O_RDONLY) p->p_retval[0] |= LINUX_O_RDONLY; if (result & O_WRONLY) p->p_retval[0] |= LINUX_O_WRONLY; if (result & O_RDWR) p->p_retval[0] |= LINUX_O_RDWR; if (result & O_NDELAY) p->p_retval[0] |= LINUX_O_NONBLOCK; if (result & O_APPEND) p->p_retval[0] |= LINUX_O_APPEND; if (result & O_FSYNC) p->p_retval[0] |= LINUX_O_SYNC; if (result & O_ASYNC) p->p_retval[0] |= LINUX_FASYNC; return error; case LINUX_F_SETFL: fcntl_args.arg = 0; if (args->arg & LINUX_O_NDELAY) fcntl_args.arg |= O_NONBLOCK; if (args->arg & LINUX_O_APPEND) fcntl_args.arg |= O_APPEND; if (args->arg & LINUX_O_SYNC) fcntl_args.arg |= O_FSYNC; if (args->arg & LINUX_FASYNC) fcntl_args.arg |= O_ASYNC; fcntl_args.cmd = F_SETFL; return fcntl(p, &fcntl_args); case LINUX_F_GETLK: if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock, sizeof(struct linux_flock)))) return error; linux_to_bsd_flock(&linux_flock, bsd_flock); fcntl_args.cmd = F_GETLK; fcntl_args.arg = (long)bsd_flock; error = fcntl(p, &fcntl_args); if (error) return error; bsd_to_linux_flock(bsd_flock, &linux_flock); return copyout((caddr_t)&linux_flock, (caddr_t)args->arg, sizeof(struct linux_flock)); case LINUX_F_SETLK: if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock, sizeof(struct linux_flock)))) return error; linux_to_bsd_flock(&linux_flock, bsd_flock); fcntl_args.cmd = F_SETLK; fcntl_args.arg = (long)bsd_flock; return fcntl(p, &fcntl_args); case LINUX_F_SETLKW: if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock, sizeof(struct linux_flock)))) return error; linux_to_bsd_flock(&linux_flock, bsd_flock); fcntl_args.cmd = F_SETLKW; fcntl_args.arg = (long)bsd_flock; return fcntl(p, &fcntl_args); case LINUX_F_GETOWN: fcntl_args.cmd = F_GETOWN; return fcntl(p, &fcntl_args); case LINUX_F_SETOWN: fcntl_args.cmd = F_SETOWN; fcntl_args.arg = args->arg; return fcntl(p, &fcntl_args); } return EINVAL; } int linux_lseek(struct proc *p, struct linux_lseek_args *args) { struct lseek_args /* { int fd; int pad; off_t offset; int whence; } */ tmp_args; int error; #ifdef DEBUG printf("Linux-emul(%ld): lseek(%d, %ld, %d)\n", (long)p->p_pid, args->fdes, args->off, args->whence); #endif tmp_args.fd = args->fdes; tmp_args.offset = (off_t)args->off; tmp_args.whence = args->whence; error = lseek(p, &tmp_args); return error; } #ifndef __alpha__ int linux_llseek(struct proc *p, struct linux_llseek_args *args) { struct lseek_args bsd_args; int error; off_t off; #ifdef DEBUG printf("Linux-emul(%d): llseek(%d, %d:%d, %d)\n", p->p_pid, args->fd, args->ohigh, args->olow, args->whence); #endif off = (args->olow) | (((off_t) args->ohigh) << 32); bsd_args.fd = args->fd; bsd_args.offset = off; bsd_args.whence = args->whence; if ((error = lseek(p, &bsd_args))) return error; if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t)))) return error; p->p_retval[0] = 0; return 0; } #endif /*!__alpha__*/ struct linux_dirent { long dino; linux_off_t doff; unsigned short dreclen; char dname[LINUX_NAME_MAX + 1]; }; #define LINUX_RECLEN(de,namlen) \ ALIGN((((char *)&(de)->dname - (char *)de) + (namlen) + 1)) #ifndef __alpha__ int linux_readdir(struct proc *p, struct linux_readdir_args *args) { struct linux_getdents_args lda; lda.fd = args->fd; lda.dent = args->dent; lda.count = 1; return linux_getdents(p, &lda); } #endif /*!__alpha__*/ int linux_getdents(struct proc *p, struct linux_getdents_args *args) { register struct dirent *bdp; struct vnode *vp; caddr_t inp, buf; /* BSD-format */ int len, reclen; /* BSD-format */ caddr_t outp; /* Linux-format */ int resid, linuxreclen=0; /* Linux-format */ struct file *fp; struct uio auio; struct iovec aiov; struct vattr va; off_t off; struct linux_dirent linux_dirent; int buflen, error, eofflag, nbytes, justone; u_long *cookies = NULL, *cookiep; int ncookies; #ifdef DEBUG printf("Linux-emul(%d): getdents(%d, *, %d)\n", p->p_pid, args->fd, args->count); #endif if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) { return (error); } if ((fp->f_flag & FREAD) == 0) return (EBADF); vp = (struct vnode *) fp->f_data; if (vp->v_type != VDIR) return (EINVAL); if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) { return error; } nbytes = args->count; if (nbytes == 1) { nbytes = sizeof (struct linux_dirent); justone = 1; } else justone = 0; off = fp->f_offset; #define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */ buflen = max(DIRBLKSIZ, nbytes); buflen = min(buflen, MAXBSIZE); buf = malloc(buflen, M_TEMP, M_WAITOK); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); again: aiov.iov_base = buf; aiov.iov_len = buflen; auio.uio_iov = &aiov; auio.uio_iovcnt = 1; auio.uio_rw = UIO_READ; auio.uio_segflg = UIO_SYSSPACE; auio.uio_procp = p; auio.uio_resid = buflen; auio.uio_offset = off; if (cookies) { free(cookies, M_TEMP); cookies = NULL; } error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies); if (error) { goto out; } inp = buf; outp = (caddr_t) args->dent; resid = nbytes; if ((len = buflen - auio.uio_resid) <= 0) { goto eof; } cookiep = cookies; if (cookies) { /* * When using cookies, the vfs has the option of reading from * a different offset than that supplied (UFS truncates the * offset to a block boundary to make sure that it never reads * partway through a directory entry, even if the directory * has been compacted). */ while (len > 0 && ncookies > 0 && *cookiep <= off) { bdp = (struct dirent *) inp; len -= bdp->d_reclen; inp += bdp->d_reclen; cookiep++; ncookies--; } } while (len > 0) { if (cookiep && ncookies == 0) break; bdp = (struct dirent *) inp; reclen = bdp->d_reclen; if (reclen & 3) { printf("linux_readdir: reclen=%d\n", reclen); error = EFAULT; goto out; } if (bdp->d_fileno == 0) { inp += reclen; if (cookiep) { off = *cookiep++; ncookies--; } else off += reclen; len -= reclen; continue; } linuxreclen = LINUX_RECLEN(&linux_dirent, bdp->d_namlen); if (reclen > len || resid < linuxreclen) { outp++; break; } linux_dirent.dino = (long) bdp->d_fileno; if (justone) { /* * old linux-style readdir usage. */ linux_dirent.doff = (linux_off_t) linuxreclen; linux_dirent.dreclen = (u_short) bdp->d_namlen; } else { if (cookiep) linux_dirent.doff = (linux_off_t)*cookiep; else linux_dirent.doff = (linux_off_t)(off + reclen); linux_dirent.dreclen = (u_short) linuxreclen; } strcpy(linux_dirent.dname, bdp->d_name); if ((error = copyout((caddr_t)&linux_dirent, outp, linuxreclen))) { goto out; } inp += reclen; if (cookiep) { off = *cookiep++; ncookies--; } else off += reclen; outp += linuxreclen; resid -= linuxreclen; len -= reclen; if (justone) break; } if (outp == (caddr_t) args->dent) goto again; fp->f_offset = off; if (justone) nbytes = resid + linuxreclen; eof: p->p_retval[0] = nbytes - resid; out: if (cookies) free(cookies, M_TEMP); VOP_UNLOCK(vp, 0, p); free(buf, M_TEMP); return error; } /* * These exist mainly for hooks for doing /compat/linux translation. */ int linux_access(struct proc *p, struct linux_access_args *args) { struct access_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): access(%s, %d)\n", p->p_pid, args->path, args->flags); #endif bsd.path = args->path; bsd.flags = args->flags; return access(p, &bsd); } int linux_unlink(struct proc *p, struct linux_unlink_args *args) { struct unlink_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): unlink(%s)\n", p->p_pid, args->path); #endif bsd.path = args->path; return unlink(p, &bsd); } int linux_chdir(struct proc *p, struct linux_chdir_args *args) { struct chdir_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): chdir(%s)\n", p->p_pid, args->path); #endif bsd.path = args->path; return chdir(p, &bsd); } int linux_chmod(struct proc *p, struct linux_chmod_args *args) { struct chmod_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): chmod(%s, %d)\n", p->p_pid, args->path, args->mode); #endif bsd.path = args->path; bsd.mode = args->mode; return chmod(p, &bsd); } int linux_chown(struct proc *p, struct linux_chown_args *args) { struct chown_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): chown(%s, %d, %d)\n", p->p_pid, args->path, args->uid, args->gid); #endif bsd.path = args->path; /* XXX size casts here */ bsd.uid = args->uid; bsd.gid = args->gid; return chown(p, &bsd); } int linux_lchown(struct proc *p, struct linux_lchown_args *args) { struct lchown_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): lchown(%s, %d, %d)\n", p->p_pid, args->path, args->uid, args->gid); #endif bsd.path = args->path; /* XXX size casts here */ bsd.uid = args->uid; bsd.gid = args->gid; return lchown(p, &bsd); } int linux_mkdir(struct proc *p, struct linux_mkdir_args *args) { struct mkdir_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTCREAT(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): mkdir(%s, %d)\n", p->p_pid, args->path, args->mode); #endif bsd.path = args->path; bsd.mode = args->mode; return mkdir(p, &bsd); } int linux_rmdir(struct proc *p, struct linux_rmdir_args *args) { struct rmdir_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): rmdir(%s)\n", p->p_pid, args->path); #endif bsd.path = args->path; return rmdir(p, &bsd); } int linux_rename(struct proc *p, struct linux_rename_args *args) { struct rename_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->from); CHECKALTCREAT(p, &sg, args->to); #ifdef DEBUG printf("Linux-emul(%d): rename(%s, %s)\n", p->p_pid, args->from, args->to); #endif bsd.from = args->from; bsd.to = args->to; return rename(p, &bsd); } int linux_symlink(struct proc *p, struct linux_symlink_args *args) { struct symlink_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); CHECKALTCREAT(p, &sg, args->to); #ifdef DEBUG printf("Linux-emul(%d): symlink(%s, %s)\n", p->p_pid, args->path, args->to); #endif bsd.path = args->path; bsd.link = args->to; return symlink(p, &bsd); } int linux_readlink(struct proc *p, struct linux_readlink_args *args) { struct readlink_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->name); #ifdef DEBUG printf("Linux-emul(%ld): readlink(%s, %p, %d)\n", (long)p->p_pid, args->name, (void *)args->buf, args->count); #endif bsd.path = args->name; bsd.buf = args->buf; bsd.count = args->count; return readlink(p, &bsd); } int linux_truncate(struct proc *p, struct linux_truncate_args *args) { struct truncate_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): truncate(%s, %ld)\n", p->p_pid, args->path, args->length); #endif bsd.path = args->path; bsd.length = args->length; return truncate(p, &bsd); } int linux_link(struct proc *p, struct linux_link_args *args) { struct link_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); CHECKALTCREAT(p, &sg, args->to); #ifdef DEBUG printf("Linux-emul(%d): link(%s, %s)\n", p->p_pid, args->path, args->to); #endif bsd.path = args->path; bsd.link = args->to; return link(p, &bsd); } int linux_getcwd(struct proc *p, struct linux_getcwd_args *args) { struct __getcwd_args bsd; caddr_t sg; int error, len; #ifdef DEBUG printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid, args->buf, args->bufsize); #endif sg = stackgap_init(); bsd.buf = stackgap_alloc(&sg, SPARE_USRSPACE); bsd.buflen = SPARE_USRSPACE; error = __getcwd(p, &bsd); if (!error) { len = strlen(bsd.buf) + 1; if (len <= args->bufsize) { p->p_retval[0] = len; error = copyout(bsd.buf, args->buf, len); } else error = ERANGE; } return (error); } #ifndef __alpha__ int linux_fdatasync(p, uap) struct proc *p; struct linux_fdatasync_args *uap; { struct fsync_args bsd; bsd.fd = uap->fd; return fsync(p, &bsd); } #endif /*!__alpha__*/ int linux_pread(p, uap) struct proc *p; struct linux_pread_args *uap; { struct pread_args bsd; bsd.fd = uap->fd; bsd.buf = uap->buf; bsd.nbyte = uap->nbyte; bsd.offset = uap->offset; return pread(p, &bsd); } int linux_pwrite(p, uap) struct proc *p; struct linux_pwrite_args *uap; { struct pwrite_args bsd; bsd.fd = uap->fd; bsd.buf = uap->buf; bsd.nbyte = uap->nbyte; bsd.offset = uap->offset; return pwrite(p, &bsd); } Index: head/sys/compat/linux/linux_ioctl.c =================================================================== --- head/sys/compat/linux/linux_ioctl.c (revision 68518) +++ head/sys/compat/linux/linux_ioctl.c (revision 68519) @@ -1,1545 +1,1541 @@ /* * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#ifdef __alpha__ #include -#else -#include -#endif #ifdef __alpha__ #include #else #include #endif #include #include static linux_ioctl_function_t linux_ioctl_cdrom; static linux_ioctl_function_t linux_ioctl_console; static linux_ioctl_function_t linux_ioctl_disk; static linux_ioctl_function_t linux_ioctl_socket; static linux_ioctl_function_t linux_ioctl_sound; static linux_ioctl_function_t linux_ioctl_termio; static struct linux_ioctl_handler cdrom_handler = { linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX }; static struct linux_ioctl_handler console_handler = { linux_ioctl_console, LINUX_IOCTL_CONSOLE_MIN, LINUX_IOCTL_CONSOLE_MAX }; static struct linux_ioctl_handler disk_handler = { linux_ioctl_disk, LINUX_IOCTL_DISK_MIN, LINUX_IOCTL_DISK_MAX }; static struct linux_ioctl_handler socket_handler = { linux_ioctl_socket, LINUX_IOCTL_SOCKET_MIN, LINUX_IOCTL_SOCKET_MAX }; static struct linux_ioctl_handler sound_handler = { linux_ioctl_sound, LINUX_IOCTL_SOUND_MIN, LINUX_IOCTL_SOUND_MAX }; static struct linux_ioctl_handler termio_handler = { linux_ioctl_termio, LINUX_IOCTL_TERMIO_MIN, LINUX_IOCTL_TERMIO_MAX }; DATA_SET(linux_ioctl_handler_set, cdrom_handler); DATA_SET(linux_ioctl_handler_set, console_handler); DATA_SET(linux_ioctl_handler_set, disk_handler); DATA_SET(linux_ioctl_handler_set, socket_handler); DATA_SET(linux_ioctl_handler_set, sound_handler); DATA_SET(linux_ioctl_handler_set, termio_handler); struct handler_element { TAILQ_ENTRY(handler_element) list; int (*func)(struct proc *, struct linux_ioctl_args *); int low, high, span; }; static TAILQ_HEAD(, handler_element) handlers = TAILQ_HEAD_INITIALIZER(handlers); static int linux_ioctl_disk(struct proc *p, struct linux_ioctl_args *args) { struct file *fp = p->p_fd->fd_ofiles[args->fd]; int error; struct disklabel dl; switch (args->cmd & 0xffff) { case LINUX_BLKGETSIZE: error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p); if (error) return (error); return copyout(&(dl.d_secperunit), (caddr_t)args->arg, sizeof(dl.d_secperunit)); break; } return (ENOIOCTL); } /* * termio related ioctls */ struct linux_termio { unsigned short c_iflag; unsigned short c_oflag; unsigned short c_cflag; unsigned short c_lflag; unsigned char c_line; unsigned char c_cc[LINUX_NCC]; }; struct linux_termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; #ifdef __alpha__ unsigned char c_cc[LINUX_NCCS]; unsigned char c_line; unsigned int c_ispeed; unsigned int c_ospeed; #else unsigned char c_line; unsigned char c_cc[LINUX_NCCS]; #endif }; struct linux_winsize { unsigned short ws_row, ws_col; unsigned short ws_xpixel, ws_ypixel; }; static struct speedtab sptab[] = { { B0, LINUX_B0 }, { B50, LINUX_B50 }, { B75, LINUX_B75 }, { B110, LINUX_B110 }, { B134, LINUX_B134 }, { B150, LINUX_B150 }, { B200, LINUX_B200 }, { B300, LINUX_B300 }, { B600, LINUX_B600 }, { B1200, LINUX_B1200 }, { B1800, LINUX_B1800 }, { B2400, LINUX_B2400 }, { B4800, LINUX_B4800 }, { B9600, LINUX_B9600 }, { B19200, LINUX_B19200 }, { B38400, LINUX_B38400 }, { B57600, LINUX_B57600 }, { B115200, LINUX_B115200 }, {-1, -1 } }; struct linux_serial_struct { int type; int line; int port; int irq; int flags; int xmit_fifo_size; int custom_divisor; int baud_base; unsigned short close_delay; char reserved_char[2]; int hub6; unsigned short closing_wait; unsigned short closing_wait2; int reserved[4]; }; static int linux_to_bsd_speed(int code, struct speedtab *table) { for ( ; table->sp_code != -1; table++) if (table->sp_code == code) return (table->sp_speed); return -1; } static int bsd_to_linux_speed(int speed, struct speedtab *table) { for ( ; table->sp_speed != -1; table++) if (table->sp_speed == speed) return (table->sp_code); return -1; } static void bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios) { int i; #ifdef DEBUG printf("LINUX: BSD termios structure (input):\n"); printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, bios->c_ispeed, bios->c_ospeed); printf("c_cc "); for (i=0; ic_cc[i]); printf("\n"); #endif lios->c_iflag = 0; if (bios->c_iflag & IGNBRK) lios->c_iflag |= LINUX_IGNBRK; if (bios->c_iflag & BRKINT) lios->c_iflag |= LINUX_BRKINT; if (bios->c_iflag & IGNPAR) lios->c_iflag |= LINUX_IGNPAR; if (bios->c_iflag & PARMRK) lios->c_iflag |= LINUX_PARMRK; if (bios->c_iflag & INPCK) lios->c_iflag |= LINUX_INPCK; if (bios->c_iflag & ISTRIP) lios->c_iflag |= LINUX_ISTRIP; if (bios->c_iflag & INLCR) lios->c_iflag |= LINUX_INLCR; if (bios->c_iflag & IGNCR) lios->c_iflag |= LINUX_IGNCR; if (bios->c_iflag & ICRNL) lios->c_iflag |= LINUX_ICRNL; if (bios->c_iflag & IXON) lios->c_iflag |= LINUX_IXON; if (bios->c_iflag & IXANY) lios->c_iflag |= LINUX_IXANY; if (bios->c_iflag & IXOFF) lios->c_iflag |= LINUX_IXOFF; if (bios->c_iflag & IMAXBEL) lios->c_iflag |= LINUX_IMAXBEL; lios->c_oflag = 0; if (bios->c_oflag & OPOST) lios->c_oflag |= LINUX_OPOST; if (bios->c_oflag & ONLCR) lios->c_oflag |= LINUX_ONLCR; if (bios->c_oflag & OXTABS) lios->c_oflag |= LINUX_XTABS; lios->c_cflag = bsd_to_linux_speed(bios->c_ispeed, sptab); lios->c_cflag |= (bios->c_cflag & CSIZE) >> 4; if (bios->c_cflag & CSTOPB) lios->c_cflag |= LINUX_CSTOPB; if (bios->c_cflag & CREAD) lios->c_cflag |= LINUX_CREAD; if (bios->c_cflag & PARENB) lios->c_cflag |= LINUX_PARENB; if (bios->c_cflag & PARODD) lios->c_cflag |= LINUX_PARODD; if (bios->c_cflag & HUPCL) lios->c_cflag |= LINUX_HUPCL; if (bios->c_cflag & CLOCAL) lios->c_cflag |= LINUX_CLOCAL; if (bios->c_cflag & CRTSCTS) lios->c_cflag |= LINUX_CRTSCTS; lios->c_lflag = 0; if (bios->c_lflag & ISIG) lios->c_lflag |= LINUX_ISIG; if (bios->c_lflag & ICANON) lios->c_lflag |= LINUX_ICANON; if (bios->c_lflag & ECHO) lios->c_lflag |= LINUX_ECHO; if (bios->c_lflag & ECHOE) lios->c_lflag |= LINUX_ECHOE; if (bios->c_lflag & ECHOK) lios->c_lflag |= LINUX_ECHOK; if (bios->c_lflag & ECHONL) lios->c_lflag |= LINUX_ECHONL; if (bios->c_lflag & NOFLSH) lios->c_lflag |= LINUX_NOFLSH; if (bios->c_lflag & TOSTOP) lios->c_lflag |= LINUX_TOSTOP; if (bios->c_lflag & ECHOCTL) lios->c_lflag |= LINUX_ECHOCTL; if (bios->c_lflag & ECHOPRT) lios->c_lflag |= LINUX_ECHOPRT; if (bios->c_lflag & ECHOKE) lios->c_lflag |= LINUX_ECHOKE; if (bios->c_lflag & FLUSHO) lios->c_lflag |= LINUX_FLUSHO; if (bios->c_lflag & PENDIN) lios->c_lflag |= LINUX_PENDIN; if (bios->c_lflag & IEXTEN) lios->c_lflag |= LINUX_IEXTEN; for (i=0; ic_cc[i] = LINUX_POSIX_VDISABLE; lios->c_cc[LINUX_VINTR] = bios->c_cc[VINTR]; lios->c_cc[LINUX_VQUIT] = bios->c_cc[VQUIT]; lios->c_cc[LINUX_VERASE] = bios->c_cc[VERASE]; lios->c_cc[LINUX_VKILL] = bios->c_cc[VKILL]; lios->c_cc[LINUX_VEOF] = bios->c_cc[VEOF]; lios->c_cc[LINUX_VEOL] = bios->c_cc[VEOL]; lios->c_cc[LINUX_VMIN] = bios->c_cc[VMIN]; lios->c_cc[LINUX_VTIME] = bios->c_cc[VTIME]; lios->c_cc[LINUX_VEOL2] = bios->c_cc[VEOL2]; lios->c_cc[LINUX_VSUSP] = bios->c_cc[VSUSP]; lios->c_cc[LINUX_VSTART] = bios->c_cc[VSTART]; lios->c_cc[LINUX_VSTOP] = bios->c_cc[VSTOP]; lios->c_cc[LINUX_VREPRINT] = bios->c_cc[VREPRINT]; lios->c_cc[LINUX_VDISCARD] = bios->c_cc[VDISCARD]; lios->c_cc[LINUX_VWERASE] = bios->c_cc[VWERASE]; lios->c_cc[LINUX_VLNEXT] = bios->c_cc[VLNEXT]; for (i=0; ic_cc[i] == _POSIX_VDISABLE) lios->c_cc[i] = LINUX_POSIX_VDISABLE; } lios->c_line = 0; #ifdef DEBUG printf("LINUX: LINUX termios structure (output):\n"); printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); printf("c_cc "); for (i=0; ic_cc[i]); printf("\n"); #endif } static void linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios) { int i; #ifdef DEBUG printf("LINUX: LINUX termios structure (input):\n"); printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag, lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line); printf("c_cc "); for (i=0; ic_cc[i]); printf("\n"); #endif bios->c_iflag = 0; if (lios->c_iflag & LINUX_IGNBRK) bios->c_iflag |= IGNBRK; if (lios->c_iflag & LINUX_BRKINT) bios->c_iflag |= BRKINT; if (lios->c_iflag & LINUX_IGNPAR) bios->c_iflag |= IGNPAR; if (lios->c_iflag & LINUX_PARMRK) bios->c_iflag |= PARMRK; if (lios->c_iflag & LINUX_INPCK) bios->c_iflag |= INPCK; if (lios->c_iflag & LINUX_ISTRIP) bios->c_iflag |= ISTRIP; if (lios->c_iflag & LINUX_INLCR) bios->c_iflag |= INLCR; if (lios->c_iflag & LINUX_IGNCR) bios->c_iflag |= IGNCR; if (lios->c_iflag & LINUX_ICRNL) bios->c_iflag |= ICRNL; if (lios->c_iflag & LINUX_IXON) bios->c_iflag |= IXON; if (lios->c_iflag & LINUX_IXANY) bios->c_iflag |= IXANY; if (lios->c_iflag & LINUX_IXOFF) bios->c_iflag |= IXOFF; if (lios->c_iflag & LINUX_IMAXBEL) bios->c_iflag |= IMAXBEL; bios->c_oflag = 0; if (lios->c_oflag & LINUX_OPOST) bios->c_oflag |= OPOST; if (lios->c_oflag & LINUX_ONLCR) bios->c_oflag |= ONLCR; if (lios->c_oflag & LINUX_XTABS) bios->c_oflag |= OXTABS; bios->c_cflag = (lios->c_cflag & LINUX_CSIZE) << 4; if (lios->c_cflag & LINUX_CSTOPB) bios->c_cflag |= CSTOPB; if (lios->c_cflag & LINUX_CREAD) bios->c_cflag |= CREAD; if (lios->c_cflag & LINUX_PARENB) bios->c_cflag |= PARENB; if (lios->c_cflag & LINUX_PARODD) bios->c_cflag |= PARODD; if (lios->c_cflag & LINUX_HUPCL) bios->c_cflag |= HUPCL; if (lios->c_cflag & LINUX_CLOCAL) bios->c_cflag |= CLOCAL; if (lios->c_cflag & LINUX_CRTSCTS) bios->c_cflag |= CRTSCTS; bios->c_lflag = 0; if (lios->c_lflag & LINUX_ISIG) bios->c_lflag |= ISIG; if (lios->c_lflag & LINUX_ICANON) bios->c_lflag |= ICANON; if (lios->c_lflag & LINUX_ECHO) bios->c_lflag |= ECHO; if (lios->c_lflag & LINUX_ECHOE) bios->c_lflag |= ECHOE; if (lios->c_lflag & LINUX_ECHOK) bios->c_lflag |= ECHOK; if (lios->c_lflag & LINUX_ECHONL) bios->c_lflag |= ECHONL; if (lios->c_lflag & LINUX_NOFLSH) bios->c_lflag |= NOFLSH; if (lios->c_lflag & LINUX_TOSTOP) bios->c_lflag |= TOSTOP; if (lios->c_lflag & LINUX_ECHOCTL) bios->c_lflag |= ECHOCTL; if (lios->c_lflag & LINUX_ECHOPRT) bios->c_lflag |= ECHOPRT; if (lios->c_lflag & LINUX_ECHOKE) bios->c_lflag |= ECHOKE; if (lios->c_lflag & LINUX_FLUSHO) bios->c_lflag |= FLUSHO; if (lios->c_lflag & LINUX_PENDIN) bios->c_lflag |= PENDIN; if (lios->c_lflag & LINUX_IEXTEN) bios->c_lflag |= IEXTEN; for (i=0; ic_cc[i] = _POSIX_VDISABLE; bios->c_cc[VINTR] = lios->c_cc[LINUX_VINTR]; bios->c_cc[VQUIT] = lios->c_cc[LINUX_VQUIT]; bios->c_cc[VERASE] = lios->c_cc[LINUX_VERASE]; bios->c_cc[VKILL] = lios->c_cc[LINUX_VKILL]; bios->c_cc[VEOF] = lios->c_cc[LINUX_VEOF]; bios->c_cc[VEOL] = lios->c_cc[LINUX_VEOL]; bios->c_cc[VMIN] = lios->c_cc[LINUX_VMIN]; bios->c_cc[VTIME] = lios->c_cc[LINUX_VTIME]; bios->c_cc[VEOL2] = lios->c_cc[LINUX_VEOL2]; bios->c_cc[VSUSP] = lios->c_cc[LINUX_VSUSP]; bios->c_cc[VSTART] = lios->c_cc[LINUX_VSTART]; bios->c_cc[VSTOP] = lios->c_cc[LINUX_VSTOP]; bios->c_cc[VREPRINT] = lios->c_cc[LINUX_VREPRINT]; bios->c_cc[VDISCARD] = lios->c_cc[LINUX_VDISCARD]; bios->c_cc[VWERASE] = lios->c_cc[LINUX_VWERASE]; bios->c_cc[VLNEXT] = lios->c_cc[LINUX_VLNEXT]; for (i=0; ic_cc[i] == LINUX_POSIX_VDISABLE) bios->c_cc[i] = _POSIX_VDISABLE; } bios->c_ispeed = bios->c_ospeed = linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab); #ifdef DEBUG printf("LINUX: BSD termios structure (output):\n"); printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n", bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag, bios->c_ispeed, bios->c_ospeed); printf("c_cc "); for (i=0; ic_cc[i]); printf("\n"); #endif } static void bsd_to_linux_termio(struct termios *bios, struct linux_termio *lio) { struct linux_termios lios; bsd_to_linux_termios(bios, &lios); lio->c_iflag = lios.c_iflag; lio->c_oflag = lios.c_oflag; lio->c_cflag = lios.c_cflag; lio->c_lflag = lios.c_lflag; lio->c_line = lios.c_line; memcpy(lio->c_cc, lios.c_cc, LINUX_NCC); } static void linux_to_bsd_termio(struct linux_termio *lio, struct termios *bios) { struct linux_termios lios; int i; lios.c_iflag = lio->c_iflag; lios.c_oflag = lio->c_oflag; lios.c_cflag = lio->c_cflag; lios.c_lflag = lio->c_lflag; for (i=LINUX_NCC; ic_cc, LINUX_NCC); linux_to_bsd_termios(&lios, bios); } static int linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args) { struct termios bios; struct linux_termios lios; struct linux_termio lio; struct file *fp = p->p_fd->fd_ofiles[args->fd]; int error; switch (args->cmd & 0xffff) { case LINUX_TCGETS: error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); if (error) return (error); bsd_to_linux_termios(&bios, &lios); return copyout(&lios, (caddr_t)args->arg, sizeof(lios)); case LINUX_TCSETS: error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); if (error) return (error); linux_to_bsd_termios(&lios, &bios); return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); case LINUX_TCSETSW: error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); if (error) return (error); linux_to_bsd_termios(&lios, &bios); return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); case LINUX_TCSETSF: error = copyin((caddr_t)args->arg, &lios, sizeof(lios)); if (error) return (error); linux_to_bsd_termios(&lios, &bios); return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); case LINUX_TCGETA: error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); if (error) return (error); bsd_to_linux_termio(&bios, &lio); return (copyout(&lio, (caddr_t)args->arg, sizeof(lio))); case LINUX_TCSETA: error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); if (error) return (error); linux_to_bsd_termio(&lio, &bios); return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p)); case LINUX_TCSETAW: error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); if (error) return (error); linux_to_bsd_termio(&lio, &bios); return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p)); case LINUX_TCSETAF: error = copyin((caddr_t)args->arg, &lio, sizeof(lio)); if (error) return (error); linux_to_bsd_termio(&lio, &bios); return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p)); /* LINUX_TCSBRK */ case LINUX_TCXONC: { switch (args->arg) { case LINUX_TCOOFF: args->cmd = TIOCSTOP; break; case LINUX_TCOON: args->cmd = TIOCSTART; break; case LINUX_TCIOFF: case LINUX_TCION: { int c; struct write_args wr; error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p); if (error) return (error); c = (args->arg == LINUX_TCIOFF) ? VSTOP : VSTART; c = bios.c_cc[c]; if (c != _POSIX_VDISABLE) { wr.fd = args->fd; wr.buf = &c; wr.nbyte = sizeof(c); return (write(p, &wr)); } else return (0); } default: return (EINVAL); } args->arg = 0; return (ioctl(p, (struct ioctl_args *)args)); } case LINUX_TCFLSH: { args->cmd = TIOCFLUSH; switch (args->arg) { case LINUX_TCIFLUSH: args->arg = FREAD; break; case LINUX_TCOFLUSH: args->arg = FWRITE; break; case LINUX_TCIOFLUSH: args->arg = FREAD | FWRITE; break; default: return (EINVAL); } return (ioctl(p, (struct ioctl_args *)args)); } case LINUX_TIOCEXCL: args->cmd = TIOCEXCL; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCNXCL: args->cmd = TIOCNXCL; return (ioctl(p, (struct ioctl_args *)args)); /* LINUX_TIOCSCTTY */ case LINUX_TIOCGPGRP: args->cmd = TIOCGPGRP; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCSPGRP: args->cmd = TIOCSPGRP; return (ioctl(p, (struct ioctl_args *)args)); /* LINUX_TIOCOUTQ */ /* LINUX_TIOCSTI */ case LINUX_TIOCGWINSZ: args->cmd = TIOCGWINSZ; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCSWINSZ: args->cmd = TIOCSWINSZ; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCMGET: args->cmd = TIOCMGET; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCMBIS: args->cmd = TIOCMBIS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCMBIC: args->cmd = TIOCMBIC; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCMSET: args->cmd = TIOCMSET; return (ioctl(p, (struct ioctl_args *)args)); /* TIOCGSOFTCAR */ /* TIOCSSOFTCAR */ case LINUX_FIONREAD: /* LINUX_TIOCINQ */ args->cmd = FIONREAD; return (ioctl(p, (struct ioctl_args *)args)); /* LINUX_TIOCLINUX */ case LINUX_TIOCCONS: args->cmd = TIOCCONS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCGSERIAL: { struct linux_serial_struct lss; lss.type = LINUX_PORT_16550A; lss.flags = 0; lss.close_delay = 0; return copyout(&lss, (caddr_t)args->arg, sizeof(lss)); } case LINUX_TIOCSSERIAL: { struct linux_serial_struct lss; error = copyin((caddr_t)args->arg, &lss, sizeof(lss)); if (error) return (error); /* XXX - It really helps to have an implementation that * does nothing. NOT! */ return (0); } /* LINUX_TIOCPKT */ case LINUX_FIONBIO: args->cmd = FIONBIO; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCNOTTY: args->cmd = TIOCNOTTY; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_TIOCSETD: { int line; switch (args->arg) { case LINUX_N_TTY: line = TTYDISC; break; case LINUX_N_SLIP: line = SLIPDISC; break; case LINUX_N_PPP: line = PPPDISC; break; default: return (EINVAL); } return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, p)); } case LINUX_TIOCGETD: { int linux_line; int bsd_line = TTYDISC; error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p); if (error) return (error); switch (bsd_line) { case TTYDISC: linux_line = LINUX_N_TTY; break; case SLIPDISC: linux_line = LINUX_N_SLIP; break; case PPPDISC: linux_line = LINUX_N_PPP; break; default: return (EINVAL); } return (copyout(&linux_line, (caddr_t)args->arg, sizeof(int))); } /* LINUX_TCSBRKP */ /* LINUX_TIOCTTYGSTRUCT */ case LINUX_FIONCLEX: args->cmd = FIONCLEX; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_FIOCLEX: args->cmd = FIOCLEX; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_FIOASYNC: args->cmd = FIOASYNC; return (ioctl(p, (struct ioctl_args *)args)); /* LINUX_TIOCSERCONFIG */ /* LINUX_TIOCSERGWILD */ /* LINUX_TIOCSERSWILD */ /* LINUX_TIOCGLCKTRMIOS */ /* LINUX_TIOCSLCKTRMIOS */ } return (ENOIOCTL); } /* * CDROM related ioctls */ struct linux_cdrom_msf { u_char cdmsf_min0; u_char cdmsf_sec0; u_char cdmsf_frame0; u_char cdmsf_min1; u_char cdmsf_sec1; u_char cdmsf_frame1; }; struct linux_cdrom_tochdr { u_char cdth_trk0; u_char cdth_trk1; }; union linux_cdrom_addr { struct { u_char minute; u_char second; u_char frame; } msf; int lba; }; struct linux_cdrom_tocentry { u_char cdte_track; u_char cdte_adr:4; u_char cdte_ctrl:4; u_char cdte_format; union linux_cdrom_addr cdte_addr; u_char cdte_datamode; }; struct linux_cdrom_subchnl { u_char cdsc_format; u_char cdsc_audiostatus; u_char cdsc_adr:4; u_char cdsc_ctrl:4; u_char cdsc_trk; u_char cdsc_ind; union linux_cdrom_addr cdsc_absaddr; union linux_cdrom_addr cdsc_reladdr; }; static void bsd_to_linux_msf_lba(u_char af, union msf_lba *bp, union linux_cdrom_addr *lp) { if (af == CD_LBA_FORMAT) lp->lba = bp->lba; else { lp->msf.minute = bp->msf.minute; lp->msf.second = bp->msf.second; lp->msf.frame = bp->msf.frame; } } static void set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba) { if (format == LINUX_CDROM_MSF) { addr->msf.frame = lba % 75; lba /= 75; lba += 2; addr->msf.second = lba % 60; addr->msf.minute = lba / 60; } else addr->lba = lba; } static int linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args) { struct file *fp = p->p_fd->fd_ofiles[args->fd]; int error; switch (args->cmd & 0xffff) { case LINUX_CDROMPAUSE: args->cmd = CDIOCPAUSE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_CDROMRESUME: args->cmd = CDIOCRESUME; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_CDROMPLAYMSF: args->cmd = CDIOCPLAYMSF; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_CDROMPLAYTRKIND: args->cmd = CDIOCPLAYTRACKS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_CDROMREADTOCHDR: { struct ioc_toc_header th; struct linux_cdrom_tochdr lth; error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p); if (!error) { lth.cdth_trk0 = th.starting_track; lth.cdth_trk1 = th.ending_track; copyout(<h, (caddr_t)args->arg, sizeof(lth)); } return (error); } case LINUX_CDROMREADTOCENTRY: { struct linux_cdrom_tocentry lte, *ltep = (struct linux_cdrom_tocentry *)args->arg; struct ioc_read_toc_single_entry irtse; irtse.address_format = ltep->cdte_format; irtse.track = ltep->cdte_track; error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p); if (!error) { lte = *ltep; lte.cdte_ctrl = irtse.entry.control; lte.cdte_adr = irtse.entry.addr_type; bsd_to_linux_msf_lba(irtse.address_format, &irtse.entry.addr, <e.cdte_addr); copyout(<e, (caddr_t)args->arg, sizeof(lte)); } return (error); } case LINUX_CDROMSTOP: args->cmd = CDIOCSTOP; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_CDROMSTART: args->cmd = CDIOCSTART; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_CDROMEJECT: args->cmd = CDIOCEJECT; return (ioctl(p, (struct ioctl_args *)args)); /* LINUX_CDROMVOLCTRL */ case LINUX_CDROMSUBCHNL: { struct linux_cdrom_subchnl sc; struct ioc_read_subchannel bsdsc; struct cd_sub_channel_info *bsdinfo; caddr_t sg = stackgap_init(); bsdinfo = (struct cd_sub_channel_info*)stackgap_alloc(&sg, sizeof(struct cd_sub_channel_info)); bsdsc.address_format = CD_LBA_FORMAT; bsdsc.data_format = CD_CURRENT_POSITION; bsdsc.track = 0; bsdsc.data_len = sizeof(struct cd_sub_channel_info); bsdsc.data = bsdinfo; error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p); if (error) return (error); error = copyin((caddr_t)args->arg, &sc, sizeof(struct linux_cdrom_subchnl)); if (error) return (error); sc.cdsc_audiostatus = bsdinfo->header.audio_status; sc.cdsc_adr = bsdinfo->what.position.addr_type; sc.cdsc_ctrl = bsdinfo->what.position.control; sc.cdsc_trk = bsdinfo->what.position.track_number; sc.cdsc_ind = bsdinfo->what.position.index_number; set_linux_cdrom_addr(&sc.cdsc_absaddr, sc.cdsc_format, bsdinfo->what.position.absaddr.lba); set_linux_cdrom_addr(&sc.cdsc_reladdr, sc.cdsc_format, bsdinfo->what.position.reladdr.lba); error = copyout(&sc, (caddr_t)args->arg, sizeof(struct linux_cdrom_subchnl)); return (error); } /* LINUX_CDROMREADMODE2 */ /* LINUX_CDROMREADMODE1 */ /* LINUX_CDROMREADAUDIO */ /* LINUX_CDROMEJECT_SW */ /* LINUX_CDROMMULTISESSION */ /* LINUX_CDROM_GET_UPC */ case LINUX_CDROMRESET: args->cmd = CDIOCRESET; return (ioctl(p, (struct ioctl_args *)args)); /* LINUX_CDROMVOLREAD */ /* LINUX_CDROMREADRAW */ /* LINUX_CDROMREADCOOKED */ /* LINUX_CDROMSEEK */ /* LINUX_CDROMPLAYBLK */ /* LINUX_CDROMREADALL */ /* LINUX_CDROMCLOSETRAY */ /* LINUX_CDROMLOADFROMSLOT */ } return (ENOIOCTL); } /* * Sound related ioctls */ static u_int32_t dirbits[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT }; #define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30]) static int linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args) { switch (args->cmd & 0xffff) { case LINUX_SOUND_MIXER_WRITE_VOLUME: args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_BASS: args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_TREBLE: args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_SYNTH: args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_PCM: args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_SPEAKER: args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_MIC: args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_CD: args->cmd = SETDIR(SOUND_MIXER_WRITE_CD); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_IMIX: args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_ALTPCM: args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_RECLEV: args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_IGAIN: args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_OGAIN: args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE1: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE2: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_MIXER_WRITE_LINE3: args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3); return (ioctl(p, (struct ioctl_args *)args)); case LINUX_OSS_GETVERSION: { int version = linux_get_oss_version(p); return (copyout(&version, (caddr_t)args->arg, sizeof(int))); } case LINUX_SOUND_MIXER_READ_DEVMASK: args->cmd = SOUND_MIXER_READ_DEVMASK; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_RESET: args->cmd = SNDCTL_DSP_RESET; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SYNC: args->cmd = SNDCTL_DSP_SYNC; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SPEED: args->cmd = SNDCTL_DSP_SPEED; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_STEREO: args->cmd = SNDCTL_DSP_STEREO; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETBLKSIZE: /* LINUX_SNDCTL_DSP_SETBLKSIZE */ args->cmd = SNDCTL_DSP_GETBLKSIZE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SETFMT: args->cmd = SNDCTL_DSP_SETFMT; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_PCM_WRITE_CHANNELS: args->cmd = SOUND_PCM_WRITE_CHANNELS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SOUND_PCM_WRITE_FILTER: args->cmd = SOUND_PCM_WRITE_FILTER; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_POST: args->cmd = SNDCTL_DSP_POST; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SUBDIVIDE: args->cmd = SNDCTL_DSP_SUBDIVIDE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SETFRAGMENT: args->cmd = SNDCTL_DSP_SETFRAGMENT; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETFMTS: args->cmd = SNDCTL_DSP_GETFMTS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETOSPACE: args->cmd = SNDCTL_DSP_GETOSPACE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETISPACE: args->cmd = SNDCTL_DSP_GETISPACE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_NONBLOCK: args->cmd = SNDCTL_DSP_NONBLOCK; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETCAPS: args->cmd = SNDCTL_DSP_GETCAPS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_SETTRIGGER: /* LINUX_SNDCTL_GETTRIGGER */ args->cmd = SNDCTL_DSP_SETTRIGGER; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETIPTR: args->cmd = SNDCTL_DSP_GETIPTR; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETOPTR: args->cmd = SNDCTL_DSP_GETOPTR; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_DSP_GETODELAY: args->cmd = SNDCTL_DSP_GETODELAY; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_RESET: args->cmd = SNDCTL_SEQ_RESET; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_SYNC: args->cmd = SNDCTL_SEQ_SYNC; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SYNTH_INFO: args->cmd = SNDCTL_SYNTH_INFO; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_CTRLRATE: args->cmd = SNDCTL_SEQ_CTRLRATE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_GETOUTCOUNT: args->cmd = SNDCTL_SEQ_GETOUTCOUNT; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_GETINCOUNT: args->cmd = SNDCTL_SEQ_GETINCOUNT; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_PERCMODE: args->cmd = SNDCTL_SEQ_PERCMODE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_FM_LOAD_INSTR: args->cmd = SNDCTL_FM_LOAD_INSTR; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_TESTMIDI: args->cmd = SNDCTL_SEQ_TESTMIDI; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_RESETSAMPLES: args->cmd = SNDCTL_SEQ_RESETSAMPLES; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_NRSYNTHS: args->cmd = SNDCTL_SEQ_NRSYNTHS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_NRMIDIS: args->cmd = SNDCTL_SEQ_NRMIDIS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_MIDI_INFO: args->cmd = SNDCTL_MIDI_INFO; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SEQ_TRESHOLD: args->cmd = SNDCTL_SEQ_TRESHOLD; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SNDCTL_SYNTH_MEMAVL: args->cmd = SNDCTL_SYNTH_MEMAVL; return (ioctl(p, (struct ioctl_args *)args)); } return (ENOIOCTL); } /* * Console related ioctls */ #define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG) static int linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args) { struct file *fp = p->p_fd->fd_ofiles[args->fd]; switch (args->cmd & 0xffff) { case LINUX_KIOCSOUND: args->cmd = KIOCSOUND; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_KDMKTONE: args->cmd = KDMKTONE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_KDGETLED: args->cmd = KDGETLED; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_KDSETLED: args->cmd = KDSETLED; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_KDSETMODE: args->cmd = KDSETMODE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_KDGETMODE: args->cmd = KDGETMODE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_KDGKBMODE: args->cmd = KDGKBMODE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_KDSKBMODE: { int kbdmode; switch (args->arg) { case LINUX_KBD_RAW: kbdmode = K_RAW; break; case LINUX_KBD_XLATE: kbdmode = K_XLATE; break; case LINUX_KBD_MEDIUMRAW: kbdmode = K_RAW; break; default: return (EINVAL); } return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p)); } case LINUX_VT_OPENQRY: args->cmd = VT_OPENQRY; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_VT_GETMODE: args->cmd = VT_GETMODE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_VT_SETMODE: { struct vt_mode *mode; args->cmd = VT_SETMODE; mode = (struct vt_mode *)args->arg; if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig)) mode->frsig = mode->acqsig; return (ioctl(p, (struct ioctl_args *)args)); } case LINUX_VT_GETSTATE: args->cmd = VT_GETACTIVE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_VT_RELDISP: args->cmd = VT_RELDISP; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_VT_ACTIVATE: args->cmd = VT_ACTIVATE; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_VT_WAITACTIVE: args->cmd = VT_WAITACTIVE; return (ioctl(p, (struct ioctl_args *)args)); } return (ENOIOCTL); } /* * Socket related ioctls */ static int linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args) { switch (args->cmd & 0xffff) { case LINUX_FIOSETOWN: args->cmd = FIOSETOWN; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCSPGRP: args->cmd = SIOCSPGRP; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_FIOGETOWN: args->cmd = FIOGETOWN; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCGPGRP: args->cmd = SIOCGPGRP; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCATMARK: args->cmd = SIOCATMARK; return (ioctl(p, (struct ioctl_args *)args)); /* LINUX_SIOCGSTAMP */ case LINUX_SIOCGIFCONF: args->cmd = OSIOCGIFCONF; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCGIFFLAGS: args->cmd = SIOCGIFFLAGS; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCGIFADDR: args->cmd = OSIOCGIFADDR; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCGIFDSTADDR: args->cmd = OSIOCGIFDSTADDR; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCGIFBRDADDR: args->cmd = OSIOCGIFBRDADDR; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCGIFNETMASK: args->cmd = OSIOCGIFNETMASK; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCGIFHWADDR: { int ifn; struct ifnet *ifp; struct ifaddr *ifa; struct sockaddr_dl *sdl; struct linux_ifreq *ifr = (struct linux_ifreq *)args->arg; /* Note that we don't actually respect the name in the ifreq * structure, as Linux interface names are all different. */ for (ifn = 0; ifn < if_index; ifn++) { ifp = ifnet_addrs[ifn]->ifa_ifp; if (ifp->if_type == IFT_ETHER) { ifa = TAILQ_FIRST(&ifp->if_addrhead); while (ifa) { sdl=(struct sockaddr_dl*)ifa->ifa_addr; if (sdl != NULL && (sdl->sdl_family == AF_LINK) && (sdl->sdl_type == IFT_ETHER)) { return (copyout(LLADDR(sdl), &ifr->ifr_hwaddr.sa_data, LINUX_IFHWADDRLEN)); } ifa = TAILQ_NEXT(ifa, ifa_link); } } } return (ENOENT); } case LINUX_SIOCADDMULTI: args->cmd = SIOCADDMULTI; return (ioctl(p, (struct ioctl_args *)args)); case LINUX_SIOCDELMULTI: args->cmd = SIOCDELMULTI; return (ioctl(p, (struct ioctl_args *)args)); } return (ENOIOCTL); } /* * main ioctl syscall function */ int linux_ioctl(struct proc *p, struct linux_ioctl_args *args) { struct filedesc *fdp = p->p_fd; struct file *fp; struct handler_element *he; int error, cmd; #ifdef DEBUG printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", (long)p->p_pid, args->fd, args->cmd); #endif if ((unsigned)args->fd >= fdp->fd_nfiles) return (EBADF); fp = fdp->fd_ofiles[args->fd]; if (fp == NULL || (fp->f_flag & (FREAD|FWRITE)) == 0) return (EBADF); /* Iterate over the ioctl handlers */ cmd = args->cmd & 0xffff; TAILQ_FOREACH(he, &handlers, list) { if (cmd >= he->low && cmd <= he->high) { error = (*he->func)(p, args); if (error != ENOIOCTL) return (error); } } printf("linux: 'ioctl' fd=%d, cmd=%x ('%c',%d) not implemented\n", args->fd, (int)(args->cmd & 0xffff), (int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff)); return (EINVAL); } int linux_ioctl_register_handler(struct linux_ioctl_handler *h) { struct handler_element *he, *cur; if (h == NULL || h->func == NULL) return (EINVAL); /* * Reuse the element if the handler is already on the list, otherwise * create a new element. */ TAILQ_FOREACH(he, &handlers, list) { if (he->func == h->func) break; } if (he == NULL) { MALLOC(he, struct handler_element *, sizeof(*he), M_LINUX, M_WAITOK); he->func = h->func; } else TAILQ_REMOVE(&handlers, he, list); /* Initialize range information. */ he->low = h->low; he->high = h->high; he->span = h->high - h->low + 1; /* Add the element to the list, sorted on span. */ TAILQ_FOREACH(cur, &handlers, list) { if (cur->span > he->span) { TAILQ_INSERT_BEFORE(cur, he, list); return (0); } } TAILQ_INSERT_TAIL(&handlers, he, list); return (0); } int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h) { struct handler_element *he; if (h == NULL || h->func == NULL) return (EINVAL); TAILQ_FOREACH(he, &handlers, list) { if (he->func == h->func) { TAILQ_REMOVE(&handlers, he, list); FREE(he, M_LINUX); return (0); } } return (EINVAL); } int linux_ioctl_register_handlers(struct linker_set *s) { int error, i; if (s == NULL) return (EINVAL); for (i = 0; i < s->ls_length; i++) { error = linux_ioctl_register_handler(s->ls_items[i]); if (error) return (error); } return (0); } int linux_ioctl_unregister_handlers(struct linker_set *s) { int error, i; if (s == NULL) return (EINVAL); for (i = 0; i < s->ls_length; i++) { error = linux_ioctl_unregister_handler(s->ls_items[i]); if (error) return (error); } return (0); } Index: head/sys/compat/linux/linux_ipc.c =================================================================== --- head/sys/compat/linux/linux_ipc.c (revision 68518) +++ head/sys/compat/linux/linux_ipc.c (revision 68519) @@ -1,453 +1,449 @@ /*- * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include -#ifdef __alpha__ #include -#else -#include -#endif #include #include struct linux_ipc_perm { linux_key_t key; unsigned short uid; unsigned short gid; unsigned short cuid; unsigned short cgid; unsigned short mode; unsigned short seq; }; static void linux_to_bsd_ipc_perm(struct linux_ipc_perm *lpp, struct ipc_perm *bpp) { bpp->key = lpp->key; bpp->uid = lpp->uid; bpp->gid = lpp->gid; bpp->cuid = lpp->cuid; bpp->cgid = lpp->cgid; bpp->mode = lpp->mode; bpp->seq = lpp->seq; } static void bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp) { lpp->key = bpp->key; lpp->uid = bpp->uid; lpp->gid = bpp->gid; lpp->cuid = bpp->cuid; lpp->cgid = bpp->cgid; lpp->mode = bpp->mode; lpp->seq = bpp->seq; } struct linux_semid_ds { struct linux_ipc_perm sem_perm; linux_time_t sem_otime; linux_time_t sem_ctime; void *sem_base; void *sem_pending; void *sem_pending_last; void *undo; ushort sem_nsems; }; struct linux_shmid_ds { struct linux_ipc_perm shm_perm; int shm_segsz; linux_time_t shm_atime; linux_time_t shm_dtime; linux_time_t shm_ctime; ushort shm_cpid; ushort shm_lpid; short shm_nattch; ushort private1; void *private2; void *private3; }; static void linux_to_bsd_semid_ds(struct linux_semid_ds *lsp, struct semid_ds *bsp) { linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm); bsp->sem_otime = lsp->sem_otime; bsp->sem_ctime = lsp->sem_ctime; bsp->sem_nsems = lsp->sem_nsems; bsp->sem_base = lsp->sem_base; } static void bsd_to_linux_semid_ds(struct semid_ds *bsp, struct linux_semid_ds *lsp) { bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm); lsp->sem_otime = bsp->sem_otime; lsp->sem_ctime = bsp->sem_ctime; lsp->sem_nsems = bsp->sem_nsems; lsp->sem_base = bsp->sem_base; } static void linux_to_bsd_shmid_ds(struct linux_shmid_ds *lsp, struct shmid_ds *bsp) { linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm); bsp->shm_segsz = lsp->shm_segsz; bsp->shm_lpid = lsp->shm_lpid; bsp->shm_cpid = lsp->shm_cpid; bsp->shm_nattch = lsp->shm_nattch; bsp->shm_atime = lsp->shm_atime; bsp->shm_dtime = lsp->shm_dtime; bsp->shm_ctime = lsp->shm_ctime; bsp->shm_internal = lsp->private3; /* this goes (yet) SOS */ } static void bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct linux_shmid_ds *lsp) { bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm); lsp->shm_segsz = bsp->shm_segsz; lsp->shm_lpid = bsp->shm_lpid; lsp->shm_cpid = bsp->shm_cpid; lsp->shm_nattch = bsp->shm_nattch; lsp->shm_atime = bsp->shm_atime; lsp->shm_dtime = bsp->shm_dtime; lsp->shm_ctime = bsp->shm_ctime; lsp->private3 = bsp->shm_internal; /* this goes (yet) SOS */ } int linux_semop(struct proc *p, struct linux_semop_args *args) { struct semop_args /* { int semid; struct sembuf *sops; int nsops; } */ bsd_args; bsd_args.semid = args->arg1; bsd_args.sops = (struct sembuf *)args->ptr; bsd_args.nsops = args->arg2; return semop(p, &bsd_args); } int linux_semget(struct proc *p, struct linux_semget_args *args) { struct semget_args /* { key_t key; int nsems; int semflg; } */ bsd_args; bsd_args.key = args->arg1; bsd_args.nsems = args->arg2; bsd_args.semflg = args->arg3; return semget(p, &bsd_args); } int linux_semctl(struct proc *p, struct linux_semctl_args *args) { struct linux_semid_ds linux_semid; struct semid_ds bsd_semid; struct __semctl_args /* { int semid; int semnum; int cmd; union semun *arg; } */ bsd_args; int error; caddr_t sg, unptr, dsp, ldsp; sg = stackgap_init(); bsd_args.semid = args->arg1; bsd_args.semnum = args->arg2; bsd_args.cmd = args->arg3; bsd_args.arg = (union semun *)args->ptr; switch (args->arg3) { case LINUX_IPC_RMID: bsd_args.cmd = IPC_RMID; break; case LINUX_GETNCNT: bsd_args.cmd = GETNCNT; break; case LINUX_GETPID: bsd_args.cmd = GETPID; break; case LINUX_GETVAL: bsd_args.cmd = GETVAL; break; case LINUX_GETZCNT: bsd_args.cmd = GETZCNT; break; case LINUX_SETVAL: bsd_args.cmd = SETVAL; break; case LINUX_IPC_SET: bsd_args.cmd = IPC_SET; error = copyin(args->ptr, &ldsp, sizeof(ldsp)); if (error) return error; error = copyin(ldsp, (caddr_t)&linux_semid, sizeof(linux_semid)); if (error) return error; linux_to_bsd_semid_ds(&linux_semid, &bsd_semid); unptr = stackgap_alloc(&sg, sizeof(union semun)); dsp = stackgap_alloc(&sg, sizeof(struct semid_ds)); error = copyout((caddr_t)&bsd_semid, dsp, sizeof(bsd_semid)); if (error) return error; error = copyout((caddr_t)&dsp, unptr, sizeof(dsp)); if (error) return error; bsd_args.arg = (union semun *)unptr; return __semctl(p, &bsd_args); case LINUX_IPC_STAT: bsd_args.cmd = IPC_STAT; unptr = stackgap_alloc(&sg, sizeof(union semun *)); dsp = stackgap_alloc(&sg, sizeof(struct semid_ds)); error = copyout((caddr_t)&dsp, unptr, sizeof(dsp)); if (error) return error; bsd_args.arg = (union semun *)unptr; error = __semctl(p, &bsd_args); if (error) return error; error = copyin(dsp, (caddr_t)&bsd_semid, sizeof(bsd_semid)); if (error) return error; bsd_to_linux_semid_ds(&bsd_semid, &linux_semid); error = copyin(args->ptr, &ldsp, sizeof(ldsp)); if (error) return error; return copyout((caddr_t)&linux_semid, ldsp, sizeof(linux_semid)); case LINUX_GETALL: /* FALLTHROUGH */ case LINUX_SETALL: /* FALLTHROUGH */ default: uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->arg3); return EINVAL; } return __semctl(p, &bsd_args); } int linux_msgsnd(struct proc *p, struct linux_msgsnd_args *args) { struct msgsnd_args /* { int msqid; void *msgp; size_t msgsz; int msgflg; } */ bsd_args; bsd_args.msqid = args->arg1; bsd_args.msgp = args->ptr; bsd_args.msgsz = args->arg2; bsd_args.msgflg = args->arg3; return msgsnd(p, &bsd_args); } int linux_msgrcv(struct proc *p, struct linux_msgrcv_args *args) { struct msgrcv_args /* { int msqid; void *msgp; size_t msgsz; long msgtyp; int msgflg; } */ bsd_args; bsd_args.msqid = args->arg1; bsd_args.msgp = args->ptr; bsd_args.msgsz = args->arg2; bsd_args.msgtyp = 0; bsd_args.msgflg = args->arg3; return msgrcv(p, &bsd_args); } int linux_msgget(struct proc *p, struct linux_msgget_args *args) { struct msgget_args /* { key_t key; int msgflg; } */ bsd_args; bsd_args.key = args->arg1; bsd_args.msgflg = args->arg2; return msgget(p, &bsd_args); } int linux_msgctl(struct proc *p, struct linux_msgctl_args *args) { struct msgctl_args /* { int msqid; int cmd; struct msqid_ds *buf; } */ bsd_args; int error; bsd_args.msqid = args->arg1; bsd_args.cmd = args->arg2; bsd_args.buf = (struct msqid_ds *)args->ptr; error = msgctl(p, &bsd_args); return ((args->arg2 == LINUX_IPC_RMID && error == EINVAL) ? 0 : error); } int linux_shmat(struct proc *p, struct linux_shmat_args *args) { struct shmat_args /* { int shmid; void *shmaddr; int shmflg; } */ bsd_args; int error; bsd_args.shmid = args->arg1; bsd_args.shmaddr = args->ptr; bsd_args.shmflg = args->arg2; if ((error = shmat(p, &bsd_args))) return error; #ifdef __i386__ if ((error = copyout(p->p_retval, (caddr_t)args->arg3, sizeof(int)))) return error; p->p_retval[0] = 0; #endif return 0; } int linux_shmdt(struct proc *p, struct linux_shmdt_args *args) { struct shmdt_args /* { void *shmaddr; } */ bsd_args; bsd_args.shmaddr = args->ptr; return shmdt(p, &bsd_args); } int linux_shmget(struct proc *p, struct linux_shmget_args *args) { struct shmget_args /* { key_t key; int size; int shmflg; } */ bsd_args; bsd_args.key = args->arg1; bsd_args.size = args->arg2; bsd_args.shmflg = args->arg3; return shmget(p, &bsd_args); } int linux_shmctl(struct proc *p, struct linux_shmctl_args *args) { struct shmid_ds bsd_shmid; struct linux_shmid_ds linux_shmid; struct shmctl_args /* { int shmid; int cmd; struct shmid_ds *buf; } */ bsd_args; int error; caddr_t sg = stackgap_init(); switch (args->arg2) { case LINUX_IPC_STAT: bsd_args.shmid = args->arg1; bsd_args.cmd = IPC_STAT; bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); if ((error = shmctl(p, &bsd_args))) return error; if ((error = copyin((caddr_t)bsd_args.buf, (caddr_t)&bsd_shmid, sizeof(struct shmid_ds)))) return error; bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid); return copyout((caddr_t)&linux_shmid, args->ptr, sizeof(linux_shmid)); case LINUX_IPC_SET: if ((error = copyin(args->ptr, (caddr_t)&linux_shmid, sizeof(linux_shmid)))) return error; linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid); bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf, sizeof(struct shmid_ds)))) return error; bsd_args.shmid = args->arg1; bsd_args.cmd = IPC_SET; return shmctl(p, &bsd_args); case LINUX_IPC_RMID: bsd_args.shmid = args->arg1; bsd_args.cmd = IPC_RMID; if (NULL == args->ptr) bsd_args.buf = NULL; else { if ((error = copyin(args->ptr, (caddr_t)&linux_shmid, sizeof(linux_shmid)))) return error; linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid); bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds)); if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf, sizeof(struct shmid_ds)))) return error; } return shmctl(p, &bsd_args); case LINUX_IPC_INFO: case LINUX_SHM_STAT: case LINUX_SHM_INFO: case LINUX_SHM_LOCK: case LINUX_SHM_UNLOCK: default: uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->arg2); return EINVAL; } } Index: head/sys/compat/linux/linux_misc.c =================================================================== --- head/sys/compat/linux/linux_misc.c (revision 68518) +++ head/sys/compat/linux/linux_misc.c (revision 68519) @@ -1,1146 +1,1142 @@ /*- * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include "opt_compat.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef __i386__ #include #endif #include #include -#ifdef __alpha__ #include -#else -#include -#endif #include #include #ifdef __alpha__ #define BSD_TO_LINUX_SIGNAL(sig) (sig) #else #define BSD_TO_LINUX_SIGNAL(sig) \ (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig) #endif struct linux_rlimit { unsigned long rlim_cur; unsigned long rlim_max; }; #ifndef __alpha__ static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] = { RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK, RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE, RLIMIT_MEMLOCK, -1 }; #endif /*!__alpha__*/ #ifndef __alpha__ int linux_alarm(struct proc *p, struct linux_alarm_args *args) { struct itimerval it, old_it; struct timeval tv; int s; #ifdef DEBUG printf("Linux-emul(%ld): alarm(%u)\n", (long)p->p_pid, args->secs); #endif if (args->secs > 100000000) return EINVAL; it.it_value.tv_sec = (long)args->secs; it.it_value.tv_usec = 0; it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; s = splsoftclock(); old_it = p->p_realtimer; getmicrouptime(&tv); if (timevalisset(&old_it.it_value)) untimeout(realitexpire, (caddr_t)p, p->p_ithandle); if (it.it_value.tv_sec != 0) { p->p_ithandle = timeout(realitexpire, (caddr_t)p, tvtohz(&it.it_value)); timevaladd(&it.it_value, &tv); } p->p_realtimer = it; splx(s); if (timevalcmp(&old_it.it_value, &tv, >)) { timevalsub(&old_it.it_value, &tv); if (old_it.it_value.tv_usec != 0) old_it.it_value.tv_sec++; p->p_retval[0] = old_it.it_value.tv_sec; } return 0; } #endif /*!__alpha__*/ int linux_brk(struct proc *p, struct linux_brk_args *args) { #if 0 struct vmspace *vm = p->p_vmspace; vm_offset_t new, old; int error; if ((vm_offset_t)args->dsend < (vm_offset_t)vm->vm_daddr) return EINVAL; if (((caddr_t)args->dsend - (caddr_t)vm->vm_daddr) > p->p_rlimit[RLIMIT_DATA].rlim_cur) return ENOMEM; old = round_page((vm_offset_t)vm->vm_daddr) + ctob(vm->vm_dsize); new = round_page((vm_offset_t)args->dsend); p->p_retval[0] = old; if ((new-old) > 0) { if (swap_pager_full) return ENOMEM; error = vm_map_find(&vm->vm_map, NULL, 0, &old, (new-old), FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) return error; vm->vm_dsize += btoc((new-old)); p->p_retval[0] = (int)(vm->vm_daddr + ctob(vm->vm_dsize)); } return 0; #else struct vmspace *vm = p->p_vmspace; vm_offset_t new, old; struct obreak_args /* { char * nsize; } */ tmp; #ifdef DEBUG printf("Linux-emul(%ld): brk(%p)\n", (long)p->p_pid, (void *)args->dsend); #endif old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize); new = (vm_offset_t)args->dsend; tmp.nsize = (char *) new; if (((caddr_t)new > vm->vm_daddr) && !obreak(p, &tmp)) p->p_retval[0] = (long)new; else p->p_retval[0] = (long)old; return 0; #endif } int linux_uselib(struct proc *p, struct linux_uselib_args *args) { struct nameidata ni; struct vnode *vp; struct exec *a_out; struct vattr attr; vm_offset_t vmaddr; unsigned long file_offset; vm_offset_t buffer; unsigned long bss_size; int error; caddr_t sg; int locked; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->library); #ifdef DEBUG printf("Linux-emul(%ld): uselib(%s)\n", (long)p->p_pid, args->library); #endif a_out = NULL; locked = 0; vp = NULL; NDINIT(&ni, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, args->library, p); error = namei(&ni); if (error) goto cleanup; vp = ni.ni_vp; /* * XXX This looks like a bogus check - a LOCKLEAF namei should not succeed * without returning a vnode. */ if (vp == NULL) { error = ENOEXEC; /* ?? */ goto cleanup; } NDFREE(&ni, NDF_ONLY_PNBUF); /* * From here on down, we have a locked vnode that must be unlocked. */ locked++; /* * Writable? */ if (vp->v_writecount) { error = ETXTBSY; goto cleanup; } /* * Executable? */ error = VOP_GETATTR(vp, &attr, p->p_ucred, p); if (error) goto cleanup; if ((vp->v_mount->mnt_flag & MNT_NOEXEC) || ((attr.va_mode & 0111) == 0) || (attr.va_type != VREG)) { error = ENOEXEC; goto cleanup; } /* * Sensible size? */ if (attr.va_size == 0) { error = ENOEXEC; goto cleanup; } /* * Can we access it? */ error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); if (error) goto cleanup; error = VOP_OPEN(vp, FREAD, p->p_ucred, p); if (error) goto cleanup; /* * Lock no longer needed */ VOP_UNLOCK(vp, 0, p); locked = 0; /* * Pull in executable header into kernel_map */ error = vm_mmap(kernel_map, (vm_offset_t *)&a_out, PAGE_SIZE, VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, 0); if (error) goto cleanup; /* * Is it a Linux binary ? */ if (((a_out->a_magic >> 16) & 0xff) != 0x64) { error = ENOEXEC; goto cleanup; } /* While we are here, we should REALLY do some more checks */ /* * Set file/virtual offset based on a.out variant. */ switch ((int)(a_out->a_magic & 0xffff)) { case 0413: /* ZMAGIC */ file_offset = 1024; break; case 0314: /* QMAGIC */ file_offset = 0; break; default: error = ENOEXEC; goto cleanup; } bss_size = round_page(a_out->a_bss); /* * Check various fields in header for validity/bounds. */ if (a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) { error = ENOEXEC; goto cleanup; } /* text + data can't exceed file size */ if (a_out->a_data + a_out->a_text > attr.va_size) { error = EFAULT; goto cleanup; } /* * text/data/bss must not exceed limits * XXX: this is not complete. it should check current usage PLUS * the resources needed by this library. */ if (a_out->a_text > MAXTSIZ || a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) { error = ENOMEM; goto cleanup; } /* * prevent more writers */ vp->v_flag |= VTEXT; /* * Check if file_offset page aligned,. * Currently we cannot handle misalinged file offsets, * and so we read in the entire image (what a waste). */ if (file_offset & PAGE_MASK) { #ifdef DEBUG printf("uselib: Non page aligned binary %lu\n", file_offset); #endif /* * Map text+data read/write/execute */ /* a_entry is the load address and is page aligned */ vmaddr = trunc_page(a_out->a_entry); /* get anon user mapping, read+write+execute */ error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr, a_out->a_text + a_out->a_data, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) goto cleanup; /* map file into kernel_map */ error = vm_mmap(kernel_map, &buffer, round_page(a_out->a_text + a_out->a_data + file_offset), VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, trunc_page(file_offset)); if (error) goto cleanup; /* copy from kernel VM space to user space */ error = copyout((caddr_t)(void *)(uintptr_t)(buffer + file_offset), (caddr_t)vmaddr, a_out->a_text + a_out->a_data); /* release temporary kernel space */ vm_map_remove(kernel_map, buffer, buffer + round_page(a_out->a_text + a_out->a_data + file_offset)); if (error) goto cleanup; } else { #ifdef DEBUG printf("uselib: Page aligned binary %lu\n", file_offset); #endif /* * for QMAGIC, a_entry is 20 bytes beyond the load address * to skip the executable header */ vmaddr = trunc_page(a_out->a_entry); /* * Map it all into the process's space as a single copy-on-write * "data" segment. */ error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr, a_out->a_text + a_out->a_data, VM_PROT_ALL, VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED, (caddr_t)vp, file_offset); if (error) goto cleanup; } #ifdef DEBUG printf("mem=%08lx = %08lx %08lx\n", vmaddr, ((long*)vmaddr)[0], ((long*)vmaddr)[1]); #endif if (bss_size != 0) { /* * Calculate BSS start address */ vmaddr = trunc_page(a_out->a_entry) + a_out->a_text + a_out->a_data; /* * allocate some 'anon' space */ error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr, bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0); if (error) goto cleanup; } cleanup: /* * Unlock vnode if needed */ if (locked) VOP_UNLOCK(vp, 0, p); /* * Release the kernel mapping. */ if (a_out) vm_map_remove(kernel_map, (vm_offset_t)a_out, (vm_offset_t)a_out + PAGE_SIZE); return error; } int linux_newselect(struct proc *p, struct linux_newselect_args *args) { struct select_args bsa; struct timeval tv0, tv1, utv, *tvp; caddr_t sg; int error; #ifdef DEBUG printf("Linux-emul(%ld): newselect(%d, %p, %p, %p, %p)\n", (long)p->p_pid, args->nfds, (void *)args->readfds, (void *)args->writefds, (void *)args->exceptfds, (void *)args->timeout); #endif error = 0; bsa.nd = args->nfds; bsa.in = args->readfds; bsa.ou = args->writefds; bsa.ex = args->exceptfds; bsa.tv = args->timeout; /* * Store current time for computation of the amount of * time left. */ if (args->timeout) { if ((error = copyin(args->timeout, &utv, sizeof(utv)))) goto select_out; #ifdef DEBUG printf("Linux-emul(%ld): incoming timeout (%ld/%ld)\n", (long)p->p_pid, utv.tv_sec, utv.tv_usec); #endif if (itimerfix(&utv)) { /* * The timeval was invalid. Convert it to something * valid that will act as it does under Linux. */ sg = stackgap_init(); tvp = stackgap_alloc(&sg, sizeof(utv)); utv.tv_sec += utv.tv_usec / 1000000; utv.tv_usec %= 1000000; if (utv.tv_usec < 0) { utv.tv_sec -= 1; utv.tv_usec += 1000000; } if (utv.tv_sec < 0) timevalclear(&utv); if ((error = copyout(&utv, tvp, sizeof(utv)))) goto select_out; bsa.tv = tvp; } microtime(&tv0); } error = select(p, &bsa); #ifdef DEBUG printf("Linux-emul(%ld): real select returns %d\n", (long)p->p_pid, error); #endif if (error) { /* * See fs/select.c in the Linux kernel. Without this, * Maelstrom doesn't work. */ if (error == ERESTART) error = EINTR; goto select_out; } if (args->timeout) { if (p->p_retval[0]) { /* * Compute how much time was left of the timeout, * by subtracting the current time and the time * before we started the call, and subtracting * that result from the user-supplied value. */ microtime(&tv1); timevalsub(&tv1, &tv0); timevalsub(&utv, &tv1); if (utv.tv_sec < 0) timevalclear(&utv); } else timevalclear(&utv); #ifdef DEBUG printf("Linux-emul(%ld): outgoing timeout (%ld/%ld)\n", (long)p->p_pid, utv.tv_sec, utv.tv_usec); #endif if ((error = copyout(&utv, args->timeout, sizeof(utv)))) goto select_out; } select_out: #ifdef DEBUG printf("Linux-emul(%ld): newselect_out -> %d\n", (long)p->p_pid, error); #endif return error; } int linux_getpgid(struct proc *p, struct linux_getpgid_args *args) { struct proc *curp; #ifdef DEBUG printf("Linux-emul(%ld): getpgid(%d)\n", (long)p->p_pid, args->pid); #endif if (args->pid != p->p_pid) { if (!(curp = pfind(args->pid))) return ESRCH; } else curp = p; p->p_retval[0] = curp->p_pgid; return 0; } int linux_mremap(struct proc *p, struct linux_mremap_args *args) { struct munmap_args /* { void *addr; size_t len; } */ bsd_args; int error = 0; #ifdef DEBUG printf("Linux-emul(%ld): mremap(%p, %08lx, %08lx, %08lx)\n", (long)p->p_pid, (void *)args->addr, (unsigned long)args->old_len, (unsigned long)args->new_len, (unsigned long)args->flags); #endif args->new_len = round_page(args->new_len); args->old_len = round_page(args->old_len); if (args->new_len > args->old_len) { p->p_retval[0] = 0; return ENOMEM; } if (args->new_len < args->old_len) { bsd_args.addr = args->addr + args->new_len; bsd_args.len = args->old_len - args->new_len; error = munmap(p, &bsd_args); } p->p_retval[0] = error ? 0 : (u_long)args->addr; return error; } int linux_msync(struct proc *p, struct linux_msync_args *args) { struct msync_args bsd_args; bsd_args.addr = args->addr; bsd_args.len = args->len; bsd_args.flags = 0; /* XXX ignore */ return msync(p, &bsd_args); } #ifndef __alpha__ int linux_time(struct proc *p, struct linux_time_args *args) { struct timeval tv; linux_time_t tm; int error; #ifdef DEBUG printf("Linux-emul(%ld): time(*)\n", (long)p->p_pid); #endif microtime(&tv); tm = tv.tv_sec; if (args->tm && (error = copyout(&tm, args->tm, sizeof(linux_time_t)))) return error; p->p_retval[0] = tm; return 0; } #endif /*!__alpha__*/ struct linux_times_argv { long tms_utime; long tms_stime; long tms_cutime; long tms_cstime; }; #define CLK_TCK 100 /* Linux uses 100 */ #define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK)) int linux_times(struct proc *p, struct linux_times_args *args) { struct timeval tv; struct linux_times_argv tms; struct rusage ru; int error; #ifdef DEBUG printf("Linux-emul(%ld): times(*)\n", (long)p->p_pid); #endif calcru(p, &ru.ru_utime, &ru.ru_stime, NULL); tms.tms_utime = CONVTCK(ru.ru_utime); tms.tms_stime = CONVTCK(ru.ru_stime); tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime); tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime); if ((error = copyout((caddr_t)&tms, (caddr_t)args->buf, sizeof(struct linux_times_argv)))) return error; microuptime(&tv); p->p_retval[0] = (int)CONVTCK(tv); return 0; } int linux_newuname(struct proc *p, struct linux_newuname_args *args) { struct linux_new_utsname utsname; char *osrelease, *osname; #ifdef DEBUG printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid); #endif osname = linux_get_osname(p); osrelease = linux_get_osrelease(p); bzero(&utsname, sizeof(struct linux_new_utsname)); strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1); strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1); strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1); strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1); strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1); strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1); return (copyout((caddr_t)&utsname, (caddr_t)args->buf, sizeof(struct linux_new_utsname))); } struct linux_utimbuf { linux_time_t l_actime; linux_time_t l_modtime; }; int linux_utime(struct proc *p, struct linux_utime_args *args) { struct utimes_args /* { char *path; struct timeval *tptr; } */ bsdutimes; struct timeval tv[2], *tvp; struct linux_utimbuf lut; int error; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->fname); #ifdef DEBUG printf("Linux-emul(%ld): utime(%s, *)\n", (long)p->p_pid, args->fname); #endif if (args->times) { if ((error = copyin(args->times, &lut, sizeof lut))) return error; tv[0].tv_sec = lut.l_actime; tv[0].tv_usec = 0; tv[1].tv_sec = lut.l_modtime; tv[1].tv_usec = 0; /* so that utimes can copyin */ tvp = (struct timeval *)stackgap_alloc(&sg, sizeof(tv)); if (tvp == NULL) return (ENAMETOOLONG); if ((error = copyout(tv, tvp, sizeof(tv)))) return error; bsdutimes.tptr = tvp; } else bsdutimes.tptr = NULL; bsdutimes.path = args->fname; return utimes(p, &bsdutimes); } #define __WCLONE 0x80000000 #ifndef __alpha__ int linux_waitpid(struct proc *p, struct linux_waitpid_args *args) { struct wait_args /* { int pid; int *status; int options; struct rusage *rusage; } */ tmp; int error, tmpstat; #ifdef DEBUG printf("Linux-emul(%ld): waitpid(%d, %p, %d)\n", (long)p->p_pid, args->pid, (void *)args->status, args->options); #endif tmp.pid = args->pid; tmp.status = args->status; tmp.options = (args->options & (WNOHANG | WUNTRACED)); /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ if (args->options & __WCLONE) tmp.options |= WLINUXCLONE; tmp.rusage = NULL; if ((error = wait4(p, &tmp)) != 0) return error; if (args->status) { if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) return error; tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); else if (WIFSTOPPED(tmpstat)) tmpstat = (tmpstat & 0xffff00ff) | (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); return copyout(&tmpstat, args->status, sizeof(int)); } else return 0; } #endif /*!__alpha__*/ int linux_wait4(struct proc *p, struct linux_wait4_args *args) { struct wait_args /* { int pid; int *status; int options; struct rusage *rusage; } */ tmp; int error, tmpstat; #ifdef DEBUG printf("Linux-emul(%ld): wait4(%d, %p, %d, %p)\n", (long)p->p_pid, args->pid, (void *)args->status, args->options, (void *)args->rusage); #endif tmp.pid = args->pid; tmp.status = args->status; tmp.options = (args->options & (WNOHANG | WUNTRACED)); /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ if (args->options & __WCLONE) tmp.options |= WLINUXCLONE; tmp.rusage = args->rusage; if ((error = wait4(p, &tmp)) != 0) return error; SIGDELSET(p->p_siglist, SIGCHLD); if (args->status) { if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) return error; tmpstat &= 0xffff; if (WIFSIGNALED(tmpstat)) tmpstat = (tmpstat & 0xffffff80) | BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); else if (WIFSTOPPED(tmpstat)) tmpstat = (tmpstat & 0xffff00ff) | (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8); return copyout(&tmpstat, args->status, sizeof(int)); } else return 0; } int linux_mknod(struct proc *p, struct linux_mknod_args *args) { caddr_t sg; struct mknod_args bsd_mknod; struct mkfifo_args bsd_mkfifo; sg = stackgap_init(); CHECKALTCREAT(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%ld): mknod(%s, %d, %d)\n", (long)p->p_pid, args->path, args->mode, args->dev); #endif if (args->mode & S_IFIFO) { bsd_mkfifo.path = args->path; bsd_mkfifo.mode = args->mode; return mkfifo(p, &bsd_mkfifo); } else { bsd_mknod.path = args->path; bsd_mknod.mode = args->mode; bsd_mknod.dev = args->dev; return mknod(p, &bsd_mknod); } } /* * UGH! This is just about the dumbest idea I've ever heard!! */ int linux_personality(struct proc *p, struct linux_personality_args *args) { #ifdef DEBUG printf("Linux-emul(%ld): personality(%d)\n", (long)p->p_pid, args->per); #endif #ifndef __alpha__ if (args->per != 0) return EINVAL; #endif /* Yes Jim, it's still a Linux... */ p->p_retval[0] = 0; return 0; } /* * Wrappers for get/setitimer for debugging.. */ int linux_setitimer(struct proc *p, struct linux_setitimer_args *args) { struct setitimer_args bsa; struct itimerval foo; int error; #ifdef DEBUG printf("Linux-emul(%ld): setitimer(%p, %p)\n", (long)p->p_pid, (void *)args->itv, (void *)args->oitv); #endif bsa.which = args->which; bsa.itv = args->itv; bsa.oitv = args->oitv; if (args->itv) { if ((error = copyin((caddr_t)args->itv, (caddr_t)&foo, sizeof(foo)))) return error; #ifdef DEBUG printf("setitimer: value: sec: %ld, usec: %ld\n", foo.it_value.tv_sec, foo.it_value.tv_usec); printf("setitimer: interval: sec: %ld, usec: %ld\n", foo.it_interval.tv_sec, foo.it_interval.tv_usec); #endif } return setitimer(p, &bsa); } int linux_getitimer(struct proc *p, struct linux_getitimer_args *args) { struct getitimer_args bsa; #ifdef DEBUG printf("Linux-emul(%ld): getitimer(%p)\n", (long)p->p_pid, (void *)args->itv); #endif bsa.which = args->which; bsa.itv = args->itv; return getitimer(p, &bsa); } #ifndef __alpha__ int linux_nice(struct proc *p, struct linux_nice_args *args) { struct setpriority_args bsd_args; bsd_args.which = PRIO_PROCESS; bsd_args.who = 0; /* current process */ bsd_args.prio = args->inc; return setpriority(p, &bsd_args); } #endif /*!__alpha__*/ int linux_setgroups(p, uap) struct proc *p; struct linux_setgroups_args *uap; { struct pcred *pc; linux_gid_t linux_gidset[NGROUPS]; gid_t *bsd_gidset; int ngrp, error; pc = p->p_cred; ngrp = uap->gidsetsize; /* * cr_groups[0] holds egid. Setting the whole set from * the supplied set will cause egid to be changed too. * Keep cr_groups[0] unchanged to prevent that. */ if ((error = suser(p)) != 0) return (error); if (ngrp >= NGROUPS) return (EINVAL); pc->pc_ucred = crcopy(pc->pc_ucred); if (ngrp > 0) { error = copyin((caddr_t)uap->gidset, (caddr_t)linux_gidset, ngrp * sizeof(linux_gid_t)); if (error) return (error); pc->pc_ucred->cr_ngroups = ngrp + 1; bsd_gidset = pc->pc_ucred->cr_groups; ngrp--; while (ngrp >= 0) { bsd_gidset[ngrp + 1] = linux_gidset[ngrp]; ngrp--; } } else pc->pc_ucred->cr_ngroups = 1; setsugid(p); return (0); } int linux_getgroups(p, uap) struct proc *p; struct linux_getgroups_args *uap; { struct pcred *pc; linux_gid_t linux_gidset[NGROUPS]; gid_t *bsd_gidset; int bsd_gidsetsz, ngrp, error; pc = p->p_cred; bsd_gidset = pc->pc_ucred->cr_groups; bsd_gidsetsz = pc->pc_ucred->cr_ngroups - 1; /* * cr_groups[0] holds egid. Returning the whole set * here will cause a duplicate. Exclude cr_groups[0] * to prevent that. */ if ((ngrp = uap->gidsetsize) == 0) { p->p_retval[0] = bsd_gidsetsz; return (0); } if (ngrp < bsd_gidsetsz) return (EINVAL); ngrp = 0; while (ngrp < bsd_gidsetsz) { linux_gidset[ngrp] = bsd_gidset[ngrp + 1]; ngrp++; } if ((error = copyout((caddr_t)linux_gidset, (caddr_t)uap->gidset, ngrp * sizeof(linux_gid_t)))) return (error); p->p_retval[0] = ngrp; return (0); } #ifndef __alpha__ int linux_setrlimit(p, uap) struct proc *p; struct linux_setrlimit_args *uap; { struct __setrlimit_args bsd; struct linux_rlimit rlim; int error; caddr_t sg = stackgap_init(); #ifdef DEBUG printf("Linux-emul(%ld): setrlimit(%d, %p)\n", (long)p->p_pid, uap->resource, (void *)uap->rlim); #endif if (uap->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); bsd.which = linux_to_bsd_resource[uap->resource]; if (bsd.which == -1) return (EINVAL); error = copyin(uap->rlim, &rlim, sizeof(rlim)); if (error) return (error); bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit)); bsd.rlp->rlim_cur = (rlim_t)rlim.rlim_cur; bsd.rlp->rlim_max = (rlim_t)rlim.rlim_max; return (setrlimit(p, &bsd)); } int linux_getrlimit(p, uap) struct proc *p; struct linux_getrlimit_args *uap; { struct __getrlimit_args bsd; struct linux_rlimit rlim; int error; caddr_t sg = stackgap_init(); #ifdef DEBUG printf("Linux-emul(%ld): getrlimit(%d, %p)\n", (long)p->p_pid, uap->resource, (void *)uap->rlim); #endif if (uap->resource >= LINUX_RLIM_NLIMITS) return (EINVAL); bsd.which = linux_to_bsd_resource[uap->resource]; if (bsd.which == -1) return (EINVAL); bsd.rlp = stackgap_alloc(&sg, sizeof(struct rlimit)); error = getrlimit(p, &bsd); if (error) return (error); rlim.rlim_cur = (unsigned long)bsd.rlp->rlim_cur; if (rlim.rlim_cur == ULONG_MAX) rlim.rlim_cur = LONG_MAX; rlim.rlim_max = (unsigned long)bsd.rlp->rlim_max; if (rlim.rlim_max == ULONG_MAX) rlim.rlim_max = LONG_MAX; return (copyout(&rlim, uap->rlim, sizeof(rlim))); } #endif /*!__alpha__*/ int linux_sched_setscheduler(p, uap) struct proc *p; struct linux_sched_setscheduler_args *uap; { struct sched_setscheduler_args bsd; #ifdef DEBUG printf("Linux-emul(%ld): sched_setscheduler(%d, %d, %p)\n", (long)p->p_pid, uap->pid, uap->policy, (const void *)uap->param); #endif switch (uap->policy) { case LINUX_SCHED_OTHER: bsd.policy = SCHED_OTHER; break; case LINUX_SCHED_FIFO: bsd.policy = SCHED_FIFO; break; case LINUX_SCHED_RR: bsd.policy = SCHED_RR; break; default: return EINVAL; } bsd.pid = uap->pid; bsd.param = uap->param; return sched_setscheduler(p, &bsd); } int linux_sched_getscheduler(p, uap) struct proc *p; struct linux_sched_getscheduler_args *uap; { struct sched_getscheduler_args bsd; int error; #ifdef DEBUG printf("Linux-emul(%ld): sched_getscheduler(%d)\n", (long)p->p_pid, uap->pid); #endif bsd.pid = uap->pid; error = sched_getscheduler(p, &bsd); switch (p->p_retval[0]) { case SCHED_OTHER: p->p_retval[0] = LINUX_SCHED_OTHER; break; case SCHED_FIFO: p->p_retval[0] = LINUX_SCHED_FIFO; break; case SCHED_RR: p->p_retval[0] = LINUX_SCHED_RR; break; } return error; } Index: head/sys/compat/linux/linux_signal.c =================================================================== --- head/sys/compat/linux/linux_signal.c (revision 68518) +++ head/sys/compat/linux/linux_signal.c (revision 68519) @@ -1,426 +1,422 @@ /*- * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include -#ifdef __alpha__ #include -#else -#include -#endif #include #include void linux_to_bsd_sigset(linux_sigset_t *lss, sigset_t *bss) { int b, l; SIGEMPTYSET(*bss); bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); bss->__bits[1] = lss->__bits[1]; for (l = 1; l <= LINUX_SIGTBLSZ; l++) { if (LINUX_SIGISMEMBER(*lss, l)) { #ifdef __alpha__ b = _SIG_IDX(l); #else b = linux_to_bsd_signal[_SIG_IDX(l)]; #endif if (b) SIGADDSET(*bss, b); } } } void bsd_to_linux_sigset(sigset_t *bss, linux_sigset_t *lss) { int b, l; LINUX_SIGEMPTYSET(*lss); lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1); lss->__bits[1] = bss->__bits[1]; for (b = 1; b <= LINUX_SIGTBLSZ; b++) { if (SIGISMEMBER(*bss, b)) { #if __alpha__ l = _SIG_IDX(b); #else l = bsd_to_linux_signal[_SIG_IDX(b)]; #endif if (l) LINUX_SIGADDSET(*lss, l); } } } static void linux_to_bsd_sigaction(linux_sigaction_t *lsa, struct sigaction *bsa) { linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask); bsa->sa_handler = lsa->lsa_handler; bsa->sa_flags = 0; if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP) bsa->sa_flags |= SA_NOCLDSTOP; if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT) bsa->sa_flags |= SA_NOCLDWAIT; if (lsa->lsa_flags & LINUX_SA_SIGINFO) bsa->sa_flags |= SA_SIGINFO; if (lsa->lsa_flags & LINUX_SA_ONSTACK) bsa->sa_flags |= SA_ONSTACK; if (lsa->lsa_flags & LINUX_SA_RESTART) bsa->sa_flags |= SA_RESTART; if (lsa->lsa_flags & LINUX_SA_ONESHOT) bsa->sa_flags |= SA_RESETHAND; if (lsa->lsa_flags & LINUX_SA_NOMASK) bsa->sa_flags |= SA_NODEFER; } static void bsd_to_linux_sigaction(struct sigaction *bsa, linux_sigaction_t *lsa) { bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask); lsa->lsa_handler = bsa->sa_handler; lsa->lsa_restorer = NULL; /* unsupported */ lsa->lsa_flags = 0; if (bsa->sa_flags & SA_NOCLDSTOP) lsa->lsa_flags |= LINUX_SA_NOCLDSTOP; if (bsa->sa_flags & SA_NOCLDWAIT) lsa->lsa_flags |= LINUX_SA_NOCLDWAIT; if (bsa->sa_flags & SA_SIGINFO) lsa->lsa_flags |= LINUX_SA_SIGINFO; if (bsa->sa_flags & SA_ONSTACK) lsa->lsa_flags |= LINUX_SA_ONSTACK; if (bsa->sa_flags & SA_RESTART) lsa->lsa_flags |= LINUX_SA_RESTART; if (bsa->sa_flags & SA_RESETHAND) lsa->lsa_flags |= LINUX_SA_ONESHOT; if (bsa->sa_flags & SA_NODEFER) lsa->lsa_flags |= LINUX_SA_NOMASK; } int linux_do_sigaction(struct proc *p, int linux_sig, linux_sigaction_t *linux_nsa, linux_sigaction_t *linux_osa) { struct sigaction *nsa, *osa; struct sigaction_args sa_args; int error; caddr_t sg = stackgap_init(); if (linux_sig <= 0 || linux_sig > LINUX_NSIG) return (EINVAL); if (linux_osa != NULL) osa = stackgap_alloc(&sg, sizeof(struct sigaction)); else osa = NULL; if (linux_nsa != NULL) { nsa = stackgap_alloc(&sg, sizeof(struct sigaction)); linux_to_bsd_sigaction(linux_nsa, nsa); } else nsa = NULL; #ifndef __alpha__ if (linux_sig <= LINUX_SIGTBLSZ) sa_args.sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)]; else #endif sa_args.sig = linux_sig; sa_args.act = nsa; sa_args.oact = osa; error = sigaction(p, &sa_args); if (error) return (error); if (linux_osa != NULL) bsd_to_linux_sigaction(osa, linux_osa); return (0); } #ifndef __alpha__ int linux_signal(struct proc *p, struct linux_signal_args *args) { linux_sigaction_t nsa, osa; int error; #ifdef DEBUG printf("Linux-emul(%ld): signal(%d, %p)\n", (long)p->p_pid, args->sig, (void *)args->handler); #endif nsa.lsa_handler = args->handler; nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK; LINUX_SIGEMPTYSET(nsa.lsa_mask); error = linux_do_sigaction(p, args->sig, &nsa, &osa); p->p_retval[0] = (int)osa.lsa_handler; return (error); } #endif /*!__alpha__*/ int linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args) { linux_sigaction_t nsa, osa; int error; #ifdef DEBUG printf("Linux-emul(%ld): rt_sigaction(%ld, %p, %p, %ld)\n", (long)p->p_pid, (long)args->sig, (void *)args->act, (void *)args->oact, (long)args->sigsetsize); #endif if (args->sigsetsize != sizeof(linux_sigset_t)) return (EINVAL); if (args->act != NULL) { error = copyin(args->act, &nsa, sizeof(linux_sigaction_t)); if (error) return (error); } error = linux_do_sigaction(p, args->sig, args->act ? &nsa : NULL, args->oact ? &osa : NULL); if (args->oact != NULL && !error) { error = copyout(&osa, args->oact, sizeof(linux_sigaction_t)); } return (error); } static int linux_do_sigprocmask(struct proc *p, int how, linux_sigset_t *new, linux_sigset_t *old) { int error, s; sigset_t mask; error = 0; p->p_retval[0] = 0; if (old != NULL) bsd_to_linux_sigset(&p->p_sigmask, old); if (new != NULL) { linux_to_bsd_sigset(new, &mask); s = splhigh(); switch (how) { case LINUX_SIG_BLOCK: SIGSETOR(p->p_sigmask, mask); SIG_CANTMASK(p->p_sigmask); break; case LINUX_SIG_UNBLOCK: SIGSETNAND(p->p_sigmask, mask); break; case LINUX_SIG_SETMASK: p->p_sigmask = mask; SIG_CANTMASK(p->p_sigmask); break; default: error = EINVAL; break; } splx(s); } return (error); } #ifndef __alpha__ int linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args) { linux_osigset_t mask; linux_sigset_t set, oset; int error; #ifdef DEBUG printf("Linux-emul(%d): sigprocmask(%d, *, *)\n", p->p_pid, args->how); #endif if (args->mask != NULL) { error = copyin(args->mask, &mask, sizeof(linux_osigset_t)); if (error) return (error); LINUX_SIGEMPTYSET(set); set.__bits[0] = mask; } error = linux_do_sigprocmask(p, args->how, args->mask ? &set : NULL, args->omask ? &oset : NULL); if (args->omask != NULL && !error) { mask = oset.__bits[0]; error = copyout(&mask, args->omask, sizeof(linux_osigset_t)); } return (error); } #endif /*!__alpha__*/ int linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args) { linux_sigset_t set, oset; int error; #ifdef DEBUG printf("Linux-emul(%ld): rt_sigprocmask(%d, %p, %p, %ld)\n", (long)p->p_pid, args->how, (void *)args->mask, (void *)args->omask, (long)args->sigsetsize); #endif if (args->sigsetsize != sizeof(linux_sigset_t)) return EINVAL; if (args->mask != NULL) { error = copyin(args->mask, &set, sizeof(linux_sigset_t)); if (error) return (error); } error = linux_do_sigprocmask(p, args->how, args->mask ? &set : NULL, args->omask ? &oset : NULL); if (args->omask != NULL && !error) { error = copyout(&oset, args->omask, sizeof(linux_sigset_t)); } return (error); } #ifndef __alpha__ int linux_siggetmask(struct proc *p, struct linux_siggetmask_args *args) { linux_sigset_t mask; #ifdef DEBUG printf("Linux-emul(%d): siggetmask()\n", p->p_pid); #endif bsd_to_linux_sigset(&p->p_sigmask, &mask); p->p_retval[0] = mask.__bits[0]; return (0); } int linux_sigsetmask(struct proc *p, struct linux_sigsetmask_args *args) { linux_sigset_t lset; sigset_t bset; int s; #ifdef DEBUG printf("Linux-emul(%ld): sigsetmask(%08lx)\n", (long)p->p_pid, (unsigned long)args->mask); #endif bsd_to_linux_sigset(&p->p_sigmask, &lset); p->p_retval[0] = lset.__bits[0]; LINUX_SIGEMPTYSET(lset); lset.__bits[0] = args->mask; linux_to_bsd_sigset(&lset, &bset); s = splhigh(); p->p_sigmask = bset; SIG_CANTMASK(p->p_sigmask); splx(s); return (0); } int linux_sigpending(struct proc *p, struct linux_sigpending_args *args) { sigset_t bset; linux_sigset_t lset; linux_osigset_t mask; #ifdef DEBUG printf("Linux-emul(%d): sigpending(*)\n", p->p_pid); #endif bset = p->p_siglist; SIGSETAND(bset, p->p_sigmask); bsd_to_linux_sigset(&bset, &lset); mask = lset.__bits[0]; return (copyout(&mask, args->mask, sizeof(mask))); } #endif /*!__alpha__*/ int linux_kill(struct proc *p, struct linux_kill_args *args) { struct kill_args /* { int pid; int signum; } */ tmp; #ifdef DEBUG printf("Linux-emul(%d): kill(%d, %d)\n", p->p_pid, args->pid, args->signum); #endif /* * Allow signal 0 as a means to check for privileges */ if (args->signum < 0 || args->signum > LINUX_NSIG) return EINVAL; #ifndef __alpha__ if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ) tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)]; else #endif tmp.signum = args->signum; tmp.pid = args->pid; return (kill(p, &tmp)); } Index: head/sys/compat/linux/linux_socket.c =================================================================== --- head/sys/compat/linux/linux_socket.c (revision 68518) +++ head/sys/compat/linux/linux_socket.c (revision 68519) @@ -1,910 +1,906 @@ /*- * Copyright (c) 1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ /* XXX we use functions that might not exist. */ #include "opt_compat.h" #ifndef COMPAT_43 #error "Unable to compile Linux-emulator due to missing COMPAT_43 option!" #endif #include #include #include #include #include #include #include #include #include #include #include -#ifdef __alpha__ #include -#else -#include -#endif #include #ifndef __alpha__ static int linux_to_bsd_domain(int domain) { switch (domain) { case LINUX_AF_UNSPEC: return (AF_UNSPEC); case LINUX_AF_UNIX: return (AF_LOCAL); case LINUX_AF_INET: return (AF_INET); case LINUX_AF_AX25: return (AF_CCITT); case LINUX_AF_IPX: return (AF_IPX); case LINUX_AF_APPLETALK: return (AF_APPLETALK); } return (-1); } static int linux_to_bsd_sockopt_level(int level) { switch (level) { case LINUX_SOL_SOCKET: return (SOL_SOCKET); } return (level); } static int linux_to_bsd_ip_sockopt(int opt) { switch (opt) { case LINUX_IP_TOS: return (IP_TOS); case LINUX_IP_TTL: return (IP_TTL); case LINUX_IP_OPTIONS: return (IP_OPTIONS); case LINUX_IP_MULTICAST_IF: return (IP_MULTICAST_IF); case LINUX_IP_MULTICAST_TTL: return (IP_MULTICAST_TTL); case LINUX_IP_MULTICAST_LOOP: return (IP_MULTICAST_LOOP); case LINUX_IP_ADD_MEMBERSHIP: return (IP_ADD_MEMBERSHIP); case LINUX_IP_DROP_MEMBERSHIP: return (IP_DROP_MEMBERSHIP); case LINUX_IP_HDRINCL: return (IP_HDRINCL); } return (-1); } static int linux_to_bsd_so_sockopt(int opt) { switch (opt) { case LINUX_SO_DEBUG: return (SO_DEBUG); case LINUX_SO_REUSEADDR: return (SO_REUSEADDR); case LINUX_SO_TYPE: return (SO_TYPE); case LINUX_SO_ERROR: return (SO_ERROR); case LINUX_SO_DONTROUTE: return (SO_DONTROUTE); case LINUX_SO_BROADCAST: return (SO_BROADCAST); case LINUX_SO_SNDBUF: return (SO_SNDBUF); case LINUX_SO_RCVBUF: return (SO_RCVBUF); case LINUX_SO_KEEPALIVE: return (SO_KEEPALIVE); case LINUX_SO_OOBINLINE: return (SO_OOBINLINE); case LINUX_SO_LINGER: return (SO_LINGER); } return (-1); } /* Return 0 if IP_HDRINCL is set for the given socket. */ static int linux_check_hdrincl(struct proc *p, int s) { struct getsockopt_args /* { int s; int level; int name; caddr_t val; int *avalsize; } */ bsd_args; int error; caddr_t sg, val, valsize; int size_val = sizeof val; int optval; sg = stackgap_init(); val = stackgap_alloc(&sg, sizeof(int)); valsize = stackgap_alloc(&sg, sizeof(int)); if ((error = copyout(&size_val, valsize, sizeof(size_val)))) return (error); bsd_args.s = s; bsd_args.level = IPPROTO_IP; bsd_args.name = IP_HDRINCL; bsd_args.val = val; bsd_args.avalsize = (int *)valsize; if ((error = getsockopt(p, &bsd_args))) return (error); if ((error = copyin(val, &optval, sizeof(optval)))) return (error); return (optval == 0); } /* * Updated sendto() when IP_HDRINCL is set: * tweak endian-dependent fields in the IP packet. */ static int linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args) { /* * linux_ip_copysize defines how many bytes we should copy * from the beginning of the IP packet before we customize it for BSD. * It should include all the fields we modify (ip_len and ip_off) * and be as small as possible to minimize copying overhead. */ #define linux_ip_copysize 8 caddr_t sg; struct ip *packet; struct msghdr *msg; struct iovec *iov; int error; struct sendmsg_args /* { int s; caddr_t msg; int flags; } */ sendmsg_args; /* Check the packet isn't too small before we mess with it */ if (bsd_args->len < linux_ip_copysize) return (EINVAL); /* * Tweaking the user buffer in place would be bad manners. * We create a corrected IP header with just the needed length, * then use an iovec to glue it to the rest of the user packet * when calling sendmsg(). */ sg = stackgap_init(); packet = (struct ip *)stackgap_alloc(&sg, linux_ip_copysize); msg = (struct msghdr *)stackgap_alloc(&sg, sizeof(*msg)); iov = (struct iovec *)stackgap_alloc(&sg, sizeof(*iov)*2); /* Make a copy of the beginning of the packet to be sent */ if ((error = copyin(bsd_args->buf, packet, linux_ip_copysize))) return (error); /* Convert fields from Linux to BSD raw IP socket format */ packet->ip_len = bsd_args->len; packet->ip_off = ntohs(packet->ip_off); /* Prepare the msghdr and iovec structures describing the new packet */ msg->msg_name = bsd_args->to; msg->msg_namelen = bsd_args->tolen; msg->msg_iov = iov; msg->msg_iovlen = 2; msg->msg_control = NULL; msg->msg_controllen = 0; msg->msg_flags = 0; iov[0].iov_base = (char *)packet; iov[0].iov_len = linux_ip_copysize; iov[1].iov_base = (char *)(bsd_args->buf) + linux_ip_copysize; iov[1].iov_len = bsd_args->len - linux_ip_copysize; sendmsg_args.s = bsd_args->s; sendmsg_args.msg = (caddr_t)msg; sendmsg_args.flags = bsd_args->flags; return (sendmsg(p, &sendmsg_args)); } struct linux_socket_args { int domain; int type; int protocol; }; static int linux_socket(struct proc *p, struct linux_socket_args *args) { struct linux_socket_args linux_args; struct socket_args /* { int domain; int type; int protocol; } */ bsd_args; int error; int retval_socket; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.protocol = linux_args.protocol; bsd_args.type = linux_args.type; bsd_args.domain = linux_to_bsd_domain(linux_args.domain); if (bsd_args.domain == -1) return (EINVAL); retval_socket = socket(p, &bsd_args); if (bsd_args.type == SOCK_RAW && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0) && bsd_args.domain == AF_INET && retval_socket >= 0) { /* It's a raw IP socket: set the IP_HDRINCL option. */ struct setsockopt_args /* { int s; int level; int name; caddr_t val; int valsize; } */ bsd_setsockopt_args; caddr_t sg; int *hdrincl; sg = stackgap_init(); hdrincl = (int *)stackgap_alloc(&sg, sizeof(*hdrincl)); *hdrincl = 1; bsd_setsockopt_args.s = p->p_retval[0]; bsd_setsockopt_args.level = IPPROTO_IP; bsd_setsockopt_args.name = IP_HDRINCL; bsd_setsockopt_args.val = (caddr_t)hdrincl; bsd_setsockopt_args.valsize = sizeof(*hdrincl); /* We ignore any error returned by setsockopt() */ setsockopt(p, &bsd_setsockopt_args); /* Copy back the return value from socket() */ p->p_retval[0] = bsd_setsockopt_args.s; } return (retval_socket); } struct linux_bind_args { int s; struct sockaddr *name; int namelen; }; static int linux_bind(struct proc *p, struct linux_bind_args *args) { struct linux_bind_args linux_args; struct bind_args /* { int s; caddr_t name; int namelen; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_args.namelen; return (bind(p, &bsd_args)); } struct linux_connect_args { int s; struct sockaddr * name; int namelen; }; static int linux_connect(struct proc *p, struct linux_connect_args *args) { struct linux_connect_args linux_args; struct connect_args /* { int s; caddr_t name; int namelen; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.name; bsd_args.namelen = linux_args.namelen; error = connect(p, &bsd_args); if (error == EISCONN) { /* * Linux doesn't return EISCONN the first time it occurs, * when on a non-blocking socket. Instead it returns the * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD. */ struct fcntl_args /* { int fd; int cmd; int arg; } */ bsd_fcntl_args; struct getsockopt_args /* { int s; int level; int name; caddr_t val; int *avalsize; } */ bsd_getsockopt_args; void *status, *statusl; int stat, statl = sizeof stat; caddr_t sg; /* Check for non-blocking */ bsd_fcntl_args.fd = linux_args.s; bsd_fcntl_args.cmd = F_GETFL; bsd_fcntl_args.arg = 0; error = fcntl(p, &bsd_fcntl_args); if (error == 0 && (p->p_retval[0] & O_NONBLOCK)) { sg = stackgap_init(); status = stackgap_alloc(&sg, sizeof stat); statusl = stackgap_alloc(&sg, sizeof statusl); if ((error = copyout(&statl, statusl, sizeof statl))) return (error); bsd_getsockopt_args.s = linux_args.s; bsd_getsockopt_args.level = SOL_SOCKET; bsd_getsockopt_args.name = SO_ERROR; bsd_getsockopt_args.val = status; bsd_getsockopt_args.avalsize = statusl; error = getsockopt(p, &bsd_getsockopt_args); if (error) return (error); if ((error = copyin(status, &stat, sizeof stat))) return (error); p->p_retval[0] = stat; return (0); } } return (error); } struct linux_listen_args { int s; int backlog; }; static int linux_listen(struct proc *p, struct linux_listen_args *args) { struct linux_listen_args linux_args; struct listen_args /* { int s; int backlog; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.backlog = linux_args.backlog; return (listen(p, &bsd_args)); } struct linux_accept_args { int s; struct sockaddr *addr; int *namelen; }; static int linux_accept(struct proc *p, struct linux_accept_args *args) { struct linux_accept_args linux_args; struct accept_args /* { int s; caddr_t name; int *anamelen; } */ bsd_args; struct fcntl_args /* { int fd; int cmd; long arg; } */ f_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.name = (caddr_t)linux_args.addr; bsd_args.anamelen = linux_args.namelen; error = oaccept(p, &bsd_args); if (error) return (error); /* * linux appears not to copy flags from the parent socket to the * accepted one, so we must clear the flags in the new descriptor. * Ignore any errors, because we already have an open fd. */ f_args.fd = p->p_retval[0]; f_args.cmd = F_SETFL; f_args.arg = 0; (void)fcntl(p, &f_args); p->p_retval[0] = f_args.fd; return (0); } struct linux_getsockname_args { int s; struct sockaddr *addr; int *namelen; }; static int linux_getsockname(struct proc *p, struct linux_getsockname_args *args) { struct linux_getsockname_args linux_args; struct getsockname_args /* { int fdes; caddr_t asa; int *alen; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; return (ogetsockname(p, &bsd_args)); } struct linux_getpeername_args { int s; struct sockaddr *addr; int *namelen; }; static int linux_getpeername(struct proc *p, struct linux_getpeername_args *args) { struct linux_getpeername_args linux_args; struct ogetpeername_args /* { int fdes; caddr_t asa; int *alen; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.fdes = linux_args.s; bsd_args.asa = (caddr_t) linux_args.addr; bsd_args.alen = linux_args.namelen; return (ogetpeername(p, &bsd_args)); } struct linux_socketpair_args { int domain; int type; int protocol; int *rsv; }; static int linux_socketpair(struct proc *p, struct linux_socketpair_args *args) { struct linux_socketpair_args linux_args; struct socketpair_args /* { int domain; int type; int protocol; int *rsv; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.domain = linux_to_bsd_domain(linux_args.domain); if (bsd_args.domain == -1) return (EINVAL); bsd_args.type = linux_args.type; bsd_args.protocol = linux_args.protocol; bsd_args.rsv = linux_args.rsv; return (socketpair(p, &bsd_args)); } struct linux_send_args { int s; void *msg; int len; int flags; }; static int linux_send(struct proc *p, struct linux_send_args *args) { struct linux_send_args linux_args; struct osend_args /* { int s; caddr_t buf; int len; int flags; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; return (osend(p, &bsd_args)); } struct linux_recv_args { int s; void *msg; int len; int flags; }; static int linux_recv(struct proc *p, struct linux_recv_args *args) { struct linux_recv_args linux_args; struct orecv_args /* { int s; caddr_t buf; int len; int flags; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; return (orecv(p, &bsd_args)); } struct linux_sendto_args { int s; void *msg; int len; int flags; caddr_t to; int tolen; }; static int linux_sendto(struct proc *p, struct linux_sendto_args *args) { struct linux_sendto_args linux_args; struct sendto_args /* { int s; caddr_t buf; size_t len; int flags; caddr_t to; int tolen; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.buf = linux_args.msg; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; bsd_args.to = linux_args.to; bsd_args.tolen = linux_args.tolen; if (linux_check_hdrincl(p, linux_args.s) == 0) /* IP_HDRINCL set, tweak the packet before sending */ return (linux_sendto_hdrincl(p, &bsd_args)); return (sendto(p, &bsd_args)); } struct linux_recvfrom_args { int s; void *buf; int len; int flags; caddr_t from; int *fromlen; }; static int linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args) { struct linux_recvfrom_args linux_args; struct recvfrom_args /* { int s; caddr_t buf; size_t len; int flags; caddr_t from; int *fromlenaddr; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.buf = linux_args.buf; bsd_args.len = linux_args.len; bsd_args.flags = linux_args.flags; bsd_args.from = linux_args.from; bsd_args.fromlenaddr = linux_args.fromlen; return (orecvfrom(p, &bsd_args)); } struct linux_shutdown_args { int s; int how; }; static int linux_shutdown(struct proc *p, struct linux_shutdown_args *args) { struct linux_shutdown_args linux_args; struct shutdown_args /* { int s; int how; } */ bsd_args; int error; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.how = linux_args.how; return (shutdown(p, &bsd_args)); } struct linux_setsockopt_args { int s; int level; int optname; void *optval; int optlen; }; static int linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args) { struct linux_setsockopt_args linux_args; struct setsockopt_args /* { int s; int level; int name; caddr_t val; int valsize; } */ bsd_args; int error, name; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.level = linux_to_bsd_sockopt_level(linux_args.level); switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(linux_args.optname); break; case IPPROTO_IP: name = linux_to_bsd_ip_sockopt(linux_args.optname); break; case IPPROTO_TCP: /* Linux TCP option values match BSD's */ name = linux_args.optname; break; default: name = -1; break; } if (name == -1) return (EINVAL); bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.valsize = linux_args.optlen; return (setsockopt(p, &bsd_args)); } struct linux_getsockopt_args { int s; int level; int optname; void *optval; int *optlen; }; static int linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args) { struct linux_getsockopt_args linux_args; struct getsockopt_args /* { int s; int level; int name; caddr_t val; int *avalsize; } */ bsd_args; int error, name; if ((error = copyin(args, &linux_args, sizeof(linux_args)))) return (error); bsd_args.s = linux_args.s; bsd_args.level = linux_to_bsd_sockopt_level(linux_args.level); switch (bsd_args.level) { case SOL_SOCKET: name = linux_to_bsd_so_sockopt(linux_args.optname); break; case IPPROTO_IP: name = linux_to_bsd_ip_sockopt(linux_args.optname); break; case IPPROTO_TCP: /* Linux TCP option values match BSD's */ name = linux_args.optname; break; default: name = -1; break; } if (name == -1) return (EINVAL); bsd_args.name = name; bsd_args.val = linux_args.optval; bsd_args.avalsize = linux_args.optlen; return (getsockopt(p, &bsd_args)); } int linux_socketcall(struct proc *p, struct linux_socketcall_args *args) { switch (args->what) { case LINUX_SOCKET: return (linux_socket(p, args->args)); case LINUX_BIND: return (linux_bind(p, args->args)); case LINUX_CONNECT: return (linux_connect(p, args->args)); case LINUX_LISTEN: return (linux_listen(p, args->args)); case LINUX_ACCEPT: return (linux_accept(p, args->args)); case LINUX_GETSOCKNAME: return (linux_getsockname(p, args->args)); case LINUX_GETPEERNAME: return (linux_getpeername(p, args->args)); case LINUX_SOCKETPAIR: return (linux_socketpair(p, args->args)); case LINUX_SEND: return (linux_send(p, args->args)); case LINUX_RECV: return (linux_recv(p, args->args)); case LINUX_SENDTO: return (linux_sendto(p, args->args)); case LINUX_RECVFROM: return (linux_recvfrom(p, args->args)); case LINUX_SHUTDOWN: return (linux_shutdown(p, args->args)); case LINUX_SETSOCKOPT: return (linux_setsockopt(p, args->args)); case LINUX_GETSOCKOPT: return (linux_getsockopt(p, args->args)); case LINUX_SENDMSG: do { int error; int level; caddr_t control; struct { int s; const struct msghdr *msg; int flags; } *uap = args->args; error = copyin(&uap->msg->msg_control, &control, sizeof(caddr_t)); if (error) return (error); if (control == NULL) goto done; error = copyin(&((struct cmsghdr*)control)->cmsg_level, &level, sizeof(int)); if (error) return (error); if (level == 1) { /* * Linux thinks that SOL_SOCKET is 1; we know * that it's really 0xffff, of course. */ level = SOL_SOCKET; error = copyout(&level, &((struct cmsghdr *)control)->cmsg_level, sizeof(int)); if (error) return (error); } done: return (sendmsg(p, args->args)); } while (0); case LINUX_RECVMSG: return (recvmsg(p, args->args)); } uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what); return (ENOSYS); } #endif /*!__alpha__*/ Index: head/sys/compat/linux/linux_stats.c =================================================================== --- head/sys/compat/linux/linux_stats.c (revision 68518) +++ head/sys/compat/linux/linux_stats.c (revision 68519) @@ -1,400 +1,396 @@ /*- * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include -#ifdef __alpha__ #include -#else -#include -#endif #include struct linux_newstat { #ifdef __alpha__ u_int stat_dev; u_int stat_ino; u_int stat_mode; u_int stat_nlink; u_int stat_uid; u_int stat_gid; u_int stat_rdev; long stat_size; u_long stat_atime; u_long stat_mtime; u_long stat_ctime; u_int stat_blksize; int stat_blocks; u_int stat_flags; u_int stat_gen; #else u_short stat_dev; u_short __pad1; u_long stat_ino; u_short stat_mode; u_short stat_nlink; u_short stat_uid; u_short stat_gid; u_short stat_rdev; u_short __pad2; u_long stat_size; u_long stat_blksize; u_long stat_blocks; u_long stat_atime; u_long __unused1; u_long stat_mtime; u_long __unused2; u_long stat_ctime; u_long __unused3; u_long __unused4; u_long __unused5; #endif }; struct linux_ustat { int f_tfree; u_long f_tinode; char f_fname[6]; char f_fpack[6]; }; static int newstat_copyout(struct stat *buf, void *ubuf) { struct linux_newstat tbuf; tbuf.stat_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8); tbuf.stat_ino = buf->st_ino; tbuf.stat_mode = buf->st_mode; tbuf.stat_nlink = buf->st_nlink; tbuf.stat_uid = buf->st_uid; tbuf.stat_gid = buf->st_gid; tbuf.stat_rdev = buf->st_rdev; tbuf.stat_size = buf->st_size; tbuf.stat_atime = buf->st_atime; tbuf.stat_mtime = buf->st_mtime; tbuf.stat_ctime = buf->st_ctime; tbuf.stat_blksize = buf->st_blksize; tbuf.stat_blocks = buf->st_blocks; return (copyout(&tbuf, ubuf, sizeof(tbuf))); } int linux_newstat(struct proc *p, struct linux_newstat_args *args) { struct stat buf; struct nameidata nd; int error; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%ld): newstat(%s, *)\n", (long)p->p_pid, args->path); #endif NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, args->path, p); error = namei(&nd); if (error) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); error = vn_stat(nd.ni_vp, &buf, p); vput(nd.ni_vp); if (error) return (error); return (newstat_copyout(&buf, args->buf)); } /* * Get file status; this version does not follow links. */ int linux_newlstat(p, uap) struct proc *p; struct linux_newlstat_args *uap; { int error; struct vnode *vp; struct stat sb; struct nameidata nd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, uap->path); #ifdef DEBUG printf("Linux-emul(%ld): newlstat(%s, *)\n", (long)p->p_pid, uap->path); #endif NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE, uap->path, p); error = namei(&nd); if (error) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; error = vn_stat(vp, &sb, p); vput(vp); if (error) return (error); return (newstat_copyout(&sb, uap->buf)); } int linux_newfstat(struct proc *p, struct linux_newfstat_args *args) { struct filedesc *fdp; struct file *fp; struct stat buf; int error; fdp = p->p_fd; #ifdef DEBUG printf("Linux-emul(%ld): newfstat(%d, *)\n", (long)p->p_pid, args->fd); #endif if ((unsigned)args->fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[args->fd]) == NULL) return (EBADF); error = fo_stat(fp, &buf, p); if (!error) error = newstat_copyout(&buf, args->buf); return (error); } struct linux_statfs_buf { int ftype; int fbsize; int fblocks; int fbfree; int fbavail; int ffiles; int fffree; linux_fsid_t ffsid; int fnamelen; int fspare[6]; }; #ifndef VT_NWFS #define VT_NWFS VT_TFS /* XXX - bug compatibility with sys/nwfs/nwfs_node.h */ #endif #define LINUX_CODA_SUPER_MAGIC 0x73757245L #define LINUX_EXT2_SUPER_MAGIC 0xEF53L #define LINUX_HPFS_SUPER_MAGIC 0xf995e849L #define LINUX_ISOFS_SUPER_MAGIC 0x9660L #define LINUX_MSDOS_SUPER_MAGIC 0x4d44L #define LINUX_NCP_SUPER_MAGIC 0x564cL #define LINUX_NFS_SUPER_MAGIC 0x6969L #define LINUX_NTFS_SUPER_MAGIC 0x5346544EL #define LINUX_PROC_SUPER_MAGIC 0x9fa0L #define LINUX_UFS_SUPER_MAGIC 0x00011954L /* XXX - UFS_MAGIC in Linux */ /* * ext2fs uses the VT_UFS tag. A mounted ext2 filesystem will therefore * be seen as an ufs/mfs filesystem. */ static long bsd_to_linux_ftype(int tag) { switch (tag) { case VT_CODA: return (LINUX_CODA_SUPER_MAGIC); case VT_HPFS: return (LINUX_HPFS_SUPER_MAGIC); case VT_ISOFS: return (LINUX_ISOFS_SUPER_MAGIC); case VT_MFS: return (LINUX_UFS_SUPER_MAGIC); case VT_MSDOSFS: return (LINUX_MSDOS_SUPER_MAGIC); case VT_NFS: return (LINUX_NFS_SUPER_MAGIC); case VT_NTFS: return (LINUX_NTFS_SUPER_MAGIC); case VT_NWFS: return (LINUX_NCP_SUPER_MAGIC); case VT_PROCFS: return (LINUX_PROC_SUPER_MAGIC); case VT_UFS: return (LINUX_UFS_SUPER_MAGIC); } return (0L); } int linux_statfs(struct proc *p, struct linux_statfs_args *args) { struct mount *mp; struct nameidata *ndp; struct statfs *bsd_statfs; struct nameidata nd; struct linux_statfs_buf linux_statfs_buf; int error; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): statfs(%s, *)\n", p->p_pid, args->path); #endif ndp = &nd; NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curproc); error = namei(ndp); if (error) return error; NDFREE(ndp, NDF_ONLY_PNBUF); mp = ndp->ni_vp->v_mount; bsd_statfs = &mp->mnt_stat; vrele(ndp->ni_vp); error = VFS_STATFS(mp, bsd_statfs, p); if (error) return error; bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; linux_statfs_buf.ftype = bsd_to_linux_ftype(bsd_statfs->f_type); linux_statfs_buf.fbsize = bsd_statfs->f_bsize; linux_statfs_buf.fblocks = bsd_statfs->f_blocks; linux_statfs_buf.fbfree = bsd_statfs->f_bfree; linux_statfs_buf.fbavail = bsd_statfs->f_bavail; linux_statfs_buf.fffree = bsd_statfs->f_ffree; linux_statfs_buf.ffiles = bsd_statfs->f_files; linux_statfs_buf.ffsid.val[0] = bsd_statfs->f_fsid.val[0]; linux_statfs_buf.ffsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs_buf.fnamelen = MAXNAMLEN; return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf, sizeof(struct linux_statfs_buf)); } int linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args) { struct file *fp; struct mount *mp; struct statfs *bsd_statfs; struct linux_statfs_buf linux_statfs_buf; int error; #ifdef DEBUG printf("Linux-emul(%d): fstatfs(%d, *)\n", p->p_pid, args->fd); #endif error = getvnode(p->p_fd, args->fd, &fp); if (error) return error; mp = ((struct vnode *)fp->f_data)->v_mount; bsd_statfs = &mp->mnt_stat; error = VFS_STATFS(mp, bsd_statfs, p); if (error) return error; bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; linux_statfs_buf.ftype = bsd_to_linux_ftype(bsd_statfs->f_type); linux_statfs_buf.fbsize = bsd_statfs->f_bsize; linux_statfs_buf.fblocks = bsd_statfs->f_blocks; linux_statfs_buf.fbfree = bsd_statfs->f_bfree; linux_statfs_buf.fbavail = bsd_statfs->f_bavail; linux_statfs_buf.fffree = bsd_statfs->f_ffree; linux_statfs_buf.ffiles = bsd_statfs->f_files; linux_statfs_buf.ffsid.val[0] = bsd_statfs->f_fsid.val[0]; linux_statfs_buf.ffsid.val[1] = bsd_statfs->f_fsid.val[1]; linux_statfs_buf.fnamelen = MAXNAMLEN; return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf, sizeof(struct linux_statfs_buf)); } int linux_ustat(p, uap) struct proc *p; struct linux_ustat_args *uap; { struct linux_ustat lu; dev_t dev; struct vnode *vp; struct statfs *stat; int error; #ifdef DEBUG printf("Linux-emul(%ld): ustat(%d, *)\n", (long)p->p_pid, uap->dev); #endif /* * lu.f_fname and lu.f_fpack are not used. They are always zeroed. * lu.f_tinode and lu.f_tfree are set from the device's super block. */ bzero(&lu, sizeof(lu)); /* * XXX - Don't return an error if we can't find a vnode for the * device. Our dev_t is 32-bits whereas Linux only has a 16-bits * dev_t. The dev_t that is used now may as well be a truncated * dev_t returned from previous syscalls. Just return a bzeroed * ustat in that case. */ dev = makedev(uap->dev >> 8, uap->dev & 0xFF); if (vfinddev(dev, VCHR, &vp)) { if (vp->v_mount == NULL) return (EINVAL); stat = &(vp->v_mount->mnt_stat); error = VFS_STATFS(vp->v_mount, stat, p); if (error) return (error); lu.f_tfree = stat->f_bfree; lu.f_tinode = stat->f_ffree; } return (copyout(&lu, uap->ubuf, sizeof(lu))); } Index: head/sys/i386/linux/linux_proto.h =================================================================== --- head/sys/i386/linux/linux_proto.h (revision 68518) +++ head/sys/i386/linux/linux_proto.h (nonexistent) @@ -1,694 +0,0 @@ -/* - * System call prototypes. - * - * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.35 2000/10/17 00:00:20 gallatin Exp - */ - -#ifndef _LINUX_SYSPROTO_H_ -#define _LINUX_SYSPROTO_H_ - -#include - -#include - -struct proc; - -#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \ - 0 : sizeof(register_t) - sizeof(t)) - -struct linux_setup_args { - register_t dummy; -}; -struct linux_fork_args { - register_t dummy; -}; -struct linux_open_args { - char * path; char path_[PAD_(char *)]; - int flags; char flags_[PAD_(int)]; - int mode; char mode_[PAD_(int)]; -}; -struct linux_waitpid_args { - int pid; char pid_[PAD_(int)]; - int * status; char status_[PAD_(int *)]; - int options; char options_[PAD_(int)]; -}; -struct linux_creat_args { - char * path; char path_[PAD_(char *)]; - int mode; char mode_[PAD_(int)]; -}; -struct linux_link_args { - char * path; char path_[PAD_(char *)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_unlink_args { - char * path; char path_[PAD_(char *)]; -}; -struct linux_execve_args { - char * path; char path_[PAD_(char *)]; - char ** argp; char argp_[PAD_(char **)]; - char ** envp; char envp_[PAD_(char **)]; -}; -struct linux_chdir_args { - char * path; char path_[PAD_(char *)]; -}; -struct linux_time_args { - linux_time_t * tm; char tm_[PAD_(linux_time_t *)]; -}; -struct linux_mknod_args { - char * path; char path_[PAD_(char *)]; - int mode; char mode_[PAD_(int)]; - int dev; char dev_[PAD_(int)]; -}; -struct linux_chmod_args { - char * path; char path_[PAD_(char *)]; - int mode; char mode_[PAD_(int)]; -}; -struct linux_lchown_args { - char * path; char path_[PAD_(char *)]; - int uid; char uid_[PAD_(int)]; - int gid; char gid_[PAD_(int)]; -}; -struct linux_break_args { - char * nsize; char nsize_[PAD_(char *)]; -}; -struct linux_stat_args { - char * path; char path_[PAD_(char *)]; - struct ostat * up; char up_[PAD_(struct ostat *)]; -}; -struct linux_lseek_args { - int fdes; char fdes_[PAD_(int)]; - long off; char off_[PAD_(long)]; - int whence; char whence_[PAD_(int)]; -}; -struct linux_mount_args { - register_t dummy; -}; -struct linux_umount_args { - register_t dummy; -}; -struct linux_stime_args { - register_t dummy; -}; -struct linux_ptrace_args { - register_t dummy; -}; -struct linux_alarm_args { - unsigned int secs; char secs_[PAD_(unsigned int)]; -}; -struct linux_fstat_args { - int fd; char fd_[PAD_(int)]; - struct ostat * up; char up_[PAD_(struct ostat *)]; -}; -struct linux_pause_args { - register_t dummy; -}; -struct linux_utime_args { - char * fname; char fname_[PAD_(char *)]; - struct linux_utimbuf * times; char times_[PAD_(struct linux_utimbuf *)]; -}; -struct linux_stty_args { - register_t dummy; -}; -struct linux_gtty_args { - register_t dummy; -}; -struct linux_access_args { - char * path; char path_[PAD_(char *)]; - int flags; char flags_[PAD_(int)]; -}; -struct linux_nice_args { - int inc; char inc_[PAD_(int)]; -}; -struct linux_ftime_args { - register_t dummy; -}; -struct linux_kill_args { - int pid; char pid_[PAD_(int)]; - int signum; char signum_[PAD_(int)]; -}; -struct linux_rename_args { - char * from; char from_[PAD_(char *)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_mkdir_args { - char * path; char path_[PAD_(char *)]; - int mode; char mode_[PAD_(int)]; -}; -struct linux_rmdir_args { - char * path; char path_[PAD_(char *)]; -}; -struct linux_pipe_args { - int * pipefds; char pipefds_[PAD_(int *)]; -}; -struct linux_times_args { - struct linux_times_argv * buf; char buf_[PAD_(struct linux_times_argv *)]; -}; -struct linux_prof_args { - register_t dummy; -}; -struct linux_brk_args { - char * dsend; char dsend_[PAD_(char *)]; -}; -struct linux_signal_args { - int sig; char sig_[PAD_(int)]; - linux_handler_t handler; char handler_[PAD_(linux_handler_t)]; -}; -struct linux_umount2_args { - register_t dummy; -}; -struct linux_lock_args { - register_t dummy; -}; -struct linux_ioctl_args { - int fd; char fd_[PAD_(int)]; - u_long cmd; char cmd_[PAD_(u_long)]; - int arg; char arg_[PAD_(int)]; -}; -struct linux_fcntl_args { - int fd; char fd_[PAD_(int)]; - int cmd; char cmd_[PAD_(int)]; - int arg; char arg_[PAD_(int)]; -}; -struct linux_mpx_args { - register_t dummy; -}; -struct linux_ulimit_args { - register_t dummy; -}; -struct linux_olduname_args { - register_t dummy; -}; -struct linux_ustat_args { - linux_dev_t dev; char dev_[PAD_(linux_dev_t)]; - struct linux_ustat * ubuf; char ubuf_[PAD_(struct linux_ustat *)]; -}; -struct linux_sigaction_args { - int sig; char sig_[PAD_(int)]; - linux_osigaction_t * nsa; char nsa_[PAD_(linux_osigaction_t *)]; - linux_osigaction_t * osa; char osa_[PAD_(linux_osigaction_t *)]; -}; -struct linux_siggetmask_args { - register_t dummy; -}; -struct linux_sigsetmask_args { - linux_osigset_t mask; char mask_[PAD_(linux_osigset_t)]; -}; -struct linux_sigsuspend_args { - int restart; char restart_[PAD_(int)]; - linux_osigset_t oldmask; char oldmask_[PAD_(linux_osigset_t)]; - linux_osigset_t mask; char mask_[PAD_(linux_osigset_t)]; -}; -struct linux_sigpending_args { - linux_osigset_t * mask; char mask_[PAD_(linux_osigset_t *)]; -}; -struct linux_setrlimit_args { - u_int resource; char resource_[PAD_(u_int)]; - struct ogetrlimit * rlim; char rlim_[PAD_(struct ogetrlimit *)]; -}; -struct linux_getrlimit_args { - u_int resource; char resource_[PAD_(u_int)]; - struct ogetrlimit * rlim; char rlim_[PAD_(struct ogetrlimit *)]; -}; -struct linux_getgroups_args { - u_int gidsetsize; char gidsetsize_[PAD_(u_int)]; - linux_gid_t * gidset; char gidset_[PAD_(linux_gid_t *)]; -}; -struct linux_setgroups_args { - u_int gidsetsize; char gidsetsize_[PAD_(u_int)]; - linux_gid_t * gidset; char gidset_[PAD_(linux_gid_t *)]; -}; -struct linux_select_args { - struct linux_select_argv * ptr; char ptr_[PAD_(struct linux_select_argv *)]; -}; -struct linux_symlink_args { - char * path; char path_[PAD_(char *)]; - char * to; char to_[PAD_(char *)]; -}; -struct linux_readlink_args { - char * name; char name_[PAD_(char *)]; - char * buf; char buf_[PAD_(char *)]; - int count; char count_[PAD_(int)]; -}; -struct linux_uselib_args { - char * library; char library_[PAD_(char *)]; -}; -struct linux_readdir_args { - int fd; char fd_[PAD_(int)]; - struct linux_dirent * dent; char dent_[PAD_(struct linux_dirent *)]; - unsigned int count; char count_[PAD_(unsigned int)]; -}; -struct linux_mmap_args { - struct linux_mmap_argv * ptr; char ptr_[PAD_(struct linux_mmap_argv *)]; -}; -struct linux_truncate_args { - char * path; char path_[PAD_(char *)]; - long length; char length_[PAD_(long)]; -}; -struct linux_statfs_args { - char * path; char path_[PAD_(char *)]; - struct linux_statfs_buf * buf; char buf_[PAD_(struct linux_statfs_buf *)]; -}; -struct linux_fstatfs_args { - int fd; char fd_[PAD_(int)]; - struct linux_statfs_buf * buf; char buf_[PAD_(struct linux_statfs_buf *)]; -}; -struct linux_ioperm_args { - unsigned int start; char start_[PAD_(unsigned int)]; - unsigned int length; char length_[PAD_(unsigned int)]; - int enable; char enable_[PAD_(int)]; -}; -struct linux_socketcall_args { - int what; char what_[PAD_(int)]; - void * args; char args_[PAD_(void *)]; -}; -struct linux_ksyslog_args { - int what; char what_[PAD_(int)]; -}; -struct linux_setitimer_args { - u_int which; char which_[PAD_(u_int)]; - struct itimerval * itv; char itv_[PAD_(struct itimerval *)]; - struct itimerval * oitv; char oitv_[PAD_(struct itimerval *)]; -}; -struct linux_getitimer_args { - u_int which; char which_[PAD_(u_int)]; - struct itimerval * itv; char itv_[PAD_(struct itimerval *)]; -}; -struct linux_newstat_args { - char * path; char path_[PAD_(char *)]; - struct linux_newstat * buf; char buf_[PAD_(struct linux_newstat *)]; -}; -struct linux_newlstat_args { - char * path; char path_[PAD_(char *)]; - struct linux_newstat * buf; char buf_[PAD_(struct linux_newstat *)]; -}; -struct linux_newfstat_args { - int fd; char fd_[PAD_(int)]; - struct linux_newstat * buf; char buf_[PAD_(struct linux_newstat *)]; -}; -struct linux_uname_args { - register_t dummy; -}; -struct linux_iopl_args { - int level; char level_[PAD_(int)]; -}; -struct linux_vhangup_args { - register_t dummy; -}; -struct linux_idle_args { - register_t dummy; -}; -struct linux_vm86old_args { - register_t dummy; -}; -struct linux_wait4_args { - int pid; char pid_[PAD_(int)]; - int * status; char status_[PAD_(int *)]; - int options; char options_[PAD_(int)]; - struct rusage * rusage; char rusage_[PAD_(struct rusage *)]; -}; -struct linux_swapoff_args { - register_t dummy; -}; -struct linux_sysinfo_args { - register_t dummy; -}; -struct linux_ipc_args { - int what; char what_[PAD_(int)]; - int arg1; char arg1_[PAD_(int)]; - int arg2; char arg2_[PAD_(int)]; - int arg3; char arg3_[PAD_(int)]; - caddr_t ptr; char ptr_[PAD_(caddr_t)]; -}; -struct linux_sigreturn_args { - struct linux_sigcontext * scp; char scp_[PAD_(struct linux_sigcontext *)]; -}; -struct linux_clone_args { - int flags; char flags_[PAD_(int)]; - void * stack; char stack_[PAD_(void *)]; -}; -struct linux_newuname_args { - struct linux_new_utsname * buf; char buf_[PAD_(struct linux_new_utsname *)]; -}; -struct linux_modify_ldt_args { - int func; char func_[PAD_(int)]; - void * ptr; char ptr_[PAD_(void *)]; - size_t bytecount; char bytecount_[PAD_(size_t)]; -}; -struct linux_adjtimex_args { - register_t dummy; -}; -struct linux_sigprocmask_args { - int how; char how_[PAD_(int)]; - linux_osigset_t * mask; char mask_[PAD_(linux_osigset_t *)]; - linux_osigset_t * omask; char omask_[PAD_(linux_osigset_t *)]; -}; -struct linux_create_module_args { - register_t dummy; -}; -struct linux_init_module_args { - register_t dummy; -}; -struct linux_delete_module_args { - register_t dummy; -}; -struct linux_get_kernel_syms_args { - register_t dummy; -}; -struct linux_quotactl_args { - register_t dummy; -}; -struct linux_getpgid_args { - int pid; char pid_[PAD_(int)]; -}; -struct linux_bdflush_args { - register_t dummy; -}; -struct linux_sysfs_args { - int option; char option_[PAD_(int)]; - u_long arg1; char arg1_[PAD_(u_long)]; - u_long arg2; char arg2_[PAD_(u_long)]; -}; -struct linux_personality_args { - int per; char per_[PAD_(int)]; -}; -struct linux_afs_syscall_args { - register_t dummy; -}; -struct linux_setfsuid_args { - linux_uid_t uid; char uid_[PAD_(linux_uid_t)]; -}; -struct linux_setfsgid_args { - linux_gid_t gid; char gid_[PAD_(linux_gid_t)]; -}; -struct linux_llseek_args { - int fd; char fd_[PAD_(int)]; - u_int32_t ohigh; char ohigh_[PAD_(u_int32_t)]; - u_int32_t olow; char olow_[PAD_(u_int32_t)]; - caddr_t res; char res_[PAD_(caddr_t)]; - int whence; char whence_[PAD_(int)]; -}; -struct linux_getdents_args { - int fd; char fd_[PAD_(int)]; - void * dent; char dent_[PAD_(void *)]; - unsigned count; char count_[PAD_(unsigned)]; -}; -struct linux_newselect_args { - int nfds; char nfds_[PAD_(int)]; - fd_set * readfds; char readfds_[PAD_(fd_set *)]; - fd_set * writefds; char writefds_[PAD_(fd_set *)]; - fd_set * exceptfds; char exceptfds_[PAD_(fd_set *)]; - struct timeval * timeout; char timeout_[PAD_(struct timeval *)]; -}; -struct linux_msync_args { - caddr_t addr; char addr_[PAD_(caddr_t)]; - int len; char len_[PAD_(int)]; - int fl; char fl_[PAD_(int)]; -}; -struct linux_getsid_args { - linux_pid_t pid; char pid_[PAD_(linux_pid_t)]; -}; -struct linux_fdatasync_args { - int fd; char fd_[PAD_(int)]; -}; -struct linux_sysctl_args { - register_t dummy; -}; -struct linux_sched_setscheduler_args { - pid_t pid; char pid_[PAD_(pid_t)]; - int policy; char policy_[PAD_(int)]; - const struct sched_param * param; char param_[PAD_(const struct sched_param *)]; -}; -struct linux_sched_getscheduler_args { - pid_t pid; char pid_[PAD_(pid_t)]; -}; -struct linux_mremap_args { - caddr_t addr; char addr_[PAD_(caddr_t)]; - int old_len; char old_len_[PAD_(int)]; - int new_len; char new_len_[PAD_(int)]; - int flags; char flags_[PAD_(int)]; -}; -struct linux_getresuid_args { - linux_uid_t * ruid; char ruid_[PAD_(linux_uid_t *)]; - linux_uid_t * euid; char euid_[PAD_(linux_uid_t *)]; - linux_uid_t * suid; char suid_[PAD_(linux_uid_t *)]; -}; -struct linux_vm86_args { - register_t dummy; -}; -struct linux_query_module_args { - register_t dummy; -}; -struct linux_nfsservctl_args { - register_t dummy; -}; -struct linux_getresgid_args { - linux_gid_t * rgid; char rgid_[PAD_(linux_gid_t *)]; - linux_gid_t * egid; char egid_[PAD_(linux_gid_t *)]; - linux_gid_t * sgid; char sgid_[PAD_(linux_gid_t *)]; -}; -struct linux_prctl_args { - register_t dummy; -}; -struct linux_rt_sigreturn_args { - struct linux_ucontext * ucp; char ucp_[PAD_(struct linux_ucontext *)]; -}; -struct linux_rt_sigaction_args { - int sig; char sig_[PAD_(int)]; - linux_sigaction_t * act; char act_[PAD_(linux_sigaction_t *)]; - linux_sigaction_t * oact; char oact_[PAD_(linux_sigaction_t *)]; - size_t sigsetsize; char sigsetsize_[PAD_(size_t)]; -}; -struct linux_rt_sigprocmask_args { - int how; char how_[PAD_(int)]; - linux_sigset_t * mask; char mask_[PAD_(linux_sigset_t *)]; - linux_sigset_t * omask; char omask_[PAD_(linux_sigset_t *)]; - size_t sigsetsize; char sigsetsize_[PAD_(size_t)]; -}; -struct linux_rt_sigpending_args { - register_t dummy; -}; -struct linux_rt_sigtimedwait_args { - register_t dummy; -}; -struct linux_rt_sigqueueinfo_args { - register_t dummy; -}; -struct linux_rt_sigsuspend_args { - linux_sigset_t * newset; char newset_[PAD_(linux_sigset_t *)]; - size_t sigsetsize; char sigsetsize_[PAD_(size_t)]; -}; -struct linux_pread_args { - int fd; char fd_[PAD_(int)]; - char * buf; char buf_[PAD_(char *)]; - size_t nbyte; char nbyte_[PAD_(size_t)]; - off_t offset; char offset_[PAD_(off_t)]; -}; -struct linux_pwrite_args { - int fd; char fd_[PAD_(int)]; - const char * buf; char buf_[PAD_(const char *)]; - size_t nbyte; char nbyte_[PAD_(size_t)]; - off_t offset; char offset_[PAD_(off_t)]; -}; -struct linux_chown_args { - char * path; char path_[PAD_(char *)]; - int uid; char uid_[PAD_(int)]; - int gid; char gid_[PAD_(int)]; -}; -struct linux_getcwd_args { - char * buf; char buf_[PAD_(char *)]; - unsigned long bufsize; char bufsize_[PAD_(unsigned long)]; -}; -struct linux_capget_args { - register_t dummy; -}; -struct linux_capset_args { - register_t dummy; -}; -struct linux_sigaltstack_args { - const linux_stack_t * uss; char uss_[PAD_(const linux_stack_t *)]; - linux_stack_t * uoss; char uoss_[PAD_(linux_stack_t *)]; -}; -struct linux_sendfile_args { - register_t dummy; -}; -struct linux_getpmsg_args { - register_t dummy; -}; -struct linux_putpmsg_args { - register_t dummy; -}; -struct linux_vfork_args { - register_t dummy; -}; -struct linux_ugetrlimit_args { - register_t dummy; -}; -struct linux_mmap2_args { - register_t dummy; -}; -struct linux_truncate64_args { - register_t dummy; -}; -struct linux_ftruncate64_args { - register_t dummy; -}; -struct linux_stat64_args { - register_t dummy; -}; -struct linux_lstat64_args { - register_t dummy; -}; -struct linux_fstat64_args { - register_t dummy; -}; -int linux_setup __P((struct proc *, struct linux_setup_args *)); -int linux_fork __P((struct proc *, struct linux_fork_args *)); -int linux_open __P((struct proc *, struct linux_open_args *)); -int linux_waitpid __P((struct proc *, struct linux_waitpid_args *)); -int linux_creat __P((struct proc *, struct linux_creat_args *)); -int linux_link __P((struct proc *, struct linux_link_args *)); -int linux_unlink __P((struct proc *, struct linux_unlink_args *)); -int linux_execve __P((struct proc *, struct linux_execve_args *)); -int linux_chdir __P((struct proc *, struct linux_chdir_args *)); -int linux_time __P((struct proc *, struct linux_time_args *)); -int linux_mknod __P((struct proc *, struct linux_mknod_args *)); -int linux_chmod __P((struct proc *, struct linux_chmod_args *)); -int linux_lchown __P((struct proc *, struct linux_lchown_args *)); -int linux_break __P((struct proc *, struct linux_break_args *)); -int linux_stat __P((struct proc *, struct linux_stat_args *)); -int linux_lseek __P((struct proc *, struct linux_lseek_args *)); -int linux_mount __P((struct proc *, struct linux_mount_args *)); -int linux_umount __P((struct proc *, struct linux_umount_args *)); -int linux_stime __P((struct proc *, struct linux_stime_args *)); -int linux_ptrace __P((struct proc *, struct linux_ptrace_args *)); -int linux_alarm __P((struct proc *, struct linux_alarm_args *)); -int linux_fstat __P((struct proc *, struct linux_fstat_args *)); -int linux_pause __P((struct proc *, struct linux_pause_args *)); -int linux_utime __P((struct proc *, struct linux_utime_args *)); -int linux_stty __P((struct proc *, struct linux_stty_args *)); -int linux_gtty __P((struct proc *, struct linux_gtty_args *)); -int linux_access __P((struct proc *, struct linux_access_args *)); -int linux_nice __P((struct proc *, struct linux_nice_args *)); -int linux_ftime __P((struct proc *, struct linux_ftime_args *)); -int linux_kill __P((struct proc *, struct linux_kill_args *)); -int linux_rename __P((struct proc *, struct linux_rename_args *)); -int linux_mkdir __P((struct proc *, struct linux_mkdir_args *)); -int linux_rmdir __P((struct proc *, struct linux_rmdir_args *)); -int linux_pipe __P((struct proc *, struct linux_pipe_args *)); -int linux_times __P((struct proc *, struct linux_times_args *)); -int linux_prof __P((struct proc *, struct linux_prof_args *)); -int linux_brk __P((struct proc *, struct linux_brk_args *)); -int linux_signal __P((struct proc *, struct linux_signal_args *)); -int linux_umount2 __P((struct proc *, struct linux_umount2_args *)); -int linux_lock __P((struct proc *, struct linux_lock_args *)); -int linux_ioctl __P((struct proc *, struct linux_ioctl_args *)); -int linux_fcntl __P((struct proc *, struct linux_fcntl_args *)); -int linux_mpx __P((struct proc *, struct linux_mpx_args *)); -int linux_ulimit __P((struct proc *, struct linux_ulimit_args *)); -int linux_olduname __P((struct proc *, struct linux_olduname_args *)); -int linux_ustat __P((struct proc *, struct linux_ustat_args *)); -int linux_sigaction __P((struct proc *, struct linux_sigaction_args *)); -int linux_siggetmask __P((struct proc *, struct linux_siggetmask_args *)); -int linux_sigsetmask __P((struct proc *, struct linux_sigsetmask_args *)); -int linux_sigsuspend __P((struct proc *, struct linux_sigsuspend_args *)); -int linux_sigpending __P((struct proc *, struct linux_sigpending_args *)); -int linux_setrlimit __P((struct proc *, struct linux_setrlimit_args *)); -int linux_getrlimit __P((struct proc *, struct linux_getrlimit_args *)); -int linux_getgroups __P((struct proc *, struct linux_getgroups_args *)); -int linux_setgroups __P((struct proc *, struct linux_setgroups_args *)); -int linux_select __P((struct proc *, struct linux_select_args *)); -int linux_symlink __P((struct proc *, struct linux_symlink_args *)); -int linux_readlink __P((struct proc *, struct linux_readlink_args *)); -int linux_uselib __P((struct proc *, struct linux_uselib_args *)); -int linux_readdir __P((struct proc *, struct linux_readdir_args *)); -int linux_mmap __P((struct proc *, struct linux_mmap_args *)); -int linux_truncate __P((struct proc *, struct linux_truncate_args *)); -int linux_statfs __P((struct proc *, struct linux_statfs_args *)); -int linux_fstatfs __P((struct proc *, struct linux_fstatfs_args *)); -int linux_ioperm __P((struct proc *, struct linux_ioperm_args *)); -int linux_socketcall __P((struct proc *, struct linux_socketcall_args *)); -int linux_ksyslog __P((struct proc *, struct linux_ksyslog_args *)); -int linux_setitimer __P((struct proc *, struct linux_setitimer_args *)); -int linux_getitimer __P((struct proc *, struct linux_getitimer_args *)); -int linux_newstat __P((struct proc *, struct linux_newstat_args *)); -int linux_newlstat __P((struct proc *, struct linux_newlstat_args *)); -int linux_newfstat __P((struct proc *, struct linux_newfstat_args *)); -int linux_uname __P((struct proc *, struct linux_uname_args *)); -int linux_iopl __P((struct proc *, struct linux_iopl_args *)); -int linux_vhangup __P((struct proc *, struct linux_vhangup_args *)); -int linux_idle __P((struct proc *, struct linux_idle_args *)); -int linux_vm86old __P((struct proc *, struct linux_vm86old_args *)); -int linux_wait4 __P((struct proc *, struct linux_wait4_args *)); -int linux_swapoff __P((struct proc *, struct linux_swapoff_args *)); -int linux_sysinfo __P((struct proc *, struct linux_sysinfo_args *)); -int linux_ipc __P((struct proc *, struct linux_ipc_args *)); -int linux_sigreturn __P((struct proc *, struct linux_sigreturn_args *)); -int linux_clone __P((struct proc *, struct linux_clone_args *)); -int linux_newuname __P((struct proc *, struct linux_newuname_args *)); -int linux_modify_ldt __P((struct proc *, struct linux_modify_ldt_args *)); -int linux_adjtimex __P((struct proc *, struct linux_adjtimex_args *)); -int linux_sigprocmask __P((struct proc *, struct linux_sigprocmask_args *)); -int linux_create_module __P((struct proc *, struct linux_create_module_args *)); -int linux_init_module __P((struct proc *, struct linux_init_module_args *)); -int linux_delete_module __P((struct proc *, struct linux_delete_module_args *)); -int linux_get_kernel_syms __P((struct proc *, struct linux_get_kernel_syms_args *)); -int linux_quotactl __P((struct proc *, struct linux_quotactl_args *)); -int linux_getpgid __P((struct proc *, struct linux_getpgid_args *)); -int linux_bdflush __P((struct proc *, struct linux_bdflush_args *)); -int linux_sysfs __P((struct proc *, struct linux_sysfs_args *)); -int linux_personality __P((struct proc *, struct linux_personality_args *)); -int linux_afs_syscall __P((struct proc *, struct linux_afs_syscall_args *)); -int linux_setfsuid __P((struct proc *, struct linux_setfsuid_args *)); -int linux_setfsgid __P((struct proc *, struct linux_setfsgid_args *)); -int linux_llseek __P((struct proc *, struct linux_llseek_args *)); -int linux_getdents __P((struct proc *, struct linux_getdents_args *)); -int linux_newselect __P((struct proc *, struct linux_newselect_args *)); -int linux_msync __P((struct proc *, struct linux_msync_args *)); -int linux_getsid __P((struct proc *, struct linux_getsid_args *)); -int linux_fdatasync __P((struct proc *, struct linux_fdatasync_args *)); -int linux_sysctl __P((struct proc *, struct linux_sysctl_args *)); -int linux_sched_setscheduler __P((struct proc *, struct linux_sched_setscheduler_args *)); -int linux_sched_getscheduler __P((struct proc *, struct linux_sched_getscheduler_args *)); -int linux_mremap __P((struct proc *, struct linux_mremap_args *)); -int linux_getresuid __P((struct proc *, struct linux_getresuid_args *)); -int linux_vm86 __P((struct proc *, struct linux_vm86_args *)); -int linux_query_module __P((struct proc *, struct linux_query_module_args *)); -int linux_nfsservctl __P((struct proc *, struct linux_nfsservctl_args *)); -int linux_getresgid __P((struct proc *, struct linux_getresgid_args *)); -int linux_prctl __P((struct proc *, struct linux_prctl_args *)); -int linux_rt_sigreturn __P((struct proc *, struct linux_rt_sigreturn_args *)); -int linux_rt_sigaction __P((struct proc *, struct linux_rt_sigaction_args *)); -int linux_rt_sigprocmask __P((struct proc *, struct linux_rt_sigprocmask_args *)); -int linux_rt_sigpending __P((struct proc *, struct linux_rt_sigpending_args *)); -int linux_rt_sigtimedwait __P((struct proc *, struct linux_rt_sigtimedwait_args *)); -int linux_rt_sigqueueinfo __P((struct proc *, struct linux_rt_sigqueueinfo_args *)); -int linux_rt_sigsuspend __P((struct proc *, struct linux_rt_sigsuspend_args *)); -int linux_pread __P((struct proc *, struct linux_pread_args *)); -int linux_pwrite __P((struct proc *, struct linux_pwrite_args *)); -int linux_chown __P((struct proc *, struct linux_chown_args *)); -int linux_getcwd __P((struct proc *, struct linux_getcwd_args *)); -int linux_capget __P((struct proc *, struct linux_capget_args *)); -int linux_capset __P((struct proc *, struct linux_capset_args *)); -int linux_sigaltstack __P((struct proc *, struct linux_sigaltstack_args *)); -int linux_sendfile __P((struct proc *, struct linux_sendfile_args *)); -int linux_getpmsg __P((struct proc *, struct linux_getpmsg_args *)); -int linux_putpmsg __P((struct proc *, struct linux_putpmsg_args *)); -int linux_vfork __P((struct proc *, struct linux_vfork_args *)); -int linux_ugetrlimit __P((struct proc *, struct linux_ugetrlimit_args *)); -int linux_mmap2 __P((struct proc *, struct linux_mmap2_args *)); -int linux_truncate64 __P((struct proc *, struct linux_truncate64_args *)); -int linux_ftruncate64 __P((struct proc *, struct linux_ftruncate64_args *)); -int linux_stat64 __P((struct proc *, struct linux_stat64_args *)); -int linux_lstat64 __P((struct proc *, struct linux_lstat64_args *)); -int linux_fstat64 __P((struct proc *, struct linux_fstat64_args *)); - -#ifdef COMPAT_43 - - -#endif /* COMPAT_43 */ - -#undef PAD_ - -#endif /* !_LINUX_SYSPROTO_H_ */ Property changes on: head/sys/i386/linux/linux_proto.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/i386/linux/linux_syscall.h =================================================================== --- head/sys/i386/linux/linux_syscall.h (revision 68518) +++ head/sys/i386/linux/linux_syscall.h (nonexistent) @@ -1,207 +0,0 @@ -/* - * System call numbers. - * - * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.35 2000/10/17 00:00:20 gallatin Exp - */ - -#define LINUX_SYS_linux_setup 0 -#define LINUX_SYS_exit 1 -#define LINUX_SYS_linux_fork 2 -#define LINUX_SYS_read 3 -#define LINUX_SYS_write 4 -#define LINUX_SYS_linux_open 5 -#define LINUX_SYS_close 6 -#define LINUX_SYS_linux_waitpid 7 -#define LINUX_SYS_linux_creat 8 -#define LINUX_SYS_linux_link 9 -#define LINUX_SYS_linux_unlink 10 -#define LINUX_SYS_linux_execve 11 -#define LINUX_SYS_linux_chdir 12 -#define LINUX_SYS_linux_time 13 -#define LINUX_SYS_linux_mknod 14 -#define LINUX_SYS_linux_chmod 15 -#define LINUX_SYS_linux_lchown 16 -#define LINUX_SYS_linux_break 17 -#define LINUX_SYS_linux_stat 18 -#define LINUX_SYS_linux_lseek 19 -#define LINUX_SYS_getpid 20 -#define LINUX_SYS_linux_mount 21 -#define LINUX_SYS_linux_umount 22 -#define LINUX_SYS_setuid 23 -#define LINUX_SYS_getuid 24 -#define LINUX_SYS_linux_stime 25 -#define LINUX_SYS_linux_ptrace 26 -#define LINUX_SYS_linux_alarm 27 -#define LINUX_SYS_linux_fstat 28 -#define LINUX_SYS_linux_pause 29 -#define LINUX_SYS_linux_utime 30 -#define LINUX_SYS_linux_stty 31 -#define LINUX_SYS_linux_gtty 32 -#define LINUX_SYS_linux_access 33 -#define LINUX_SYS_linux_nice 34 -#define LINUX_SYS_linux_ftime 35 -#define LINUX_SYS_sync 36 -#define LINUX_SYS_linux_kill 37 -#define LINUX_SYS_linux_rename 38 -#define LINUX_SYS_linux_mkdir 39 -#define LINUX_SYS_linux_rmdir 40 -#define LINUX_SYS_dup 41 -#define LINUX_SYS_linux_pipe 42 -#define LINUX_SYS_linux_times 43 -#define LINUX_SYS_linux_prof 44 -#define LINUX_SYS_linux_brk 45 -#define LINUX_SYS_setgid 46 -#define LINUX_SYS_getgid 47 -#define LINUX_SYS_linux_signal 48 -#define LINUX_SYS_geteuid 49 -#define LINUX_SYS_getegid 50 -#define LINUX_SYS_acct 51 -#define LINUX_SYS_linux_umount2 52 -#define LINUX_SYS_linux_lock 53 -#define LINUX_SYS_linux_ioctl 54 -#define LINUX_SYS_linux_fcntl 55 -#define LINUX_SYS_linux_mpx 56 -#define LINUX_SYS_setpgid 57 -#define LINUX_SYS_linux_ulimit 58 -#define LINUX_SYS_linux_olduname 59 -#define LINUX_SYS_umask 60 -#define LINUX_SYS_chroot 61 -#define LINUX_SYS_linux_ustat 62 -#define LINUX_SYS_dup2 63 -#define LINUX_SYS_getppid 64 -#define LINUX_SYS_getpgrp 65 -#define LINUX_SYS_setsid 66 -#define LINUX_SYS_linux_sigaction 67 -#define LINUX_SYS_linux_siggetmask 68 -#define LINUX_SYS_linux_sigsetmask 69 -#define LINUX_SYS_setreuid 70 -#define LINUX_SYS_setregid 71 -#define LINUX_SYS_linux_sigsuspend 72 -#define LINUX_SYS_linux_sigpending 73 -#define LINUX_SYS_osethostname 74 -#define LINUX_SYS_linux_setrlimit 75 -#define LINUX_SYS_linux_getrlimit 76 -#define LINUX_SYS_getrusage 77 -#define LINUX_SYS_gettimeofday 78 -#define LINUX_SYS_settimeofday 79 -#define LINUX_SYS_linux_getgroups 80 -#define LINUX_SYS_linux_setgroups 81 -#define LINUX_SYS_linux_select 82 -#define LINUX_SYS_linux_symlink 83 -#define LINUX_SYS_ostat 84 -#define LINUX_SYS_linux_readlink 85 -#define LINUX_SYS_linux_uselib 86 -#define LINUX_SYS_swapon 87 -#define LINUX_SYS_reboot 88 -#define LINUX_SYS_linux_readdir 89 -#define LINUX_SYS_linux_mmap 90 -#define LINUX_SYS_munmap 91 -#define LINUX_SYS_linux_truncate 92 -#define LINUX_SYS_oftruncate 93 -#define LINUX_SYS_fchmod 94 -#define LINUX_SYS_fchown 95 -#define LINUX_SYS_getpriority 96 -#define LINUX_SYS_setpriority 97 -#define LINUX_SYS_profil 98 -#define LINUX_SYS_linux_statfs 99 -#define LINUX_SYS_linux_fstatfs 100 -#define LINUX_SYS_linux_ioperm 101 -#define LINUX_SYS_linux_socketcall 102 -#define LINUX_SYS_linux_ksyslog 103 -#define LINUX_SYS_linux_setitimer 104 -#define LINUX_SYS_linux_getitimer 105 -#define LINUX_SYS_linux_newstat 106 -#define LINUX_SYS_linux_newlstat 107 -#define LINUX_SYS_linux_newfstat 108 -#define LINUX_SYS_linux_uname 109 -#define LINUX_SYS_linux_iopl 110 -#define LINUX_SYS_linux_vhangup 111 -#define LINUX_SYS_linux_idle 112 -#define LINUX_SYS_linux_vm86old 113 -#define LINUX_SYS_linux_wait4 114 -#define LINUX_SYS_linux_swapoff 115 -#define LINUX_SYS_linux_sysinfo 116 -#define LINUX_SYS_linux_ipc 117 -#define LINUX_SYS_fsync 118 -#define LINUX_SYS_linux_sigreturn 119 -#define LINUX_SYS_linux_clone 120 -#define LINUX_SYS_setdomainname 121 -#define LINUX_SYS_linux_newuname 122 -#define LINUX_SYS_linux_modify_ldt 123 -#define LINUX_SYS_linux_adjtimex 124 -#define LINUX_SYS_mprotect 125 -#define LINUX_SYS_linux_sigprocmask 126 -#define LINUX_SYS_linux_create_module 127 -#define LINUX_SYS_linux_init_module 128 -#define LINUX_SYS_linux_delete_module 129 -#define LINUX_SYS_linux_get_kernel_syms 130 -#define LINUX_SYS_linux_quotactl 131 -#define LINUX_SYS_linux_getpgid 132 -#define LINUX_SYS_fchdir 133 -#define LINUX_SYS_linux_bdflush 134 -#define LINUX_SYS_linux_sysfs 135 -#define LINUX_SYS_linux_personality 136 -#define LINUX_SYS_linux_afs_syscall 137 -#define LINUX_SYS_linux_setfsuid 138 -#define LINUX_SYS_linux_setfsgid 139 -#define LINUX_SYS_linux_llseek 140 -#define LINUX_SYS_linux_getdents 141 -#define LINUX_SYS_linux_newselect 142 -#define LINUX_SYS_flock 143 -#define LINUX_SYS_linux_msync 144 -#define LINUX_SYS_readv 145 -#define LINUX_SYS_writev 146 -#define LINUX_SYS_linux_getsid 147 -#define LINUX_SYS_linux_fdatasync 148 -#define LINUX_SYS_linux_sysctl 149 -#define LINUX_SYS_mlock 150 -#define LINUX_SYS_munlock 151 -#define LINUX_SYS_mlockall 152 -#define LINUX_SYS_munlockall 153 -#define LINUX_SYS_sched_setparam 154 -#define LINUX_SYS_sched_getparam 155 -#define LINUX_SYS_linux_sched_setscheduler 156 -#define LINUX_SYS_linux_sched_getscheduler 157 -#define LINUX_SYS_sched_yield 158 -#define LINUX_SYS_sched_get_priority_max 159 -#define LINUX_SYS_sched_get_priority_min 160 -#define LINUX_SYS_sched_rr_get_interval 161 -#define LINUX_SYS_nanosleep 162 -#define LINUX_SYS_linux_mremap 163 -#define LINUX_SYS_setresuid 164 -#define LINUX_SYS_linux_getresuid 165 -#define LINUX_SYS_linux_vm86 166 -#define LINUX_SYS_linux_query_module 167 -#define LINUX_SYS_poll 168 -#define LINUX_SYS_linux_nfsservctl 169 -#define LINUX_SYS_setresgid 170 -#define LINUX_SYS_linux_getresgid 171 -#define LINUX_SYS_linux_prctl 172 -#define LINUX_SYS_linux_rt_sigreturn 173 -#define LINUX_SYS_linux_rt_sigaction 174 -#define LINUX_SYS_linux_rt_sigprocmask 175 -#define LINUX_SYS_linux_rt_sigpending 176 -#define LINUX_SYS_linux_rt_sigtimedwait 177 -#define LINUX_SYS_linux_rt_sigqueueinfo 178 -#define LINUX_SYS_linux_rt_sigsuspend 179 -#define LINUX_SYS_linux_pread 180 -#define LINUX_SYS_linux_pwrite 181 -#define LINUX_SYS_linux_chown 182 -#define LINUX_SYS_linux_getcwd 183 -#define LINUX_SYS_linux_capget 184 -#define LINUX_SYS_linux_capset 185 -#define LINUX_SYS_linux_sigaltstack 186 -#define LINUX_SYS_linux_sendfile 187 -#define LINUX_SYS_linux_getpmsg 188 -#define LINUX_SYS_linux_putpmsg 189 -#define LINUX_SYS_linux_vfork 190 -#define LINUX_SYS_linux_ugetrlimit 191 -#define LINUX_SYS_linux_mmap2 192 -#define LINUX_SYS_linux_truncate64 193 -#define LINUX_SYS_linux_ftruncate64 194 -#define LINUX_SYS_linux_stat64 195 -#define LINUX_SYS_linux_lstat64 196 -#define LINUX_SYS_linux_fstat64 197 -#define LINUX_SYS_MAXSYSCALL 198 Property changes on: head/sys/i386/linux/linux_syscall.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/i386/linux/linux_sysent.c =================================================================== --- head/sys/i386/linux/linux_sysent.c (revision 68518) +++ head/sys/i386/linux/linux_sysent.c (nonexistent) @@ -1,218 +0,0 @@ -/* - * System call switch table. - * - * DO NOT EDIT-- this file is automatically generated. - * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.35 2000/10/17 00:00:20 gallatin Exp - */ - -#include "opt_compat.h" -#include -#include -#include -#include -#include - -#define AS(name) (sizeof(struct name) / sizeof(register_t)) - -/* The casts are bogus but will do for now. */ -struct sysent linux_sysent[] = { - { 0, (sy_call_t *)linux_setup }, /* 0 = linux_setup */ - { AS(sys_exit_args), (sy_call_t *)sys_exit }, /* 1 = exit */ - { 0, (sy_call_t *)linux_fork }, /* 2 = linux_fork */ - { AS(read_args), (sy_call_t *)read }, /* 3 = read */ - { AS(write_args), (sy_call_t *)write }, /* 4 = write */ - { AS(linux_open_args), (sy_call_t *)linux_open }, /* 5 = linux_open */ - { AS(close_args), (sy_call_t *)close }, /* 6 = close */ - { AS(linux_waitpid_args), (sy_call_t *)linux_waitpid }, /* 7 = linux_waitpid */ - { AS(linux_creat_args), (sy_call_t *)linux_creat }, /* 8 = linux_creat */ - { AS(linux_link_args), (sy_call_t *)linux_link }, /* 9 = linux_link */ - { AS(linux_unlink_args), (sy_call_t *)linux_unlink }, /* 10 = linux_unlink */ - { AS(linux_execve_args), (sy_call_t *)linux_execve }, /* 11 = linux_execve */ - { AS(linux_chdir_args), (sy_call_t *)linux_chdir }, /* 12 = linux_chdir */ - { AS(linux_time_args), (sy_call_t *)linux_time }, /* 13 = linux_time */ - { AS(linux_mknod_args), (sy_call_t *)linux_mknod }, /* 14 = linux_mknod */ - { AS(linux_chmod_args), (sy_call_t *)linux_chmod }, /* 15 = linux_chmod */ - { AS(linux_lchown_args), (sy_call_t *)linux_lchown }, /* 16 = linux_lchown */ - { AS(linux_break_args), (sy_call_t *)linux_break }, /* 17 = linux_break */ - { AS(linux_stat_args), (sy_call_t *)linux_stat }, /* 18 = linux_stat */ - { AS(linux_lseek_args), (sy_call_t *)linux_lseek }, /* 19 = linux_lseek */ - { 0, (sy_call_t *)getpid }, /* 20 = getpid */ - { 0, (sy_call_t *)linux_mount }, /* 21 = linux_mount */ - { 0, (sy_call_t *)linux_umount }, /* 22 = linux_umount */ - { AS(setuid_args), (sy_call_t *)setuid }, /* 23 = setuid */ - { 0, (sy_call_t *)getuid }, /* 24 = getuid */ - { 0, (sy_call_t *)linux_stime }, /* 25 = linux_stime */ - { 0, (sy_call_t *)linux_ptrace }, /* 26 = linux_ptrace */ - { AS(linux_alarm_args), (sy_call_t *)linux_alarm }, /* 27 = linux_alarm */ - { AS(linux_fstat_args), (sy_call_t *)linux_fstat }, /* 28 = linux_fstat */ - { 0, (sy_call_t *)linux_pause }, /* 29 = linux_pause */ - { AS(linux_utime_args), (sy_call_t *)linux_utime }, /* 30 = linux_utime */ - { 0, (sy_call_t *)linux_stty }, /* 31 = linux_stty */ - { 0, (sy_call_t *)linux_gtty }, /* 32 = linux_gtty */ - { AS(linux_access_args), (sy_call_t *)linux_access }, /* 33 = linux_access */ - { AS(linux_nice_args), (sy_call_t *)linux_nice }, /* 34 = linux_nice */ - { 0, (sy_call_t *)linux_ftime }, /* 35 = linux_ftime */ - { 0, (sy_call_t *)sync }, /* 36 = sync */ - { AS(linux_kill_args), (sy_call_t *)linux_kill }, /* 37 = linux_kill */ - { AS(linux_rename_args), (sy_call_t *)linux_rename }, /* 38 = linux_rename */ - { AS(linux_mkdir_args), (sy_call_t *)linux_mkdir }, /* 39 = linux_mkdir */ - { AS(linux_rmdir_args), (sy_call_t *)linux_rmdir }, /* 40 = linux_rmdir */ - { AS(dup_args), (sy_call_t *)dup }, /* 41 = dup */ - { AS(linux_pipe_args), (sy_call_t *)linux_pipe }, /* 42 = linux_pipe */ - { AS(linux_times_args), (sy_call_t *)linux_times }, /* 43 = linux_times */ - { 0, (sy_call_t *)linux_prof }, /* 44 = linux_prof */ - { AS(linux_brk_args), (sy_call_t *)linux_brk }, /* 45 = linux_brk */ - { AS(setgid_args), (sy_call_t *)setgid }, /* 46 = setgid */ - { 0, (sy_call_t *)getgid }, /* 47 = getgid */ - { AS(linux_signal_args), (sy_call_t *)linux_signal }, /* 48 = linux_signal */ - { 0, (sy_call_t *)geteuid }, /* 49 = geteuid */ - { 0, (sy_call_t *)getegid }, /* 50 = getegid */ - { AS(acct_args), (sy_call_t *)acct }, /* 51 = acct */ - { 0, (sy_call_t *)linux_umount2 }, /* 52 = linux_umount2 */ - { 0, (sy_call_t *)linux_lock }, /* 53 = linux_lock */ - { AS(linux_ioctl_args), (sy_call_t *)linux_ioctl }, /* 54 = linux_ioctl */ - { AS(linux_fcntl_args), (sy_call_t *)linux_fcntl }, /* 55 = linux_fcntl */ - { 0, (sy_call_t *)linux_mpx }, /* 56 = linux_mpx */ - { AS(setpgid_args), (sy_call_t *)setpgid }, /* 57 = setpgid */ - { 0, (sy_call_t *)linux_ulimit }, /* 58 = linux_ulimit */ - { 0, (sy_call_t *)linux_olduname }, /* 59 = linux_olduname */ - { AS(umask_args), (sy_call_t *)umask }, /* 60 = umask */ - { AS(chroot_args), (sy_call_t *)chroot }, /* 61 = chroot */ - { AS(linux_ustat_args), (sy_call_t *)linux_ustat }, /* 62 = linux_ustat */ - { AS(dup2_args), (sy_call_t *)dup2 }, /* 63 = dup2 */ - { 0, (sy_call_t *)getppid }, /* 64 = getppid */ - { 0, (sy_call_t *)getpgrp }, /* 65 = getpgrp */ - { 0, (sy_call_t *)setsid }, /* 66 = setsid */ - { AS(linux_sigaction_args), (sy_call_t *)linux_sigaction }, /* 67 = linux_sigaction */ - { 0, (sy_call_t *)linux_siggetmask }, /* 68 = linux_siggetmask */ - { AS(linux_sigsetmask_args), (sy_call_t *)linux_sigsetmask }, /* 69 = linux_sigsetmask */ - { AS(setreuid_args), (sy_call_t *)setreuid }, /* 70 = setreuid */ - { AS(setregid_args), (sy_call_t *)setregid }, /* 71 = setregid */ - { AS(linux_sigsuspend_args), (sy_call_t *)linux_sigsuspend }, /* 72 = linux_sigsuspend */ - { AS(linux_sigpending_args), (sy_call_t *)linux_sigpending }, /* 73 = linux_sigpending */ - { AS(sethostname_args), (sy_call_t *)osethostname }, /* 74 = osethostname */ - { AS(linux_setrlimit_args), (sy_call_t *)linux_setrlimit }, /* 75 = linux_setrlimit */ - { AS(linux_getrlimit_args), (sy_call_t *)linux_getrlimit }, /* 76 = linux_getrlimit */ - { AS(getrusage_args), (sy_call_t *)getrusage }, /* 77 = getrusage */ - { AS(gettimeofday_args), (sy_call_t *)gettimeofday }, /* 78 = gettimeofday */ - { AS(settimeofday_args), (sy_call_t *)settimeofday }, /* 79 = settimeofday */ - { AS(linux_getgroups_args), (sy_call_t *)linux_getgroups }, /* 80 = linux_getgroups */ - { AS(linux_setgroups_args), (sy_call_t *)linux_setgroups }, /* 81 = linux_setgroups */ - { AS(linux_select_args), (sy_call_t *)linux_select }, /* 82 = linux_select */ - { AS(linux_symlink_args), (sy_call_t *)linux_symlink }, /* 83 = linux_symlink */ - { AS(ostat_args), (sy_call_t *)ostat }, /* 84 = ostat */ - { AS(linux_readlink_args), (sy_call_t *)linux_readlink }, /* 85 = linux_readlink */ - { AS(linux_uselib_args), (sy_call_t *)linux_uselib }, /* 86 = linux_uselib */ - { AS(swapon_args), (sy_call_t *)swapon }, /* 87 = swapon */ - { AS(reboot_args), (sy_call_t *)reboot }, /* 88 = reboot */ - { AS(linux_readdir_args), (sy_call_t *)linux_readdir }, /* 89 = linux_readdir */ - { AS(linux_mmap_args), (sy_call_t *)linux_mmap }, /* 90 = linux_mmap */ - { AS(munmap_args), (sy_call_t *)munmap }, /* 91 = munmap */ - { AS(linux_truncate_args), (sy_call_t *)linux_truncate }, /* 92 = linux_truncate */ - { AS(oftruncate_args), (sy_call_t *)oftruncate }, /* 93 = oftruncate */ - { AS(fchmod_args), (sy_call_t *)fchmod }, /* 94 = fchmod */ - { AS(fchown_args), (sy_call_t *)fchown }, /* 95 = fchown */ - { AS(getpriority_args), (sy_call_t *)getpriority }, /* 96 = getpriority */ - { AS(setpriority_args), (sy_call_t *)setpriority }, /* 97 = setpriority */ - { AS(profil_args), (sy_call_t *)profil }, /* 98 = profil */ - { AS(linux_statfs_args), (sy_call_t *)linux_statfs }, /* 99 = linux_statfs */ - { AS(linux_fstatfs_args), (sy_call_t *)linux_fstatfs }, /* 100 = linux_fstatfs */ - { AS(linux_ioperm_args), (sy_call_t *)linux_ioperm }, /* 101 = linux_ioperm */ - { AS(linux_socketcall_args), (sy_call_t *)linux_socketcall }, /* 102 = linux_socketcall */ - { AS(linux_ksyslog_args), (sy_call_t *)linux_ksyslog }, /* 103 = linux_ksyslog */ - { AS(linux_setitimer_args), (sy_call_t *)linux_setitimer }, /* 104 = linux_setitimer */ - { AS(linux_getitimer_args), (sy_call_t *)linux_getitimer }, /* 105 = linux_getitimer */ - { AS(linux_newstat_args), (sy_call_t *)linux_newstat }, /* 106 = linux_newstat */ - { AS(linux_newlstat_args), (sy_call_t *)linux_newlstat }, /* 107 = linux_newlstat */ - { AS(linux_newfstat_args), (sy_call_t *)linux_newfstat }, /* 108 = linux_newfstat */ - { 0, (sy_call_t *)linux_uname }, /* 109 = linux_uname */ - { AS(linux_iopl_args), (sy_call_t *)linux_iopl }, /* 110 = linux_iopl */ - { 0, (sy_call_t *)linux_vhangup }, /* 111 = linux_vhangup */ - { 0, (sy_call_t *)linux_idle }, /* 112 = linux_idle */ - { 0, (sy_call_t *)linux_vm86old }, /* 113 = linux_vm86old */ - { AS(linux_wait4_args), (sy_call_t *)linux_wait4 }, /* 114 = linux_wait4 */ - { 0, (sy_call_t *)linux_swapoff }, /* 115 = linux_swapoff */ - { 0, (sy_call_t *)linux_sysinfo }, /* 116 = linux_sysinfo */ - { AS(linux_ipc_args), (sy_call_t *)linux_ipc }, /* 117 = linux_ipc */ - { AS(fsync_args), (sy_call_t *)fsync }, /* 118 = fsync */ - { AS(linux_sigreturn_args), (sy_call_t *)linux_sigreturn }, /* 119 = linux_sigreturn */ - { AS(linux_clone_args), (sy_call_t *)linux_clone }, /* 120 = linux_clone */ - { AS(setdomainname_args), (sy_call_t *)setdomainname }, /* 121 = setdomainname */ - { AS(linux_newuname_args), (sy_call_t *)linux_newuname }, /* 122 = linux_newuname */ - { AS(linux_modify_ldt_args), (sy_call_t *)linux_modify_ldt }, /* 123 = linux_modify_ldt */ - { 0, (sy_call_t *)linux_adjtimex }, /* 124 = linux_adjtimex */ - { AS(mprotect_args), (sy_call_t *)mprotect }, /* 125 = mprotect */ - { AS(linux_sigprocmask_args), (sy_call_t *)linux_sigprocmask }, /* 126 = linux_sigprocmask */ - { 0, (sy_call_t *)linux_create_module }, /* 127 = linux_create_module */ - { 0, (sy_call_t *)linux_init_module }, /* 128 = linux_init_module */ - { 0, (sy_call_t *)linux_delete_module }, /* 129 = linux_delete_module */ - { 0, (sy_call_t *)linux_get_kernel_syms }, /* 130 = linux_get_kernel_syms */ - { 0, (sy_call_t *)linux_quotactl }, /* 131 = linux_quotactl */ - { AS(linux_getpgid_args), (sy_call_t *)linux_getpgid }, /* 132 = linux_getpgid */ - { AS(fchdir_args), (sy_call_t *)fchdir }, /* 133 = fchdir */ - { 0, (sy_call_t *)linux_bdflush }, /* 134 = linux_bdflush */ - { AS(linux_sysfs_args), (sy_call_t *)linux_sysfs }, /* 135 = linux_sysfs */ - { AS(linux_personality_args), (sy_call_t *)linux_personality }, /* 136 = linux_personality */ - { 0, (sy_call_t *)linux_afs_syscall }, /* 137 = linux_afs_syscall */ - { AS(linux_setfsuid_args), (sy_call_t *)linux_setfsuid }, /* 138 = linux_setfsuid */ - { AS(linux_setfsgid_args), (sy_call_t *)linux_setfsgid }, /* 139 = linux_setfsgid */ - { AS(linux_llseek_args), (sy_call_t *)linux_llseek }, /* 140 = linux_llseek */ - { AS(linux_getdents_args), (sy_call_t *)linux_getdents }, /* 141 = linux_getdents */ - { AS(linux_newselect_args), (sy_call_t *)linux_newselect }, /* 142 = linux_newselect */ - { AS(flock_args), (sy_call_t *)flock }, /* 143 = flock */ - { AS(linux_msync_args), (sy_call_t *)linux_msync }, /* 144 = linux_msync */ - { AS(readv_args), (sy_call_t *)readv }, /* 145 = readv */ - { AS(writev_args), (sy_call_t *)writev }, /* 146 = writev */ - { AS(linux_getsid_args), (sy_call_t *)linux_getsid }, /* 147 = linux_getsid */ - { AS(linux_fdatasync_args), (sy_call_t *)linux_fdatasync }, /* 148 = linux_fdatasync */ - { 0, (sy_call_t *)linux_sysctl }, /* 149 = linux_sysctl */ - { AS(mlock_args), (sy_call_t *)mlock }, /* 150 = mlock */ - { AS(munlock_args), (sy_call_t *)munlock }, /* 151 = munlock */ - { AS(mlockall_args), (sy_call_t *)mlockall }, /* 152 = mlockall */ - { 0, (sy_call_t *)munlockall }, /* 153 = munlockall */ - { AS(sched_setparam_args), (sy_call_t *)sched_setparam }, /* 154 = sched_setparam */ - { AS(sched_getparam_args), (sy_call_t *)sched_getparam }, /* 155 = sched_getparam */ - { AS(linux_sched_setscheduler_args), (sy_call_t *)linux_sched_setscheduler }, /* 156 = linux_sched_setscheduler */ - { AS(linux_sched_getscheduler_args), (sy_call_t *)linux_sched_getscheduler }, /* 157 = linux_sched_getscheduler */ - { 0, (sy_call_t *)sched_yield }, /* 158 = sched_yield */ - { AS(sched_get_priority_max_args), (sy_call_t *)sched_get_priority_max }, /* 159 = sched_get_priority_max */ - { AS(sched_get_priority_min_args), (sy_call_t *)sched_get_priority_min }, /* 160 = sched_get_priority_min */ - { AS(sched_rr_get_interval_args), (sy_call_t *)sched_rr_get_interval }, /* 161 = sched_rr_get_interval */ - { AS(nanosleep_args), (sy_call_t *)nanosleep }, /* 162 = nanosleep */ - { AS(linux_mremap_args), (sy_call_t *)linux_mremap }, /* 163 = linux_mremap */ - { AS(setresuid_args), (sy_call_t *)setresuid }, /* 164 = setresuid */ - { AS(linux_getresuid_args), (sy_call_t *)linux_getresuid }, /* 165 = linux_getresuid */ - { 0, (sy_call_t *)linux_vm86 }, /* 166 = linux_vm86 */ - { 0, (sy_call_t *)linux_query_module }, /* 167 = linux_query_module */ - { AS(poll_args), (sy_call_t *)poll }, /* 168 = poll */ - { 0, (sy_call_t *)linux_nfsservctl }, /* 169 = linux_nfsservctl */ - { AS(setresgid_args), (sy_call_t *)setresgid }, /* 170 = setresgid */ - { AS(linux_getresgid_args), (sy_call_t *)linux_getresgid }, /* 171 = linux_getresgid */ - { 0, (sy_call_t *)linux_prctl }, /* 172 = linux_prctl */ - { AS(linux_rt_sigreturn_args), (sy_call_t *)linux_rt_sigreturn }, /* 173 = linux_rt_sigreturn */ - { AS(linux_rt_sigaction_args), (sy_call_t *)linux_rt_sigaction }, /* 174 = linux_rt_sigaction */ - { AS(linux_rt_sigprocmask_args), (sy_call_t *)linux_rt_sigprocmask }, /* 175 = linux_rt_sigprocmask */ - { 0, (sy_call_t *)linux_rt_sigpending }, /* 176 = linux_rt_sigpending */ - { 0, (sy_call_t *)linux_rt_sigtimedwait }, /* 177 = linux_rt_sigtimedwait */ - { 0, (sy_call_t *)linux_rt_sigqueueinfo }, /* 178 = linux_rt_sigqueueinfo */ - { AS(linux_rt_sigsuspend_args), (sy_call_t *)linux_rt_sigsuspend }, /* 179 = linux_rt_sigsuspend */ - { AS(linux_pread_args), (sy_call_t *)linux_pread }, /* 180 = linux_pread */ - { AS(linux_pwrite_args), (sy_call_t *)linux_pwrite }, /* 181 = linux_pwrite */ - { AS(linux_chown_args), (sy_call_t *)linux_chown }, /* 182 = linux_chown */ - { AS(linux_getcwd_args), (sy_call_t *)linux_getcwd }, /* 183 = linux_getcwd */ - { 0, (sy_call_t *)linux_capget }, /* 184 = linux_capget */ - { 0, (sy_call_t *)linux_capset }, /* 185 = linux_capset */ - { AS(linux_sigaltstack_args), (sy_call_t *)linux_sigaltstack }, /* 186 = linux_sigaltstack */ - { 0, (sy_call_t *)linux_sendfile }, /* 187 = linux_sendfile */ - { 0, (sy_call_t *)linux_getpmsg }, /* 188 = linux_getpmsg */ - { 0, (sy_call_t *)linux_putpmsg }, /* 189 = linux_putpmsg */ - { 0, (sy_call_t *)linux_vfork }, /* 190 = linux_vfork */ - { 0, (sy_call_t *)linux_ugetrlimit }, /* 191 = linux_ugetrlimit */ - { 0, (sy_call_t *)linux_mmap2 }, /* 192 = linux_mmap2 */ - { 0, (sy_call_t *)linux_truncate64 }, /* 193 = linux_truncate64 */ - { 0, (sy_call_t *)linux_ftruncate64 }, /* 194 = linux_ftruncate64 */ - { 0, (sy_call_t *)linux_stat64 }, /* 195 = linux_stat64 */ - { 0, (sy_call_t *)linux_lstat64 }, /* 196 = linux_lstat64 */ - { 0, (sy_call_t *)linux_fstat64 }, /* 197 = linux_fstat64 */ -}; Property changes on: head/sys/i386/linux/linux_sysent.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/i386/linux/linux.h =================================================================== --- head/sys/i386/linux/linux.h (revision 68518) +++ head/sys/i386/linux/linux.h (revision 68519) @@ -1,509 +1,509 @@ /*- * Copyright (c) 1994-1996 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #ifndef _I386_LINUX_LINUX_H_ #define _I386_LINUX_LINUX_H_ #include /* for sigval union */ -#include +#include #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_LINUX); #endif /* * Miscellaneous */ #define LINUX_NAME_MAX 255 #define LINUX_MAX_UTSNAME 65 /* Scheduling policies */ #define LINUX_SCHED_OTHER 0 #define LINUX_SCHED_FIFO 1 #define LINUX_SCHED_RR 2 /* Resource limits */ #define LINUX_RLIMIT_CPU 0 #define LINUX_RLIMIT_FSIZE 1 #define LINUX_RLIMIT_DATA 2 #define LINUX_RLIMIT_STACK 3 #define LINUX_RLIMIT_CORE 4 #define LINUX_RLIMIT_RSS 5 #define LINUX_RLIMIT_NPROC 6 #define LINUX_RLIMIT_NOFILE 7 #define LINUX_RLIMIT_MEMLOCK 8 #define LINUX_RLIMIT_AS 9 /* address space limit */ #define LINUX_RLIM_NLIMITS 10 /* mmap options */ #define LINUX_MAP_SHARED 0x0001 #define LINUX_MAP_PRIVATE 0x0002 #define LINUX_MAP_FIXED 0x0010 #define LINUX_MAP_ANON 0x0020 #define LINUX_MAP_GROWSDOWN 0x0100 typedef char * linux_caddr_t; typedef long linux_clock_t; typedef u_short linux_dev_t; typedef u_short linux_gid_t; typedef u_long linux_ino_t; typedef int linux_key_t; /* XXX */ typedef u_short linux_mode_t; typedef u_short linux_nlink_t; typedef long linux_off_t; typedef int linux_pid_t; typedef u_int linux_size_t; typedef long linux_time_t; typedef u_short linux_uid_t; typedef struct { long val[2]; } linux_fsid_t; struct linux_new_utsname { char sysname[LINUX_MAX_UTSNAME]; char nodename[LINUX_MAX_UTSNAME]; char release[LINUX_MAX_UTSNAME]; char version[LINUX_MAX_UTSNAME]; char machine[LINUX_MAX_UTSNAME]; char domainname[LINUX_MAX_UTSNAME]; }; /* * Signalling */ #define LINUX_SIGHUP 1 #define LINUX_SIGINT 2 #define LINUX_SIGQUIT 3 #define LINUX_SIGILL 4 #define LINUX_SIGTRAP 5 #define LINUX_SIGABRT 6 #define LINUX_SIGIOT LINUX_SIGABRT #define LINUX_SIGBUS 7 #define LINUX_SIGFPE 8 #define LINUX_SIGKILL 9 #define LINUX_SIGUSR1 10 #define LINUX_SIGSEGV 11 #define LINUX_SIGUSR2 12 #define LINUX_SIGPIPE 13 #define LINUX_SIGALRM 14 #define LINUX_SIGTERM 15 #define LINUX_SIGSTKFLT 16 #define LINUX_SIGCHLD 17 #define LINUX_SIGCONT 18 #define LINUX_SIGSTOP 19 #define LINUX_SIGTSTP 20 #define LINUX_SIGTTIN 21 #define LINUX_SIGTTOU 22 #define LINUX_SIGURG 23 #define LINUX_SIGXCPU 24 #define LINUX_SIGXFSZ 25 #define LINUX_SIGVTALRM 26 #define LINUX_SIGPROF 27 #define LINUX_SIGWINCH 28 #define LINUX_SIGIO 29 #define LINUX_SIGPOLL LINUX_SIGIO #define LINUX_SIGPWR 30 #define LINUX_SIGUNUSED 31 #define LINUX_NSIG 64 #define LINUX_SIGTBLSZ 31 /* sigaction flags */ #define LINUX_SA_NOCLDSTOP 0x00000001 #define LINUX_SA_NOCLDWAIT 0x00000002 #define LINUX_SA_SIGINFO 0x00000004 #define LINUX_SA_RESTORER 0x04000000 #define LINUX_SA_ONSTACK 0x08000000 #define LINUX_SA_RESTART 0x10000000 #define LINUX_SA_INTERRUPT 0x20000000 #define LINUX_SA_NOMASK 0x40000000 #define LINUX_SA_ONESHOT 0x80000000 /* sigprocmask actions */ #define LINUX_SIG_BLOCK 0 #define LINUX_SIG_UNBLOCK 1 #define LINUX_SIG_SETMASK 2 /* sigset_t macros */ #define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0 #define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig) #define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig) /* sigaltstack */ #define LINUX_MINSIGSTKSZ 2048 #define LINUX_SS_ONSTACK_BC 0 /* backwards compat SS_ONSTACK */ #define LINUX_SS_ONSTACK 1 #define LINUX_SS_DISABLE 2 int linux_to_bsd_sigaltstack(int lsa); int bsd_to_linux_sigaltstack(int bsa); typedef void (*linux_handler_t)(int); typedef u_long linux_osigset_t; typedef struct { u_int __bits[2]; } linux_sigset_t; typedef struct { linux_handler_t lsa_handler; linux_osigset_t lsa_mask; u_long lsa_flags; void (*lsa_restorer)(void); } linux_osigaction_t; typedef struct { linux_handler_t lsa_handler; u_long lsa_flags; void (*lsa_restorer)(void); linux_sigset_t lsa_mask; } linux_sigaction_t; typedef struct { void *ss_sp; int ss_flags; linux_size_t ss_size; } linux_stack_t; /* The Linux sigcontext, pretty much a standard 386 trapframe. */ struct linux_sigcontext { int sc_gs; int sc_fs; int sc_es; int sc_ds; int sc_edi; int sc_esi; int sc_ebp; int sc_esp; int sc_ebx; int sc_edx; int sc_ecx; int sc_eax; int sc_trapno; int sc_err; int sc_eip; int sc_cs; int sc_eflags; int sc_esp_at_signal; int sc_ss; int sc_387; int sc_mask; int sc_cr2; }; struct linux_ucontext { unsigned long uc_flags; void *uc_link; linux_stack_t uc_stack; struct linux_sigcontext uc_mcontext; linux_sigset_t uc_sigmask; }; #define LINUX_SI_MAX_SIZE 128 #define LINUX_SI_PAD_SIZE ((LINUX_SI_MAX_SIZE/sizeof(int)) - 3) typedef struct siginfo { int lsi_signo; int lsi_errno; int lsi_code; union { int _pad[LINUX_SI_PAD_SIZE]; struct { linux_pid_t _pid; linux_uid_t _uid; } _kill; struct { unsigned int _timer1; unsigned int _timer2; } _timer; struct { linux_pid_t _pid; /* sender's pid */ linux_uid_t _uid; /* sender's uid */ union sigval _sigval; } _rt; struct { linux_pid_t _pid; /* which child */ linux_uid_t _uid; /* sender's uid */ int _status; /* exit code */ linux_clock_t _utime; linux_clock_t _stime; } _sigchld; struct { void *_addr; /* faulting insn/memory ref. */ } _sigfault; struct { int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ int _fd; } _sigpoll; } _sifields; } linux_siginfo_t; #define lsi_pid _sifields._kill._pid #define lsi_uid _sifields._kill._uid #define lsi_status _sifields._sigchld._status #define lsi_utime _sifields._sigchld._utime #define lsi_stime _sifields._sigchld._stime #define lsi_value _sifields._rt._sigval #define lsi_int _sifields._rt._sigval.sival_int #define lsi_ptr _sifields._rt._sigval.sival_ptr #define lsi_addr _sifields._sigfault._addr #define lsi_band _sifields._sigpoll._band #define lsi_fd _sifields._sigpoll._fd /* * We make the stack look like Linux expects it when calling a signal * handler, but use the BSD way of calling the handler and sigreturn(). * This means that we need to pass the pointer to the handler too. * It is appended to the frame to not interfere with the rest of it. */ struct linux_sigframe { int sf_sig; struct linux_sigcontext sf_sc; linux_handler_t sf_handler; }; struct linux_rt_sigframe { int sf_sig; linux_siginfo_t *sf_siginfo;; struct linux_ucontext *sf_ucontext; linux_siginfo_t sf_si; struct linux_ucontext sf_sc; linux_handler_t sf_handler; }; extern int bsd_to_linux_signal[]; extern int linux_to_bsd_signal[]; extern struct sysentvec linux_sysvec; extern struct sysentvec elf_linux_sysvec; void bsd_to_linux_sigset(sigset_t *bss, linux_sigset_t *lss); /* * Pluggable ioctl handlers */ struct linker_set; struct linux_ioctl_args; struct proc; typedef int linux_ioctl_function_t(struct proc *, struct linux_ioctl_args *); struct linux_ioctl_handler { linux_ioctl_function_t *func; int low, high; }; int linux_ioctl_register_handler(struct linux_ioctl_handler *h); int linux_ioctl_register_handlers(struct linker_set *s); int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h); int linux_ioctl_unregister_handlers(struct linker_set *s); /* * open/fcntl flags */ #define LINUX_O_RDONLY 00 #define LINUX_O_WRONLY 01 #define LINUX_O_RDWR 02 #define LINUX_O_CREAT 0100 #define LINUX_O_EXCL 0200 #define LINUX_O_NOCTTY 0400 #define LINUX_O_TRUNC 01000 #define LINUX_O_APPEND 02000 #define LINUX_O_NONBLOCK 04000 #define LINUX_O_NDELAY LINUX_O_NONBLOCK #define LINUX_O_SYNC 010000 #define LINUX_FASYNC 020000 #define LINUX_F_DUPFD 0 #define LINUX_F_GETFD 1 #define LINUX_F_SETFD 2 #define LINUX_F_GETFL 3 #define LINUX_F_SETFL 4 #define LINUX_F_GETLK 5 #define LINUX_F_SETLK 6 #define LINUX_F_SETLKW 7 #define LINUX_F_SETOWN 8 #define LINUX_F_GETOWN 9 #define LINUX_F_RDLCK 0 #define LINUX_F_WRLCK 1 #define LINUX_F_UNLCK 2 /* * SystemV IPC defines */ #define LINUX_SEMOP 1 #define LINUX_SEMGET 2 #define LINUX_SEMCTL 3 #define LINUX_MSGSND 11 #define LINUX_MSGRCV 12 #define LINUX_MSGGET 13 #define LINUX_MSGCTL 14 #define LINUX_SHMAT 21 #define LINUX_SHMDT 22 #define LINUX_SHMGET 23 #define LINUX_SHMCTL 24 #define LINUX_IPC_RMID 0 #define LINUX_IPC_SET 1 #define LINUX_IPC_STAT 2 #define LINUX_IPC_INFO 3 #define LINUX_SHM_LOCK 11 #define LINUX_SHM_UNLOCK 12 #define LINUX_SHM_STAT 13 #define LINUX_SHM_INFO 14 #define LINUX_SHM_RDONLY 0x1000 #define LINUX_SHM_RND 0x2000 #define LINUX_SHM_REMAP 0x4000 /* semctl commands */ #define LINUX_GETPID 11 #define LINUX_GETVAL 12 #define LINUX_GETALL 13 #define LINUX_GETNCNT 14 #define LINUX_GETZCNT 15 #define LINUX_SETVAL 16 #define LINUX_SETALL 17 /* * Socket defines */ #define LINUX_SOCKET 1 #define LINUX_BIND 2 #define LINUX_CONNECT 3 #define LINUX_LISTEN 4 #define LINUX_ACCEPT 5 #define LINUX_GETSOCKNAME 6 #define LINUX_GETPEERNAME 7 #define LINUX_SOCKETPAIR 8 #define LINUX_SEND 9 #define LINUX_RECV 10 #define LINUX_SENDTO 11 #define LINUX_RECVFROM 12 #define LINUX_SHUTDOWN 13 #define LINUX_SETSOCKOPT 14 #define LINUX_GETSOCKOPT 15 #define LINUX_SENDMSG 16 #define LINUX_RECVMSG 17 #define LINUX_AF_UNSPEC 0 #define LINUX_AF_UNIX 1 #define LINUX_AF_INET 2 #define LINUX_AF_AX25 3 #define LINUX_AF_IPX 4 #define LINUX_AF_APPLETALK 5 #define LINUX_SOL_SOCKET 1 #define LINUX_SOL_IP 0 #define LINUX_SOL_IPX 256 #define LINUX_SOL_AX25 257 #define LINUX_SOL_TCP 6 #define LINUX_SOL_UDP 17 #define LINUX_SO_DEBUG 1 #define LINUX_SO_REUSEADDR 2 #define LINUX_SO_TYPE 3 #define LINUX_SO_ERROR 4 #define LINUX_SO_DONTROUTE 5 #define LINUX_SO_BROADCAST 6 #define LINUX_SO_SNDBUF 7 #define LINUX_SO_RCVBUF 8 #define LINUX_SO_KEEPALIVE 9 #define LINUX_SO_OOBINLINE 10 #define LINUX_SO_NO_CHECK 11 #define LINUX_SO_PRIORITY 12 #define LINUX_SO_LINGER 13 #define LINUX_IP_TOS 1 #define LINUX_IP_TTL 2 #define LINUX_IP_HDRINCL 3 #define LINUX_IP_OPTIONS 4 #define LINUX_IP_MULTICAST_IF 32 #define LINUX_IP_MULTICAST_TTL 33 #define LINUX_IP_MULTICAST_LOOP 34 #define LINUX_IP_ADD_MEMBERSHIP 35 #define LINUX_IP_DROP_MEMBERSHIP 36 struct linux_sockaddr { u_short sa_family; char sa_data[14]; }; struct linux_ifmap { u_long mem_start; u_long mem_end; u_short base_addr; u_char irq; u_char dma; u_char port; }; #define LINUX_IFHWADDRLEN 6 #define LINUX_IFNAMSIZ 16 struct linux_ifreq { union { char ifrn_name[LINUX_IFNAMSIZ]; } ifr_ifrn; union { struct linux_sockaddr ifru_addr; struct linux_sockaddr ifru_dstaddr; struct linux_sockaddr ifru_broadaddr; struct linux_sockaddr ifru_netmask; struct linux_sockaddr ifru_hwaddr; short ifru_flags; int ifru_metric; int ifru_mtu; struct linux_ifmap ifru_map; char ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */ linux_caddr_t ifru_data; } ifr_ifru; }; #define ifr_name ifr_ifrn.ifrn_name /* interface name */ #define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ #endif /* !_I386_LINUX_LINUX_H_ */ Index: head/sys/i386/linux/linux_dummy.c =================================================================== --- head/sys/i386/linux/linux_dummy.c (revision 68518) +++ head/sys/i386/linux/linux_dummy.c (revision 68519) @@ -1,111 +1,111 @@ /*- * Copyright (c) 1994-1995 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include -#include +#include #define DUMMY(s) \ int \ linux_ ## s(struct proc *p, struct linux_ ## s ## _args *args) \ { \ return (unsupported_msg(p, #s)); \ } \ struct __hack static int unsupported_msg(struct proc *p, const char *fname) { printf("linux: syscall %s is obsoleted or not implemented (pid=%ld)\n", fname, (long)p->p_pid); return (ENOSYS); } DUMMY(setup); DUMMY(break); DUMMY(stat); DUMMY(mount); DUMMY(umount); DUMMY(stime); DUMMY(ptrace); DUMMY(fstat); DUMMY(stty); DUMMY(gtty); DUMMY(ftime); DUMMY(prof); DUMMY(umount2); DUMMY(lock); DUMMY(mpx); DUMMY(ulimit); DUMMY(olduname); DUMMY(ksyslog); DUMMY(uname); DUMMY(vhangup); DUMMY(idle); DUMMY(vm86old); DUMMY(swapoff); DUMMY(sysinfo); DUMMY(adjtimex); DUMMY(create_module); DUMMY(init_module); DUMMY(delete_module); DUMMY(get_kernel_syms); DUMMY(quotactl); DUMMY(bdflush); DUMMY(sysfs); DUMMY(afs_syscall); DUMMY(setfsuid); DUMMY(setfsgid); DUMMY(getsid); DUMMY(sysctl); DUMMY(getresuid); DUMMY(vm86); DUMMY(query_module); DUMMY(nfsservctl); DUMMY(getresgid); DUMMY(prctl); DUMMY(rt_sigpending); DUMMY(rt_sigtimedwait); DUMMY(rt_sigqueueinfo); DUMMY(capget); DUMMY(capset); DUMMY(sendfile); DUMMY(getpmsg); DUMMY(putpmsg); DUMMY(ugetrlimit); DUMMY(mmap2); DUMMY(truncate64); DUMMY(ftruncate64); DUMMY(stat64); DUMMY(lstat64); DUMMY(fstat64); Index: head/sys/i386/linux/linux_locore.s =================================================================== --- head/sys/i386/linux/linux_locore.s (revision 68518) +++ head/sys/i386/linux/linux_locore.s (revision 68519) @@ -1,40 +1,40 @@ /* $FreeBSD$ */ #include "linux_assym.h" /* system definitions */ -#include /* miscellaneous asm macros */ +#include /* miscellaneous asm macros */ -#include /* system call numbers */ +#include /* system call numbers */ NON_GPROF_ENTRY(linux_sigcode) call *LINUX_SIGF_HANDLER(%esp) leal LINUX_SIGF_SC(%esp),%ebx /* linux scp */ movl LINUX_SC_GS(%ebx),%gs push %eax /* fake ret addr */ movl $LINUX_SYS_linux_sigreturn,%eax /* linux_sigreturn() */ int $0x80 /* enter kernel with args */ 0: jmp 0b ALIGN_TEXT /* XXXXX */ _linux_rt_sigcode: call *LINUX_RT_SIGF_HANDLER(%esp) leal LINUX_RT_SIGF_UC(%esp),%ebx /* linux ucp */ movl LINUX_SC_GS(%ebx),%gs push %eax /* fake ret addr */ movl $LINUX_SYS_linux_rt_sigreturn,%eax /* linux_rt_sigreturn() */ int $0x80 /* enter kernel with args */ 0: jmp 0b ALIGN_TEXT /* XXXXX */ _linux_esigcode: .data .globl _linux_szsigcode, _linux_sznonrtsigcode _linux_szsigcode: .long _linux_esigcode-_linux_sigcode _linux_sznonrtsigcode: .long _linux_rt_sigcode-_linux_sigcode .text Index: head/sys/i386/linux/linux_machdep.c =================================================================== --- head/sys/i386/linux/linux_machdep.c (revision 68518) +++ head/sys/i386/linux/linux_machdep.c (revision 68519) @@ -1,694 +1,693 @@ /*- * Copyright (c) 2000 Marcel Moolenaar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include - #include -#include +#include #include #include #include struct linux_descriptor { unsigned int entry_number; unsigned long base_addr; unsigned int limit; unsigned int seg_32bit:1; unsigned int contents:2; unsigned int read_exec_only:1; unsigned int limit_in_pages:1; unsigned int seg_not_present:1; unsigned int useable:1; }; struct linux_select_argv { int nfds; fd_set *readfds; fd_set *writefds; fd_set *exceptfds; struct timeval *timeout; }; int linux_to_bsd_sigaltstack(int lsa) { int bsa = 0; if (lsa & LINUX_SS_DISABLE) bsa |= SS_DISABLE; if (lsa & LINUX_SS_ONSTACK) bsa |= SS_ONSTACK; if (lsa == LINUX_SS_ONSTACK_BC) bsa = SS_ONSTACK; return (bsa); } int bsd_to_linux_sigaltstack(int bsa) { int lsa = 0; if (bsa & SS_DISABLE) lsa |= LINUX_SS_DISABLE; if (bsa & SS_ONSTACK) lsa |= LINUX_SS_ONSTACK; return (lsa); } int linux_execve(struct proc *p, struct linux_execve_args *args) { struct execve_args bsd; caddr_t sg; sg = stackgap_init(); CHECKALTEXIST(p, &sg, args->path); #ifdef DEBUG printf("Linux-emul(%d): execve(%s)\n", p->p_pid, args->path); #endif bsd.fname = args->path; bsd.argv = args->argp; bsd.envv = args->envp; return (execve(p, &bsd)); } int linux_ipc(struct proc *p, struct linux_ipc_args *args) { switch (args->what) { case LINUX_SEMOP: return (linux_semop(p, args)); case LINUX_SEMGET: return (linux_semget(p, args)); case LINUX_SEMCTL: return (linux_semctl(p, args)); case LINUX_MSGSND: return (linux_msgsnd(p, args)); case LINUX_MSGRCV: return (linux_msgrcv(p, args)); case LINUX_MSGGET: return (linux_msgget(p, args)); case LINUX_MSGCTL: return (linux_msgctl(p, args)); case LINUX_SHMAT: return (linux_shmat(p, args)); case LINUX_SHMDT: return (linux_shmdt(p, args)); case LINUX_SHMGET: return (linux_shmget(p, args)); case LINUX_SHMCTL: return (linux_shmctl(p, args)); } uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what); return (ENOSYS); } int linux_select(struct proc *p, struct linux_select_args *args) { struct linux_select_argv linux_args; struct linux_newselect_args newsel; int error; #ifdef SELECT_DEBUG printf("Linux-emul(%ld): select(%x)\n", (long)p->p_pid, args->ptr); #endif error = copyin(args->ptr, &linux_args, sizeof(linux_args)); if (error) return (error); newsel.nfds = linux_args.nfds; newsel.readfds = linux_args.readfds; newsel.writefds = linux_args.writefds; newsel.exceptfds = linux_args.exceptfds; newsel.timeout = linux_args.timeout; return (linux_newselect(p, &newsel)); } int linux_fork(struct proc *p, struct linux_fork_args *args) { int error; #ifdef DEBUG printf("Linux-emul(%ld): fork()\n", (long)p->p_pid); #endif if ((error = fork(p, (struct fork_args *)args)) != 0) return (error); if (p->p_retval[1] == 1) p->p_retval[0] = 0; return (0); } int linux_vfork(struct proc *p, struct linux_vfork_args *args) { int error; #ifdef DEBUG printf("Linux-emul(%ld): vfork()\n", (long)p->p_pid); #endif if ((error = vfork(p, (struct vfork_args *)args)) != 0) return (error); /* Are we the child? */ if (p->p_retval[1] == 1) p->p_retval[0] = 0; return (0); } #define CLONE_VM 0x100 #define CLONE_FS 0x200 #define CLONE_FILES 0x400 #define CLONE_SIGHAND 0x800 #define CLONE_PID 0x1000 int linux_clone(struct proc *p, struct linux_clone_args *args) { int error, ff = RFPROC; struct proc *p2; int exit_signal; vm_offset_t start; struct rfork_args rf_args; #ifdef DEBUG if (args->flags & CLONE_PID) printf("linux_clone(%ld): CLONE_PID not yet supported\n", (long)p->p_pid); printf("linux_clone(%ld): invoked with flags %x and stack %x\n", (long)p->p_pid, (unsigned int)args->flags, (unsigned int)args->stack); #endif if (!args->stack) return (EINVAL); exit_signal = args->flags & 0x000000ff; if (exit_signal >= LINUX_NSIG) return (EINVAL); if (exit_signal <= LINUX_SIGTBLSZ) exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)]; /* RFTHREAD probably not necessary here, but it shouldn't hurt */ ff |= RFTHREAD; if (args->flags & CLONE_VM) ff |= RFMEM; if (args->flags & CLONE_SIGHAND) ff |= RFSIGSHARE; if (!(args->flags & CLONE_FILES)) ff |= RFFDG; error = 0; start = 0; rf_args.flags = ff; if ((error = rfork(p, &rf_args)) != 0) return (error); p2 = pfind(p->p_retval[0]); if (p2 == 0) return (ESRCH); p2->p_sigparent = exit_signal; p2->p_md.md_regs->tf_esp = (unsigned int)args->stack; #ifdef DEBUG printf ("linux_clone(%ld): successful rfork to %ld\n", (long)p->p_pid, (long)p2->p_pid); #endif return (0); } /* XXX move */ struct linux_mmap_argv { linux_caddr_t addr; int len; int prot; int flags; int fd; int pos; }; #define STACK_SIZE (2 * 1024 * 1024) #define GUARD_SIZE (4 * PAGE_SIZE) int linux_mmap(struct proc *p, struct linux_mmap_args *args) { struct mmap_args /* { caddr_t addr; size_t len; int prot; int flags; int fd; long pad; off_t pos; } */ bsd_args; int error; struct linux_mmap_argv linux_args; error = copyin(args->ptr, &linux_args, sizeof(linux_args)); if (error) return (error); #ifdef DEBUG printf("Linux-emul(%ld): mmap(%p, %d, %d, 0x%08x, %d, %d)", (long)p->p_pid, (void *)linux_args.addr, linux_args.len, linux_args.prot, linux_args.flags, linux_args.fd, linux_args.pos); #endif bsd_args.flags = 0; if (linux_args.flags & LINUX_MAP_SHARED) bsd_args.flags |= MAP_SHARED; if (linux_args.flags & LINUX_MAP_PRIVATE) bsd_args.flags |= MAP_PRIVATE; if (linux_args.flags & LINUX_MAP_FIXED) bsd_args.flags |= MAP_FIXED; if (linux_args.flags & LINUX_MAP_ANON) bsd_args.flags |= MAP_ANON; if (linux_args.flags & LINUX_MAP_GROWSDOWN) { bsd_args.flags |= MAP_STACK; /* The linux MAP_GROWSDOWN option does not limit auto * growth of the region. Linux mmap with this option * takes as addr the inital BOS, and as len, the initial * region size. It can then grow down from addr without * limit. However, linux threads has an implicit internal * limit to stack size of STACK_SIZE. Its just not * enforced explicitly in linux. But, here we impose * a limit of (STACK_SIZE - GUARD_SIZE) on the stack * region, since we can do this with our mmap. * * Our mmap with MAP_STACK takes addr as the maximum * downsize limit on BOS, and as len the max size of * the region. It them maps the top SGROWSIZ bytes, * and autgrows the region down, up to the limit * in addr. * * If we don't use the MAP_STACK option, the effect * of this code is to allocate a stack region of a * fixed size of (STACK_SIZE - GUARD_SIZE). */ /* This gives us TOS */ bsd_args.addr = linux_args.addr + linux_args.len; if (bsd_args.addr > p->p_vmspace->vm_maxsaddr) { /* Some linux apps will attempt to mmap * thread stacks near the top of their * address space. If their TOS is greater * than vm_maxsaddr, vm_map_growstack() * will confuse the thread stack with the * process stack and deliver a SEGV if they * attempt to grow the thread stack past their * current stacksize rlimit. To avoid this, * adjust vm_maxsaddr upwards to reflect * the current stacksize rlimit rather * than the maximum possible stacksize. * It would be better to adjust the * mmap'ed region, but some apps do not check * mmap's return value. */ p->p_vmspace->vm_maxsaddr = (char *)USRSTACK - p->p_rlimit[RLIMIT_STACK].rlim_cur; } /* This gives us our maximum stack size */ if (linux_args.len > STACK_SIZE - GUARD_SIZE) bsd_args.len = linux_args.len; else bsd_args.len = STACK_SIZE - GUARD_SIZE; /* This gives us a new BOS. If we're using VM_STACK, then * mmap will just map the top SGROWSIZ bytes, and let * the stack grow down to the limit at BOS. If we're * not using VM_STACK we map the full stack, since we * don't have a way to autogrow it. */ bsd_args.addr -= bsd_args.len; } else { bsd_args.addr = linux_args.addr; bsd_args.len = linux_args.len; } bsd_args.prot = linux_args.prot | PROT_READ; /* always required */ if (linux_args.flags & LINUX_MAP_ANON) bsd_args.fd = -1; else bsd_args.fd = linux_args.fd; bsd_args.pos = linux_args.pos; bsd_args.pad = 0; #ifdef DEBUG printf("-> (%p, %d, %d, 0x%08x, %d, %d)\n", (void *)bsd_args.addr, bsd_args.len, bsd_args.prot, bsd_args.flags, bsd_args.fd, (int)bsd_args.pos); #endif return (mmap(p, &bsd_args)); } int linux_pipe(struct proc *p, struct linux_pipe_args *args) { int error; int reg_edx; #ifdef DEBUG printf("Linux-emul(%ld): pipe(*)\n", (long)p->p_pid); #endif reg_edx = p->p_retval[1]; error = pipe(p, 0); if (error) { p->p_retval[1] = reg_edx; return (error); } error = copyout(p->p_retval, args->pipefds, 2*sizeof(int)); if (error) { p->p_retval[1] = reg_edx; return (error); } p->p_retval[1] = reg_edx; p->p_retval[0] = 0; return (0); } int linux_ioperm(struct proc *p, struct linux_ioperm_args *args) { struct sysarch_args sa; struct i386_ioperm_args *iia; caddr_t sg; sg = stackgap_init(); iia = stackgap_alloc(&sg, sizeof(struct i386_ioperm_args)); iia->start = args->start; iia->length = args->length; iia->enable = args->enable; sa.op = I386_SET_IOPERM; sa.parms = (char *)iia; return (sysarch(p, &sa)); } int linux_iopl(struct proc *p, struct linux_iopl_args *args) { int error; if (args->level < 0 || args->level > 3) return (EINVAL); if ((error = suser(p)) != 0) return (error); if (securelevel > 0) return (EPERM); p->p_md.md_regs->tf_eflags = (p->p_md.md_regs->tf_eflags & ~PSL_IOPL) | (args->level * (PSL_IOPL / 3)); return (0); } int linux_modify_ldt(p, uap) struct proc *p; struct linux_modify_ldt_args *uap; { int error; caddr_t sg; struct sysarch_args args; struct i386_ldt_args *ldt; struct linux_descriptor ld; union descriptor *desc; sg = stackgap_init(); if (uap->ptr == NULL) return (EINVAL); switch (uap->func) { case 0x00: /* read_ldt */ ldt = stackgap_alloc(&sg, sizeof(*ldt)); ldt->start = 0; ldt->descs = uap->ptr; ldt->num = uap->bytecount / sizeof(union descriptor); args.op = I386_GET_LDT; args.parms = (char*)ldt; error = sysarch(p, &args); p->p_retval[0] *= sizeof(union descriptor); break; case 0x01: /* write_ldt */ case 0x11: /* write_ldt */ if (uap->bytecount != sizeof(ld)) return (EINVAL); error = copyin(uap->ptr, &ld, sizeof(ld)); if (error) return (error); ldt = stackgap_alloc(&sg, sizeof(*ldt)); desc = stackgap_alloc(&sg, sizeof(*desc)); ldt->start = ld.entry_number; ldt->descs = desc; ldt->num = 1; desc->sd.sd_lolimit = (ld.limit & 0x0000ffff); desc->sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16; desc->sd.sd_lobase = (ld.base_addr & 0x00ffffff); desc->sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24; desc->sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) | (ld.contents << 2); desc->sd.sd_dpl = 3; desc->sd.sd_p = (ld.seg_not_present ^ 1); desc->sd.sd_xx = 0; desc->sd.sd_def32 = ld.seg_32bit; desc->sd.sd_gran = ld.limit_in_pages; args.op = I386_SET_LDT; args.parms = (char*)ldt; error = sysarch(p, &args); break; default: error = EINVAL; break; } if (error == EOPNOTSUPP) { printf("linux: modify_ldt needs kernel option USER_LDT\n"); error = ENOSYS; } return (error); } int linux_sigaction(struct proc *p, struct linux_sigaction_args *args) { linux_osigaction_t osa; linux_sigaction_t act, oact; int error; #ifdef DEBUG printf("Linux-emul(%ld): sigaction(%d, %p, %p)\n", (long)p->p_pid, args->sig, (void *)args->nsa, (void *)args->osa); #endif if (args->nsa != NULL) { error = copyin(args->nsa, &osa, sizeof(linux_osigaction_t)); if (error) return (error); act.lsa_handler = osa.lsa_handler; act.lsa_flags = osa.lsa_flags; act.lsa_restorer = osa.lsa_restorer; LINUX_SIGEMPTYSET(act.lsa_mask); act.lsa_mask.__bits[0] = osa.lsa_mask; } error = linux_do_sigaction(p, args->sig, args->nsa ? &act : NULL, args->osa ? &oact : NULL); if (args->osa != NULL && !error) { osa.lsa_handler = oact.lsa_handler; osa.lsa_flags = oact.lsa_flags; osa.lsa_restorer = oact.lsa_restorer; osa.lsa_mask = oact.lsa_mask.__bits[0]; error = copyout(&osa, args->osa, sizeof(linux_osigaction_t)); } return (error); } /* * Linux has two extra args, restart and oldmask. We dont use these, * but it seems that "restart" is actually a context pointer that * enables the signal to happen with a different register set. */ int linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args) { struct sigsuspend_args bsd; sigset_t *sigmask; linux_sigset_t mask; caddr_t sg = stackgap_init(); #ifdef DEBUG printf("Linux-emul(%ld): sigsuspend(%08lx)\n", (long)p->p_pid, (unsigned long)args->mask); #endif sigmask = stackgap_alloc(&sg, sizeof(sigset_t)); LINUX_SIGEMPTYSET(mask); mask.__bits[0] = args->mask; linux_to_bsd_sigset(&mask, sigmask); bsd.sigmask = sigmask; return (sigsuspend(p, &bsd)); } int linux_rt_sigsuspend(p, uap) struct proc *p; struct linux_rt_sigsuspend_args *uap; { linux_sigset_t lmask; sigset_t *bmask; struct sigsuspend_args bsd; caddr_t sg = stackgap_init(); int error; #ifdef DEBUG printf("Linux-emul(%ld): rt_sigsuspend(%p, %d)\n", (long)p->p_pid, (void *)uap->newset, uap->sigsetsize); #endif if (uap->sigsetsize != sizeof(linux_sigset_t)) return (EINVAL); error = copyin(uap->newset, &lmask, sizeof(linux_sigset_t)); if (error) return (error); bmask = stackgap_alloc(&sg, sizeof(sigset_t)); linux_to_bsd_sigset(&lmask, bmask); bsd.sigmask = bmask; return (sigsuspend(p, &bsd)); } int linux_pause(struct proc *p, struct linux_pause_args *args) { struct sigsuspend_args bsd; sigset_t *sigmask; caddr_t sg = stackgap_init(); #ifdef DEBUG printf("Linux-emul(%d): pause()\n", p->p_pid); #endif sigmask = stackgap_alloc(&sg, sizeof(sigset_t)); *sigmask = p->p_sigmask; bsd.sigmask = sigmask; return (sigsuspend(p, &bsd)); } int linux_sigaltstack(p, uap) struct proc *p; struct linux_sigaltstack_args *uap; { struct sigaltstack_args bsd; stack_t *ss, *oss; linux_stack_t lss; int error; caddr_t sg = stackgap_init(); #ifdef DEBUG printf("Linux-emul(%ld): sigaltstack(%p, %p)\n", (long)p->p_pid, uap->uss, uap->uoss); #endif if (uap->uss == NULL) { ss = NULL; } else { error = copyin(uap->uss, &lss, sizeof(linux_stack_t)); if (error) return (error); ss = stackgap_alloc(&sg, sizeof(stack_t)); ss->ss_sp = lss.ss_sp; ss->ss_size = (lss.ss_size >= LINUX_MINSIGSTKSZ && lss.ss_size < MINSIGSTKSZ) ? MINSIGSTKSZ : lss.ss_size; ss->ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags); } oss = (uap->uoss != NULL) ? stackgap_alloc(&sg, sizeof(stack_t)) : NULL; bsd.ss = ss; bsd.oss = oss; error = sigaltstack(p, &bsd); if (!error && oss != NULL) { lss.ss_sp = oss->ss_sp; lss.ss_size = oss->ss_size; lss.ss_flags = bsd_to_linux_sigaltstack(oss->ss_flags); error = copyout(&lss, uap->uoss, sizeof(linux_stack_t)); } if (!error && (ss != NULL) && (lss.ss_size < ss->ss_size)) p->p_sigstk.ss_size = lss.ss_size; return (error); } Index: head/sys/i386/linux/linux_sysvec.c =================================================================== --- head/sys/i386/linux/linux_sysvec.c (revision 68518) +++ head/sys/i386/linux/linux_sysvec.c (revision 68519) @@ -1,821 +1,821 @@ /*- * Copyright (c) 1994-1996 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 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. The name of the author may not be used to endorse or promote products * derived from this software withough specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ /* XXX we use functions that might not exist. */ #include "opt_compat.h" #ifndef COMPAT_43 #error "Unable to compile Linux-emulator due to missing COMPAT_43 option!" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include -#include +#include #include MODULE_VERSION(linux, 1); MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures"); #if BYTE_ORDER == LITTLE_ENDIAN #define SHELLMAGIC 0x2123 /* #! */ #else #define SHELLMAGIC 0x2321 #endif extern char linux_sigcode[]; extern int linux_szsigcode; extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL]; extern struct linker_set linux_ioctl_handler_set; static int linux_fixup __P((register_t **stack_base, struct image_params *iparams)); static int elf_linux_fixup __P((register_t **stack_base, struct image_params *iparams)); static void linux_prepsyscall __P((struct trapframe *tf, int *args, u_int *code, caddr_t *params)); static void linux_sendsig __P((sig_t catcher, int sig, sigset_t *mask, u_long code)); /* * Linux syscalls return negative errno's, we do positive and map them */ static int bsd_to_linux_errno[ELAST + 1] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, -6, -6, -43, -42, -75, -6, -84 }; int bsd_to_linux_signal[LINUX_SIGTBLSZ] = { LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL, LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE, LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, 0, LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG, LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD, LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU, LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH, 0, LINUX_SIGUSR1, LINUX_SIGUSR2 }; int linux_to_bsd_signal[LINUX_SIGTBLSZ] = { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT, SIGBUS, SIGFPE, SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2, SIGPIPE, SIGALRM, SIGTERM, SIGBUS, SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGIO, SIGURG, 0 }; /* * If FreeBSD & Linux have a difference of opinion about what a trap * means, deal with it here. */ static int translate_traps(int signal, int trap_code) { if (signal != SIGBUS) return signal; switch (trap_code) { case T_PROTFLT: case T_TSSFLT: case T_DOUBLEFLT: case T_PAGEFLT: return SIGSEGV; default: return signal; } } static int linux_fixup(register_t **stack_base, struct image_params *imgp) { register_t *argv, *envp; argv = *stack_base; envp = *stack_base + (imgp->argc + 1); (*stack_base)--; **stack_base = (intptr_t)(void *)envp; (*stack_base)--; **stack_base = (intptr_t)(void *)argv; (*stack_base)--; **stack_base = imgp->argc; return 0; } static int elf_linux_fixup(register_t **stack_base, struct image_params *imgp) { Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs; register_t *pos; pos = *stack_base + (imgp->argc + imgp->envc + 2); if (args->trace) { AUXARGS_ENTRY(pos, AT_DEBUG, 1); } if (args->execfd != -1) { AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd); } AUXARGS_ENTRY(pos, AT_PHDR, args->phdr); AUXARGS_ENTRY(pos, AT_PHENT, args->phent); AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum); AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz); AUXARGS_ENTRY(pos, AT_FLAGS, args->flags); AUXARGS_ENTRY(pos, AT_ENTRY, args->entry); AUXARGS_ENTRY(pos, AT_BASE, args->base); AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_cred->p_ruid); AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_cred->p_svuid); AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_cred->p_rgid); AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_cred->p_svgid); AUXARGS_ENTRY(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); imgp->auxargs = NULL; (*stack_base)--; **stack_base = (long)imgp->argc; return 0; } extern int _ucodesel, _udatasel; extern unsigned long _linux_sznonrtsigcode; static void linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) { register struct proc *p = curproc; register struct trapframe *regs; struct linux_rt_sigframe *fp, frame; struct sigacts *psp = p->p_sigacts; int oonstack; regs = p->p_md.md_regs; oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; #ifdef DEBUG printf("Linux-emul(%ld): linux_rt_sendsig(%p, %d, %p, %lu)\n", (long)p->p_pid, catcher, sig, (void*)mask, code); #endif /* * Allocate space for the signal handler context. */ if ((p->p_flag & P_ALTSTACK) && !oonstack && SIGISMEMBER(psp->ps_sigonstack, sig)) { fp = (struct linux_rt_sigframe *)(p->p_sigstk.ss_sp + p->p_sigstk.ss_size - sizeof(struct linux_rt_sigframe)); p->p_sigstk.ss_flags |= SS_ONSTACK; } else { fp = (struct linux_rt_sigframe *)regs->tf_esp - 1; } /* * grow() will return FALSE if the fp will not fit inside the stack * and the stack can not be grown. useracc will return FALSE * if access is denied. */ if ((grow_stack (p, (int)fp) == FALSE) || !useracc((caddr_t)fp, sizeof (struct linux_rt_sigframe), VM_PROT_WRITE)) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ SIGACTION(p, SIGILL) = SIG_DFL; SIGDELSET(p->p_sigignore, SIGILL); SIGDELSET(p->p_sigcatch, SIGILL); SIGDELSET(p->p_sigmask, SIGILL); #ifdef DEBUG printf("Linux-emul(%ld): linux_rt_sendsig -- bad stack %p, SS_ONSTACK: 0x%x ", (long)p->p_pid, fp, p->p_sigstk.ss_flags & SS_ONSTACK); #endif psignal(p, SIGILL); return; } /* * Build the argument list for the signal handler. */ if (p->p_sysent->sv_sigtbl) if (sig <= p->p_sysent->sv_sigsize) sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; frame.sf_handler = catcher; frame.sf_sig = sig; frame.sf_siginfo = &fp->sf_si; frame.sf_ucontext = &fp->sf_sc; /* Fill siginfo structure. */ frame.sf_si.lsi_signo = sig; frame.sf_si.lsi_code = code; frame.sf_si.lsi_addr = (void *)regs->tf_err; /* * Build the signal context to be used by sigreturn. */ frame.sf_sc.uc_mcontext.sc_mask = mask->__bits[0]; frame.sf_sc.uc_mcontext.sc_gs = rgs(); frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs; frame.sf_sc.uc_mcontext.sc_es = regs->tf_es; frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds; frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi; frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi; frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp; frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx; frame.sf_sc.uc_mcontext.sc_edx = regs->tf_edx; frame.sf_sc.uc_mcontext.sc_ecx = regs->tf_ecx; frame.sf_sc.uc_mcontext.sc_eax = regs->tf_eax; frame.sf_sc.uc_mcontext.sc_eip = regs->tf_eip; frame.sf_sc.uc_mcontext.sc_cs = regs->tf_cs; frame.sf_sc.uc_mcontext.sc_eflags = regs->tf_eflags; frame.sf_sc.uc_mcontext.sc_esp_at_signal = regs->tf_esp; frame.sf_sc.uc_mcontext.sc_ss = regs->tf_ss; frame.sf_sc.uc_mcontext.sc_err = regs->tf_err; frame.sf_sc.uc_mcontext.sc_trapno = code; /* XXX ???? */ /* * Build the remainder of the ucontext struct to be used by sigreturn. */ frame.sf_sc.uc_flags = 0; /* XXX ??? */ frame.sf_sc.uc_link = NULL; /* XXX ??? */ frame.sf_sc.uc_stack.ss_sp = p->p_sigstk.ss_sp; frame.sf_sc.uc_stack.ss_flags = bsd_to_linux_sigaltstack(p->p_sigstk.ss_flags); frame.sf_sc.uc_stack.ss_size = p->p_sigstk.ss_size; #ifdef DEBUG printf("Linux-emul(%ld): rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x\n", (long)p->p_pid, frame.sf_sc.uc_stack.ss_flags, p->p_sigstk.ss_sp, p->p_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask); #endif bsd_to_linux_sigset(&p->p_sigmask, &frame.sf_sc.uc_sigmask); if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(p, SIGILL); /* NOTREACHED */ } /* * Build context to run handler in. */ regs->tf_esp = (int)fp; regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode) + _linux_sznonrtsigcode; regs->tf_eflags &= ~PSL_VM; regs->tf_cs = _ucodesel; regs->tf_ds = _udatasel; regs->tf_es = _udatasel; regs->tf_fs = _udatasel; load_gs(_udatasel); regs->tf_ss = _udatasel; } /* * Send an interrupt to process. * * Stack is set up to allow sigcode stored * in u. to call routine, followed by kcall * to sigreturn routine below. After sigreturn * resets the signal mask, the stack, and the * frame pointer, it returns to the user * specified pc, psl. */ static void linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) { register struct proc *p = curproc; register struct trapframe *regs; struct linux_sigframe *fp, frame; struct sigacts *psp = p->p_sigacts; int oonstack; regs = p->p_md.md_regs; oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; #ifdef DEBUG printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n", (long)p->p_pid, catcher, sig, (void*)mask, code); #endif if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) { /* Signal handler installed with SA_SIGINFO. */ linux_rt_sendsig(catcher, sig, mask, code); return; } /* * Allocate space for the signal handler context. */ if ((p->p_flag & P_ALTSTACK) && !oonstack && SIGISMEMBER(psp->ps_sigonstack, sig)) { fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp + p->p_sigstk.ss_size - sizeof(struct linux_sigframe)); p->p_sigstk.ss_flags |= SS_ONSTACK; } else { fp = (struct linux_sigframe *)regs->tf_esp - 1; } /* * grow() will return FALSE if the fp will not fit inside the stack * and the stack can not be grown. useracc will return FALSE * if access is denied. */ if ((grow_stack (p, (int)fp) == FALSE) || !useracc((caddr_t)fp, sizeof (struct linux_sigframe), VM_PROT_WRITE)) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ SIGACTION(p, SIGILL) = SIG_DFL; SIGDELSET(p->p_sigignore, SIGILL); SIGDELSET(p->p_sigcatch, SIGILL); SIGDELSET(p->p_sigmask, SIGILL); psignal(p, SIGILL); return; } /* * Build the argument list for the signal handler. */ if (p->p_sysent->sv_sigtbl) if (sig <= p->p_sysent->sv_sigsize) sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; frame.sf_handler = catcher; frame.sf_sig = sig; /* * Build the signal context to be used by sigreturn. */ frame.sf_sc.sc_mask = mask->__bits[0]; frame.sf_sc.sc_gs = rgs(); frame.sf_sc.sc_fs = regs->tf_fs; frame.sf_sc.sc_es = regs->tf_es; frame.sf_sc.sc_ds = regs->tf_ds; frame.sf_sc.sc_edi = regs->tf_edi; frame.sf_sc.sc_esi = regs->tf_esi; frame.sf_sc.sc_ebp = regs->tf_ebp; frame.sf_sc.sc_ebx = regs->tf_ebx; frame.sf_sc.sc_edx = regs->tf_edx; frame.sf_sc.sc_ecx = regs->tf_ecx; frame.sf_sc.sc_eax = regs->tf_eax; frame.sf_sc.sc_eip = regs->tf_eip; frame.sf_sc.sc_cs = regs->tf_cs; frame.sf_sc.sc_eflags = regs->tf_eflags; frame.sf_sc.sc_esp_at_signal = regs->tf_esp; frame.sf_sc.sc_ss = regs->tf_ss; frame.sf_sc.sc_err = regs->tf_err; frame.sf_sc.sc_trapno = code; /* XXX ???? */ if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(p, SIGILL); /* NOTREACHED */ } /* * Build context to run handler in. */ regs->tf_esp = (int)fp; regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode); regs->tf_eflags &= ~PSL_VM; regs->tf_cs = _ucodesel; regs->tf_ds = _udatasel; regs->tf_es = _udatasel; regs->tf_fs = _udatasel; load_gs(_udatasel); regs->tf_ss = _udatasel; } /* * System call to cleanup state after a signal * has been taken. Reset signal mask and * stack state from context left by sendsig (above). * Return to previous pc and psl as specified by * context left by sendsig. Check carefully to * make sure that the user has not modified the * psl to gain improper privileges or to cause * a machine fault. */ int linux_sigreturn(p, args) struct proc *p; struct linux_sigreturn_args *args; { struct linux_sigcontext context; register struct trapframe *regs; int eflags; regs = p->p_md.md_regs; #ifdef DEBUG printf("Linux-emul(%ld): linux_sigreturn(%p)\n", (long)p->p_pid, (void *)args->scp); #endif /* * The trampoline code hands us the context. * It is unsafe to keep track of it ourselves, in the event that a * program jumps out of a signal handler. */ if (copyin((caddr_t)args->scp, &context, sizeof(context)) != 0) return (EFAULT); /* * Check for security violations. */ #define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) eflags = context.sc_eflags; /* * XXX do allow users to change the privileged flag PSL_RF. The * cpu sets PSL_RF in tf_eflags for faults. Debuggers should * sometimes set it there too. tf_eflags is kept in the signal * context during signal handling and there is no other place * to remember it, so the PSL_RF bit may be corrupted by the * signal handler without us knowing. Corruption of the PSL_RF * bit at worst causes one more or one less debugger trap, so * allowing it is fairly harmless. */ if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { return(EINVAL); } /* * Don't allow users to load a valid privileged %cs. Let the * hardware check for invalid selectors, excess privilege in * other selectors, invalid %eip's and invalid %esp's. */ #define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) if (!CS_SECURE(context.sc_cs)) { trapsignal(p, SIGBUS, T_PROTFLT); return(EINVAL); } p->p_sigstk.ss_flags &= ~SS_ONSTACK; SIGSETOLD(p->p_sigmask, context.sc_mask); SIG_CANTMASK(p->p_sigmask); /* * Restore signal context. */ /* %gs was restored by the trampoline. */ regs->tf_fs = context.sc_fs; regs->tf_es = context.sc_es; regs->tf_ds = context.sc_ds; regs->tf_edi = context.sc_edi; regs->tf_esi = context.sc_esi; regs->tf_ebp = context.sc_ebp; regs->tf_ebx = context.sc_ebx; regs->tf_edx = context.sc_edx; regs->tf_ecx = context.sc_ecx; regs->tf_eax = context.sc_eax; regs->tf_eip = context.sc_eip; regs->tf_cs = context.sc_cs; regs->tf_eflags = eflags; regs->tf_esp = context.sc_esp_at_signal; regs->tf_ss = context.sc_ss; return (EJUSTRETURN); } /* * System call to cleanup state after a signal * has been taken. Reset signal mask and * stack state from context left by rt_sendsig (above). * Return to previous pc and psl as specified by * context left by sendsig. Check carefully to * make sure that the user has not modified the * psl to gain improper privileges or to cause * a machine fault. */ int linux_rt_sigreturn(p, args) struct proc *p; struct linux_rt_sigreturn_args *args; { struct sigaltstack_args sasargs; struct linux_ucontext uc; struct linux_sigcontext *context; linux_stack_t *lss; stack_t *ss; register struct trapframe *regs; int eflags; caddr_t sg = stackgap_init(); regs = p->p_md.md_regs; #ifdef DEBUG printf("Linux-emul(%ld): linux_rt_sigreturn(%p)\n", (long)p->p_pid, (void *)args->ucp); #endif /* * The trampoline code hands us the u_context. * It is unsafe to keep track of it ourselves, in the event that a * program jumps out of a signal handler. */ if (copyin((caddr_t)args->ucp, &uc, sizeof(uc)) != 0) return (EFAULT); context = &uc.uc_mcontext; /* * Check for security violations. */ #define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) eflags = context->sc_eflags; /* * XXX do allow users to change the privileged flag PSL_RF. The * cpu sets PSL_RF in tf_eflags for faults. Debuggers should * sometimes set it there too. tf_eflags is kept in the signal * context during signal handling and there is no other place * to remember it, so the PSL_RF bit may be corrupted by the * signal handler without us knowing. Corruption of the PSL_RF * bit at worst causes one more or one less debugger trap, so * allowing it is fairly harmless. */ if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { return(EINVAL); } /* * Don't allow users to load a valid privileged %cs. Let the * hardware check for invalid selectors, excess privilege in * other selectors, invalid %eip's and invalid %esp's. */ #define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) if (!CS_SECURE(context->sc_cs)) { trapsignal(p, SIGBUS, T_PROTFLT); return(EINVAL); } p->p_sigstk.ss_flags &= ~SS_ONSTACK; SIGSETOLD(p->p_sigmask, context->sc_mask); SIG_CANTMASK(p->p_sigmask); /* * Restore signal context-> */ /* %gs was restored by the trampoline. */ regs->tf_fs = context->sc_fs; regs->tf_es = context->sc_es; regs->tf_ds = context->sc_ds; regs->tf_edi = context->sc_edi; regs->tf_esi = context->sc_esi; regs->tf_ebp = context->sc_ebp; regs->tf_ebx = context->sc_ebx; regs->tf_edx = context->sc_edx; regs->tf_ecx = context->sc_ecx; regs->tf_eax = context->sc_eax; regs->tf_eip = context->sc_eip; regs->tf_cs = context->sc_cs; regs->tf_eflags = eflags; regs->tf_esp = context->sc_esp_at_signal; regs->tf_ss = context->sc_ss; /* * call sigaltstack & ignore results.. */ ss = stackgap_alloc(&sg, sizeof(stack_t)); lss = &uc.uc_stack; ss->ss_sp = lss->ss_sp; ss->ss_size = (lss->ss_size >= LINUX_MINSIGSTKSZ && lss->ss_size < MINSIGSTKSZ) ? MINSIGSTKSZ : lss->ss_size; ss->ss_flags = linux_to_bsd_sigaltstack(lss->ss_flags); #ifdef DEBUG printf("Linux-emul(%ld): rt_sigret flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x\n", (long)p->p_pid, ss->ss_flags, ss->ss_sp, ss->ss_size, context->sc_mask); #endif sasargs.ss = ss; sasargs.oss = NULL; (void) sigaltstack(p, &sasargs); return (EJUSTRETURN); } static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params) { args[0] = tf->tf_ebx; args[1] = tf->tf_ecx; args[2] = tf->tf_edx; args[3] = tf->tf_esi; args[4] = tf->tf_edi; *params = NULL; /* no copyin */ } /* * If a linux binary is exec'ing something, try this image activator * first. We override standard shell script execution in order to * be able to modify the interpreter path. We only do this if a linux * binary is doing the exec, so we do not create an EXEC module for it. */ static int exec_linux_imgact_try __P((struct image_params *iparams)); static int exec_linux_imgact_try(imgp) struct image_params *imgp; { const char *head = (const char *)imgp->image_header; int error = -1; /* * The interpreter for shell scripts run from a linux binary needs * to be located in /compat/linux if possible in order to recursively * maintain linux path emulation. */ if (((const short *)head)[0] == SHELLMAGIC) { /* * Run our normal shell image activator. If it succeeds attempt * to use the alternate path for the interpreter. If an alternate * path is found, use our stringspace to store it. */ if ((error = exec_shell_imgact(imgp)) == 0) { char *rpath = NULL; linux_emul_find(imgp->proc, NULL, linux_emul_path, imgp->interpreter_name, &rpath, 0); if (rpath != imgp->interpreter_name) { int len = strlen(rpath) + 1; if (len <= MAXSHELLCMDLEN) { memcpy(imgp->interpreter_name, rpath, len); } free(rpath, M_TEMP); } } } return(error); } struct sysentvec linux_sysvec = { LINUX_SYS_MAXSYSCALL, linux_sysent, 0xff, LINUX_SIGTBLSZ, bsd_to_linux_signal, ELAST + 1, bsd_to_linux_errno, translate_traps, linux_fixup, linux_sendsig, linux_sigcode, &linux_szsigcode, linux_prepsyscall, "Linux a.out", aout_coredump, exec_linux_imgact_try }; struct sysentvec elf_linux_sysvec = { LINUX_SYS_MAXSYSCALL, linux_sysent, 0xff, LINUX_SIGTBLSZ, bsd_to_linux_signal, ELAST + 1, bsd_to_linux_errno, translate_traps, elf_linux_fixup, linux_sendsig, linux_sigcode, &linux_szsigcode, linux_prepsyscall, "Linux ELF", elf_coredump, exec_linux_imgact_try }; static Elf32_Brandinfo linux_brand = { ELFOSABI_LINUX, "/compat/linux", "/lib/ld-linux.so.1", &elf_linux_sysvec }; static Elf32_Brandinfo linux_glibc2brand = { ELFOSABI_LINUX, "/compat/linux", "/lib/ld-linux.so.2", &elf_linux_sysvec }; Elf32_Brandinfo *linux_brandlist[] = { &linux_brand, &linux_glibc2brand, NULL }; static int linux_elf_modevent(module_t mod, int type, void *data) { Elf32_Brandinfo **brandinfo; int error; error = 0; switch(type) { case MOD_LOAD: for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; ++brandinfo) if (elf_insert_brand_entry(*brandinfo) < 0) error = EINVAL; if (error) printf("cannot insert Linux elf brand handler\n"); else { linux_ioctl_register_handlers(&linux_ioctl_handler_set); if (bootverbose) printf("Linux-ELF exec handler installed\n"); } break; case MOD_UNLOAD: linux_ioctl_unregister_handlers(&linux_ioctl_handler_set); for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; ++brandinfo) if (elf_brand_inuse(*brandinfo)) error = EBUSY; if (error == 0) { for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; ++brandinfo) if (elf_remove_brand_entry(*brandinfo) < 0) error = EINVAL; } if (error) printf("Could not deinstall ELF interpreter entry\n"); else if (bootverbose) printf("Linux-elf exec handler removed\n"); break; default: break; } return error; } static moduledata_t linux_elf_mod = { "linuxelf", linux_elf_modevent, 0 }; DECLARE_MODULE(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); Index: head/sys/i386/linux/syscalls.master =================================================================== --- head/sys/i386/linux/syscalls.master (revision 68518) +++ head/sys/i386/linux/syscalls.master (revision 68519) @@ -1,289 +1,289 @@ $FreeBSD$ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 ; System call name/number master file (or rather, slave, from LINUX). -; Processed to created linux_sysent.c, linux_syscalls.c and linux_syscall.h. +; Processed to create linux_sysent.c, linux_proto.h and linux_syscall.h. ; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments ; number system call number, must be in order ; type one of STD, OBSOL, UNIMPL, COMPAT ; namespc one of POSIX, BSD, STD, NOHIDE (I dont care :-) -Peter ; name psuedo-prototype of syscall routine ; If one of the following alts is different, then all appear: ; altname name of system call if different ; alttag name of args struct tag if different from [o]`name'"_args" ; altrtyp return type if not int (bogus - syscalls always return int) ; for UNIMPL/OBSOL, name continues with comments ; types: ; STD always included ; COMPAT included on COMPAT #ifdef ; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h ; OBSOL obsolete, not included in system, only specifies name ; UNIMPL not implemented, placeholder only #include "opt_compat.h" #include #include #include #include -#include +#include ; #ifdef's, etc. may be included, and are copied to the output files. 0 STD LINUX { int linux_setup(void); } 1 NOPROTO LINUX { void sys_exit(int rval); } exit sys_exit_args void 2 STD LINUX { int linux_fork(void); } 3 NOPROTO LINUX { int read(int fd, char *buf, u_int nbyte); } 4 NOPROTO LINUX { int write(int fd, char *buf, u_int nbyte); } 5 STD LINUX { int linux_open(char *path, int flags, int mode); } 6 NOPROTO LINUX { int close(int fd); } 7 STD LINUX { int linux_waitpid(int pid, int *status, \ int options); } 8 STD LINUX { int linux_creat(char *path, int mode); } 9 STD LINUX { int linux_link(char *path, char *to); } 10 STD LINUX { int linux_unlink(char *path); } 11 STD LINUX { int linux_execve(char *path, char **argp, \ char **envp); } 12 STD LINUX { int linux_chdir(char *path); } 13 STD LINUX { int linux_time(linux_time_t *tm); } 14 STD LINUX { int linux_mknod(char *path, int mode, int dev); } 15 STD LINUX { int linux_chmod(char *path, int mode); } 16 STD LINUX { int linux_lchown(char *path, int uid, int gid); } 17 STD LINUX { int linux_break(char *nsize); } 18 STD LINUX { int linux_stat(char *path, struct ostat *up); } 19 STD LINUX { int linux_lseek(int fdes, long off, int whence); } 20 NOPROTO LINUX { int getpid(void); } 21 STD LINUX { int linux_mount(void); } 22 STD LINUX { int linux_umount(void); } 23 NOPROTO LINUX { int setuid(uid_t uid); } 24 NOPROTO LINUX { int getuid(void); } 25 STD LINUX { int linux_stime(void); } 26 STD LINUX { int linux_ptrace(void); } 27 STD LINUX { int linux_alarm(unsigned int secs); } 28 STD LINUX { int linux_fstat(int fd, struct ostat *up); } 29 STD LINUX { int linux_pause(void); } 30 STD LINUX { int linux_utime(char *fname, \ struct linux_utimbuf *times); } 31 STD LINUX { int linux_stty(void); } 32 STD LINUX { int linux_gtty(void); } 33 STD LINUX { int linux_access(char *path, int flags); } 34 STD LINUX { int linux_nice(int inc); } 35 STD LINUX { int linux_ftime(void); } 36 NOPROTO LINUX { int sync(void); } 37 STD LINUX { int linux_kill(int pid, int signum); } 38 STD LINUX { int linux_rename(char *from, char *to); } 39 STD LINUX { int linux_mkdir(char *path, int mode); } 40 STD LINUX { int linux_rmdir(char *path); } 41 NOPROTO LINUX { int dup(u_int fd); } 42 STD LINUX { int linux_pipe(int *pipefds); } 43 STD LINUX { int linux_times(struct linux_times_argv *buf); } 44 STD LINUX { int linux_prof(void); } 45 STD LINUX { int linux_brk(char *dsend); } 46 NOPROTO LINUX { int setgid(gid_t gid); } 47 NOPROTO LINUX { int getgid(void); } 48 STD LINUX { int linux_signal(int sig, linux_handler_t handler); } 49 NOPROTO LINUX { int geteuid(void); } 50 NOPROTO LINUX { int getegid(void); } 51 NOPROTO LINUX { int acct(char *path); } 52 STD LINUX { int linux_umount2(void); } 53 STD LINUX { int linux_lock(void); } 54 STD LINUX { int linux_ioctl(int fd, u_long cmd, int arg); } 55 STD LINUX { int linux_fcntl(int fd, int cmd, int arg); } 56 STD LINUX { int linux_mpx(void); } 57 NOPROTO LINUX { int setpgid(int pid, int pgid); } 58 STD LINUX { int linux_ulimit(void); } 59 STD LINUX { int linux_olduname(void); } 60 NOPROTO LINUX { int umask(int newmask); } 61 NOPROTO LINUX { int chroot(char *path); } 62 STD LINUX { int linux_ustat(linux_dev_t dev, \ struct linux_ustat *ubuf); } 63 NOPROTO LINUX { int dup2(u_int from, u_int to); } 64 NOPROTO LINUX { int getppid(void); } 65 NOPROTO LINUX { int getpgrp(void); } 66 NOPROTO LINUX { int setsid(void); } 67 STD LINUX { int linux_sigaction(int sig, \ linux_osigaction_t *nsa, \ linux_osigaction_t *osa); } 68 STD LINUX { int linux_siggetmask(void); } 69 STD LINUX { int linux_sigsetmask(linux_osigset_t mask); } 70 NOPROTO LINUX { int setreuid(int ruid, int euid); } 71 NOPROTO LINUX { int setregid(int rgid, int egid); } 72 STD LINUX { int linux_sigsuspend(int restart, \ linux_osigset_t oldmask, \ linux_osigset_t mask); } 73 STD LINUX { int linux_sigpending(linux_osigset_t *mask); } 74 NOPROTO LINUX { int osethostname(char *hostname, u_int len); } \ osethostname sethostname_args int 75 STD LINUX { int linux_setrlimit(u_int resource, \ struct ogetrlimit *rlim); } 76 STD LINUX { int linux_getrlimit(u_int resource, \ struct ogetrlimit *rlim); } 77 NOPROTO LINUX { int getrusage(int who, struct rusage *rusage); } 78 NOPROTO LINUX { int gettimeofday(struct timeval *tp, \ struct timezone *tzp); } 79 NOPROTO LINUX { int settimeofday(struct timeval *tp, \ struct timezone *tzp); } 80 STD LINUX { int linux_getgroups(u_int gidsetsize, \ linux_gid_t *gidset); } 81 STD LINUX { int linux_setgroups(u_int gidsetsize, \ linux_gid_t *gidset); } 82 STD LINUX { int linux_select(struct linux_select_argv *ptr); } 83 STD LINUX { int linux_symlink(char *path, char *to); } 84 NOPROTO LINUX { int ostat(char *path, struct ostat *up); } 85 STD LINUX { int linux_readlink(char *name, char *buf, \ int count); } 86 STD LINUX { int linux_uselib(char *library); } 87 NOPROTO LINUX { int swapon(char *name); } 88 NOPROTO LINUX { int reboot(int opt); } 89 STD LINUX { int linux_readdir(int fd, \ struct linux_dirent *dent, \ unsigned int count); } 90 STD LINUX { int linux_mmap(struct linux_mmap_argv *ptr); } 91 NOPROTO LINUX { int munmap(caddr_t addr, int len); } 92 STD LINUX { int linux_truncate(char *path, long length); } 93 NOPROTO LINUX { int oftruncate(int fd, long length); } 94 NOPROTO LINUX { int fchmod(int fd, int mode); } 95 NOPROTO LINUX { int fchown(int fd, int uid, int gid); } 96 NOPROTO LINUX { int getpriority(int which, int who); } 97 NOPROTO LINUX { int setpriority(int which, int who, int prio); } 98 NOPROTO LINUX { int profil(caddr_t samples, u_int size, \ u_int offset, u_int scale); } 99 STD LINUX { int linux_statfs(char *path, \ struct linux_statfs_buf *buf); } 100 STD LINUX { int linux_fstatfs(int fd, \ struct linux_statfs_buf *buf); } 101 STD LINUX { int linux_ioperm(unsigned int start, \ unsigned int length, int enable); } 102 STD LINUX { int linux_socketcall(int what, void *args); } 103 STD LINUX { int linux_ksyslog(int what); } 104 STD LINUX { int linux_setitimer(u_int which, \ struct itimerval *itv, \ struct itimerval *oitv); } 105 STD LINUX { int linux_getitimer(u_int which, \ struct itimerval *itv); } 106 STD LINUX { int linux_newstat(char *path, \ struct linux_newstat *buf); } 107 STD LINUX { int linux_newlstat(char *path, \ struct linux_newstat *buf); } 108 STD LINUX { int linux_newfstat(int fd, \ struct linux_newstat *buf); } 109 STD LINUX { int linux_uname(void); } 110 STD LINUX { int linux_iopl(int level); } 111 STD LINUX { int linux_vhangup(void); } 112 STD LINUX { int linux_idle(void); } 113 STD LINUX { int linux_vm86old(void); } 114 STD LINUX { int linux_wait4(int pid, int *status, \ int options, struct rusage *rusage); } 115 STD LINUX { int linux_swapoff(void); } 116 STD LINUX { int linux_sysinfo(void); } 117 STD LINUX { int linux_ipc(int what, int arg1, int arg2, \ int arg3, caddr_t ptr); } 118 NOPROTO LINUX { int fsync(int fd); } 119 STD LINUX { int linux_sigreturn(struct linux_sigcontext *scp); } 120 STD LINUX { int linux_clone(int flags, void *stack); } 121 NOPROTO LINUX { int setdomainname(char *name, int len); } 122 STD LINUX { int linux_newuname(struct linux_new_utsname *buf); } 123 STD LINUX { int linux_modify_ldt(int func, void *ptr, \ size_t bytecount); } 124 STD LINUX { int linux_adjtimex(void); } 125 NOPROTO LINUX { int mprotect(caddr_t addr, int len, int prot); } 126 STD LINUX { int linux_sigprocmask(int how, \ linux_osigset_t *mask, \ linux_osigset_t *omask); } 127 STD LINUX { int linux_create_module(void); } 128 STD LINUX { int linux_init_module(void); } 129 STD LINUX { int linux_delete_module(void); } 130 STD LINUX { int linux_get_kernel_syms(void); } 131 STD LINUX { int linux_quotactl(void); } 132 STD LINUX { int linux_getpgid(int pid); } 133 NOPROTO LINUX { int fchdir(int fd); } 134 STD LINUX { int linux_bdflush(void); } 135 STD LINUX { int linux_sysfs(int option, u_long arg1, \ u_long arg2); } 136 STD LINUX { int linux_personality(int per); } 137 STD LINUX { int linux_afs_syscall(void); } 138 STD LINUX { int linux_setfsuid(linux_uid_t uid); } 139 STD LINUX { int linux_setfsgid(linux_gid_t gid); } 140 STD LINUX { int linux_llseek(int fd, u_int32_t ohigh, \ u_int32_t olow, caddr_t res, int whence); } 141 STD LINUX { int linux_getdents(int fd, void *dent, \ unsigned count); } 142 STD LINUX { int linux_newselect(int nfds, fd_set *readfds, \ fd_set *writefds, fd_set *exceptfds, \ struct timeval *timeout); } 143 NOPROTO LINUX { int flock(int fd, int how); } 144 STD LINUX { int linux_msync(caddr_t addr, int len, int fl); } 145 NOPROTO LINUX { int readv(int fd, struct iovec *iovp, \ u_int iovcnt); } 146 NOPROTO LINUX { int writev(int fd, struct iovec *iovp, \ u_int iovcnt); } 147 STD LINUX { int linux_getsid(linux_pid_t pid); } 148 STD LINUX { int linux_fdatasync(int fd); } 149 STD LINUX { int linux_sysctl(void); } 150 NOPROTO BSD { int mlock(const void *addr, size_t len); } 151 NOPROTO BSD { int munlock(const void *addr, size_t len); } 152 NOPROTO BSD { int mlockall(int how); } 153 NOPROTO BSD { int munlockall(void); } 154 NOPROTO POSIX { int sched_setparam (pid_t pid, \ const struct sched_param *param); } 155 NOPROTO POSIX { int sched_getparam (pid_t pid, \ struct sched_param *param); } 156 STD POSIX { int linux_sched_setscheduler(pid_t pid, int policy, \ const struct sched_param *param); } 157 STD POSIX { int linux_sched_getscheduler(pid_t pid); } 158 NOPROTO POSIX { int sched_yield (void); } 159 NOPROTO POSIX { int sched_get_priority_max (int policy); } 160 NOPROTO POSIX { int sched_get_priority_min (int policy); } 161 NOPROTO POSIX { int sched_rr_get_interval (pid_t pid, \ struct timespec *interval); } 162 NOPROTO POSIX { int nanosleep(const struct timespec *rqtp, \ struct timespec *rmtp); } 163 STD LINUX { int linux_mremap(caddr_t addr, int old_len, \ int new_len, int flags); } 164 NOPROTO LINUX { int setresuid(int ruid, int euid, int suid); } 165 STD LINUX { int linux_getresuid(linux_uid_t *ruid, \ linux_uid_t *euid, linux_uid_t *suid); } 166 STD LINUX { int linux_vm86(void); } 167 STD LINUX { int linux_query_module(void); } 168 NOPROTO LINUX { int poll(struct pollfd*, unsigned int nfds, \ long timeout); } 169 STD LINUX { int linux_nfsservctl(void); } 170 NOPROTO LINUX { int setresgid(int rgid, int egid, int sgid); } 171 STD LINUX { int linux_getresgid(linux_gid_t *rgid, \ linux_gid_t *egid, linux_gid_t *sgid); } 172 STD LINUX { int linux_prctl(void); } 173 STD LINUX { int linux_rt_sigreturn(struct linux_ucontext *ucp); } 174 STD LINUX { int linux_rt_sigaction(int sig, \ linux_sigaction_t *act, \ linux_sigaction_t *oact, \ size_t sigsetsize); } 175 STD LINUX { int linux_rt_sigprocmask(int how, \ linux_sigset_t *mask, linux_sigset_t *omask, \ size_t sigsetsize); } 176 STD LINUX { int linux_rt_sigpending(void); } 177 STD LINUX { int linux_rt_sigtimedwait(void); } 178 STD LINUX { int linux_rt_sigqueueinfo(void); } 179 STD LINUX { int linux_rt_sigsuspend(linux_sigset_t *newset, \ size_t sigsetsize); } 180 STD LINUX { int linux_pread(int fd, char *buf, size_t nbyte, \ off_t offset); } 181 STD LINUX { int linux_pwrite(int fd, const char *buf, \ size_t nbyte, off_t offset); } 182 STD LINUX { int linux_chown(char *path, int uid, int gid); } 183 STD LINUX { int linux_getcwd(char *buf, unsigned long bufsize); } 184 STD LINUX { int linux_capget(void); } 185 STD LINUX { int linux_capset(void); } 186 STD LINUX { int linux_sigaltstack(const linux_stack_t *uss, \ linux_stack_t *uoss); } 187 STD LINUX { int linux_sendfile(void); } 188 STD LINUX { int linux_getpmsg(void); } 189 STD LINUX { int linux_putpmsg(void); } 190 STD LINUX { int linux_vfork(void); } 191 STD LINUX { int linux_ugetrlimit(void); } 192 STD LINUX { int linux_mmap2(void); } 193 STD LINUX { int linux_truncate64(void); } 194 STD LINUX { int linux_ftruncate64(void); } 195 STD LINUX { int linux_stat64(void); } 196 STD LINUX { int linux_lstat64(void); } 197 STD LINUX { int linux_fstat64(void); }