The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/osf1/osf1_descrip.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: osf1_descrip.c,v 1.26 2008/03/21 21:54:58 ad Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Christopher G. Demetriou
   17  *      for the NetBSD Project.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
   35  * All rights reserved.
   36  *
   37  * Author: Chris G. Demetriou
   38  *
   39  * Permission to use, copy, modify and distribute this software and
   40  * its documentation is hereby granted, provided that both the copyright
   41  * notice and this permission notice appear in all copies of the
   42  * software, derivative works or modified versions, and any portions
   43  * thereof, and that both notices appear in supporting documentation.
   44  *
   45  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   46  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
   47  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   48  *
   49  * Carnegie Mellon requests users of this software to return to
   50  *
   51  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   52  *  School of Computer Science
   53  *  Carnegie Mellon University
   54  *  Pittsburgh PA 15213-3890
   55  *
   56  * any improvements or extensions that they make and grant Carnegie the
   57  * rights to redistribute these changes.
   58  */
   59 
   60 #include <sys/cdefs.h>
   61 __KERNEL_RCSID(0, "$NetBSD: osf1_descrip.c,v 1.26 2008/03/21 21:54:58 ad Exp $");
   62 
   63 #include <sys/param.h>
   64 #include <sys/systm.h>
   65 #include <sys/namei.h>
   66 #include <sys/proc.h>
   67 #include <sys/file.h>
   68 #include <sys/stat.h>
   69 #include <sys/filedesc.h>
   70 #include <sys/kernel.h>
   71 #include <sys/malloc.h>
   72 #include <sys/mman.h>
   73 #include <sys/mount.h>
   74 #include <sys/signal.h>
   75 #include <sys/signalvar.h>
   76 #include <sys/reboot.h>
   77 #include <sys/syscallargs.h>
   78 #include <sys/exec.h>
   79 #include <sys/vnode.h>
   80 #include <sys/socketvar.h>
   81 #include <sys/resource.h>
   82 #include <sys/resourcevar.h>
   83 #include <sys/wait.h>
   84 
   85 #include <compat/osf1/osf1.h>
   86 #include <compat/osf1/osf1_syscallargs.h>
   87 #include <compat/osf1/osf1_cvt.h>
   88 
   89 int
   90 osf1_sys_fcntl(struct lwp *l, const struct osf1_sys_fcntl_args *uap, register_t *retval)
   91 {
   92         struct sys_fcntl_args a;
   93         struct osf1_flock oflock;
   94         struct flock nflock;
   95         unsigned long xfl, leftovers;
   96         int error;
   97 
   98         SCARG(&a, fd) = SCARG(uap, fd);
   99 
  100         leftovers = 0;
  101         switch (SCARG(uap, cmd)) {
  102         case OSF1_F_DUPFD:
  103                 SCARG(&a, cmd) = F_DUPFD;
  104                 SCARG(&a, arg) = SCARG(uap, arg);
  105                 break;
  106 
  107         case OSF1_F_GETFD:
  108                 SCARG(&a, cmd) = F_GETFD;
  109                 SCARG(&a, arg) = 0;             /* ignored */
  110                 break;
  111 
  112         case OSF1_F_SETFD:
  113                 SCARG(&a, cmd) = F_SETFD;
  114                 SCARG(&a, arg) = (void *)emul_flags_translate(
  115                     osf1_fcntl_getsetfd_flags_xtab,
  116                     (unsigned long)SCARG(uap, arg), &leftovers);
  117                 break;
  118 
  119         case OSF1_F_GETFL:
  120                 SCARG(&a, cmd) = F_GETFL;
  121                 SCARG(&a, arg) = 0;             /* ignored */
  122                 break;
  123 
  124         case OSF1_F_SETFL:
  125                 SCARG(&a, cmd) = F_SETFL;
  126                 xfl = emul_flags_translate(osf1_open_flags_xtab,
  127                     (unsigned long)SCARG(uap, arg), &leftovers);
  128                 xfl |= emul_flags_translate(osf1_fcntl_getsetfl_flags_xtab,
  129                     leftovers, &leftovers);
  130                 SCARG(&a, arg) = (void *)xfl;
  131                 break;
  132 
  133         case OSF1_F_GETOWN:             /* XXX not yet supported */
  134         case OSF1_F_SETOWN:             /* XXX not yet supported */
  135                 /* XXX translate. */
  136                 return (EINVAL);
  137 
  138         case OSF1_F_GETLK:
  139         case OSF1_F_SETLK:
  140         case OSF1_F_SETLKW:
  141                 if (SCARG(uap, cmd) == OSF1_F_GETLK)
  142                         SCARG(&a, cmd) = F_GETLK;
  143                 else if (SCARG(uap, cmd) == OSF1_F_SETLK)
  144                         SCARG(&a, cmd) = F_SETLK;
  145                 else if (SCARG(uap, cmd) == OSF1_F_SETLKW)
  146                         SCARG(&a, cmd) = F_SETLKW;
  147 
  148                 error = copyin(SCARG(uap, arg), &oflock, sizeof oflock);
  149                 if (error != 0)
  150                         return error;
  151                 error = osf1_cvt_flock_to_native(&oflock, &nflock);
  152                 if (error != 0)
  153                         return error;
  154                 error = do_fcntl_lock(SCARG(uap, fd), SCARG(&a, cmd), &nflock);
  155                 if (SCARG(&a, cmd) != F_GETLK || error != 0)
  156                         return error;
  157                 osf1_cvt_flock_from_native(&nflock, &oflock);
  158                 return copyout(&oflock, SCARG(uap, arg), sizeof oflock);
  159 
  160         case OSF1_F_RGETLK:             /* [lock mgr op] XXX not supported */
  161         case OSF1_F_RSETLK:             /* [lock mgr op] XXX not supported */
  162         case OSF1_F_CNVT:               /* [lock mgr op] XXX not supported */
  163         case OSF1_F_RSETLKW:            /* [lock mgr op] XXX not supported */
  164         case OSF1_F_PURGEFS:            /* [lock mgr op] XXX not supported */
  165         case OSF1_F_PURGENFS:           /* [DECsafe op] XXX not supported */
  166         default:
  167                 /* XXX syslog? */
  168                 return (EINVAL);
  169         }
  170         if (leftovers != 0)
  171                 return (EINVAL);
  172 
  173         error = sys_fcntl(l, &a, retval);
  174 
  175         if (error)
  176                 return error;
  177 
  178         switch (SCARG(uap, cmd)) {
  179         case OSF1_F_GETFD:
  180                 retval[0] = emul_flags_translate(
  181                     osf1_fcntl_getsetfd_flags_rxtab, retval[0], NULL);
  182                 break;
  183 
  184         case OSF1_F_GETFL:
  185                 xfl = emul_flags_translate(osf1_open_flags_rxtab,
  186                     retval[0], &leftovers);
  187                 xfl |= emul_flags_translate(osf1_fcntl_getsetfl_flags_rxtab,
  188                     leftovers, NULL);
  189                 retval[0] = xfl;
  190                 break;
  191         }
  192 
  193         return error;
  194 }
  195 
  196 int
  197 osf1_sys_fpathconf(struct lwp *l, const struct osf1_sys_fpathconf_args *uap, register_t *retval)
  198 {
  199         struct sys_fpathconf_args a;
  200         int error;
  201 
  202         SCARG(&a, fd) = SCARG(uap, fd);
  203 
  204         error = osf1_cvt_pathconf_name_to_native(SCARG(uap, name),
  205             &SCARG(&a, name));
  206 
  207         if (error == 0)
  208                 error = sys_fpathconf(l, &a, retval);
  209 
  210         return (error);
  211 }
  212 
  213 /*
  214  * Return status information about a file descriptor.
  215  */
  216 int
  217 osf1_sys_fstat(struct lwp *l, const struct osf1_sys_fstat_args *uap, register_t *retval)
  218 {
  219         file_t *fp;
  220         struct stat ub;
  221         struct osf1_stat oub;
  222         int error;
  223 
  224         if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
  225                 return (EBADF);
  226         error = (*fp->f_ops->fo_stat)(fp, &ub);
  227         fd_putfile(SCARG(uap, fd));
  228 
  229         osf1_cvt_stat_from_native(&ub, &oub);
  230         if (error == 0)
  231                 error = copyout(&oub, SCARG(uap, sb), sizeof(oub));
  232 
  233         return (error);
  234 }
  235 
  236 /*
  237  * Return status information about a file descriptor.
  238  */
  239 int
  240 osf1_sys_fstat2(struct lwp *l, const struct osf1_sys_fstat2_args *uap, register_t *retval)
  241 {
  242         file_t *fp;
  243         struct stat ub;
  244         struct osf1_stat2 oub;
  245         int error;
  246 
  247         if ((fp = fd_getfile(SCARG(uap, fd))) == NULL)
  248                 return (EBADF);
  249         error = (*fp->f_ops->fo_stat)(fp, &ub);
  250         fd_putfile(SCARG(uap, fd));
  251 
  252         osf1_cvt_stat2_from_native(&ub, &oub);
  253         if (error == 0)
  254                 error = copyout(&oub, SCARG(uap, sb), sizeof(oub));
  255 
  256         return (error);
  257 }
  258 
  259 int
  260 osf1_sys_ftruncate(struct lwp *l, const struct osf1_sys_ftruncate_args *uap, register_t *retval)
  261 {
  262         struct sys_ftruncate_args a;
  263 
  264         SCARG(&a, fd) = SCARG(uap, fd);
  265         SCARG(&a, pad) = 0;
  266         SCARG(&a, length) = SCARG(uap, length);
  267 
  268         return sys_ftruncate(l, &a, retval);
  269 }
  270 
  271 int
  272 osf1_sys_lseek(struct lwp *l, const struct osf1_sys_lseek_args *uap, register_t *retval)
  273 {
  274         struct sys_lseek_args a;
  275 
  276         SCARG(&a, fd) = SCARG(uap, fd);
  277         SCARG(&a, pad) = 0;
  278         SCARG(&a, offset) = SCARG(uap, offset);
  279         SCARG(&a, whence) = SCARG(uap, whence);
  280 
  281         return sys_lseek(l, &a, retval);
  282 }

Cache object: 3ca24e6ad66c73d59258c1e5b49b5ec6


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.