[BACK]Return to svr4_filio.c CVS log [TXT][DIR] Up to [local] / sys / compat / svr4

Annotation of sys/compat/svr4/svr4_filio.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: svr4_filio.c,v 1.5 2002/03/14 01:26:51 millert Exp $   */
                      2: /*     $NetBSD: svr4_filio.c,v 1.5 1996/04/11 12:54:40 christos Exp $   */
                      3:
                      4: /*
                      5:  * Copyright (c) 1994 Christos Zoulas
                      6:  * All rights reserved.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. The name of the author may not be used to endorse or promote products
                     17:  *    derived from this software without specific prior written permission
                     18:  *
                     19:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     20:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     21:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     22:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     23:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     24:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     25:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     26:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     27:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     28:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     29:  */
                     30:
                     31: #include <sys/param.h>
                     32: #include <sys/proc.h>
                     33: #include <sys/systm.h>
                     34: #include <sys/file.h>
                     35: #include <sys/filedesc.h>
                     36: #include <sys/ioctl.h>
                     37: #include <sys/termios.h>
                     38: #include <sys/tty.h>
                     39: #include <sys/socket.h>
                     40: #include <sys/mount.h>
                     41: #include <net/if.h>
                     42: #include <sys/malloc.h>
                     43:
                     44: #include <sys/syscallargs.h>
                     45:
                     46: #include <compat/svr4/svr4_types.h>
                     47: #include <compat/svr4/svr4_util.h>
                     48: #include <compat/svr4/svr4_signal.h>
                     49: #include <compat/svr4/svr4_syscallargs.h>
                     50: #include <compat/svr4/svr4_stropts.h>
                     51: #include <compat/svr4/svr4_ioctl.h>
                     52: #include <compat/svr4/svr4_filio.h>
                     53:
                     54:
                     55: int
                     56: svr4_fil_ioctl(fp, p, retval, fd, cmd, data)
                     57:        struct file *fp;
                     58:        struct proc *p;
                     59:        register_t *retval;
                     60:        int fd;
                     61:        u_long cmd;
                     62:        caddr_t data;
                     63: {
                     64:        int error;
                     65:        int num;
                     66:        struct filedesc *fdp = p->p_fd;
                     67:        int (*ctl)(struct file *, u_long,  caddr_t, struct proc *) =
                     68:                        fp->f_ops->fo_ioctl;
                     69:
                     70:        *retval = 0;
                     71:
                     72:        switch (cmd) {
                     73:        case SVR4_FIOCLEX:
                     74:                fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
                     75:                return 0;
                     76:
                     77:        case SVR4_FIONCLEX:
                     78:                fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
                     79:                return 0;
                     80:
                     81:        case SVR4_FIOGETOWN:
                     82:        case SVR4_FIOSETOWN:
                     83:        case SVR4_FIOASYNC:
                     84:        case SVR4_FIONBIO:
                     85:        case SVR4_FIONREAD:
                     86:                if ((error = copyin(data, &num, sizeof(num))) != 0)
                     87:                        return error;
                     88:
                     89:                switch (cmd) {
                     90:                case SVR4_FIOGETOWN:    cmd = FIOGETOWN; break;
                     91:                case SVR4_FIOSETOWN:    cmd = FIOSETOWN; break;
                     92:                case SVR4_FIOASYNC:     cmd = FIOASYNC;  break;
                     93:                case SVR4_FIONBIO:      cmd = FIONBIO;   break;
                     94:                case SVR4_FIONREAD:     cmd = FIONREAD;  break;
                     95:                }
                     96:
                     97:                error = (*ctl)(fp, cmd, (caddr_t) &num, p);
                     98:
                     99:                if (error)
                    100:                        return error;
                    101:
                    102:                return copyout(&num, data, sizeof(num));
                    103:
                    104:        default:
                    105:                DPRINTF(("Unknown svr4 filio %lx\n", cmd));
                    106:                return 0;       /* ENOSYS really */
                    107:        }
                    108: }

CVSweb