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/i386/ibcs2/ibcs2_xenix.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1994 Sean Eric Fagan
    3  * Copyright (c) 1994 Søren Schmidt
    4  * Copyright (c) 1995 Steven Wallace
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer
   12  *    in this position and unchanged.
   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 withough 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  * $FreeBSD: src/sys/i386/ibcs2/ibcs2_xenix.c,v 1.7.4.2 1999/09/05 08:11:30 peter Exp $
   31  */
   32 
   33 #include <sys/param.h>
   34 #include <sys/systm.h>
   35 #include <sys/namei.h> 
   36 #include <sys/sysproto.h>
   37 #include <sys/kernel.h>
   38 #include <sys/exec.h>
   39 #include <sys/ioctl.h>
   40 #include <sys/proc.h>
   41 #include <sys/vnode.h>
   42 #include <sys/sysctl.h>
   43 #include <sys/sysent.h>
   44 #include <sys/errno.h>
   45 #include <sys/timeb.h>
   46 #include <sys/unistd.h>
   47 
   48 #include <vm/vm.h>
   49 #include <machine/cpu.h>
   50 #include <machine/psl.h>
   51 #include <machine/reg.h>
   52 
   53 #include <i386/ibcs2/ibcs2_types.h>
   54 #include <i386/ibcs2/ibcs2_unistd.h>
   55 #include <i386/ibcs2/ibcs2_signal.h>
   56 #include <i386/ibcs2/ibcs2_util.h>
   57 #include <i386/ibcs2/ibcs2_proto.h>
   58 #include <i386/ibcs2/ibcs2_xenix.h>
   59 #include <i386/ibcs2/ibcs2_xenix_syscall.h>
   60 
   61 extern struct sysent xenix_sysent[];
   62 
   63 int
   64 ibcs2_xenix(struct proc *p, struct ibcs2_xenix_args *uap, int *retval)
   65 {
   66         struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
   67         struct sysent *callp;
   68         u_int code;             
   69 
   70         code = (tf->tf_eax & 0xff00) >> 8;
   71         callp = &xenix_sysent[code];
   72 
   73         if(code < IBCS2_XENIX_MAXSYSCALL)
   74           return((*callp->sy_call)(p, (void *)uap, retval));
   75         else
   76           return ENOSYS;
   77 }
   78 
   79 int
   80 xenix_rdchk(p, uap, retval)
   81         struct proc *p;
   82         struct xenix_rdchk_args *uap;
   83         int *retval;
   84 {
   85         int error;
   86         struct ioctl_args sa;
   87         caddr_t sg = stackgap_init();
   88 
   89         DPRINTF(("IBCS2: 'xenix rdchk'\n"));
   90         SCARG(&sa, fd) = SCARG(uap, fd);
   91         SCARG(&sa, com) = FIONREAD;
   92         SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int));
   93         if (error = ioctl(p, &sa, retval))
   94                 return error;
   95         *retval = (*((int*)SCARG(&sa, data))) ? 1 : 0;
   96         return 0;
   97 }
   98 
   99 int
  100 xenix_chsize(p, uap, retval)
  101         struct proc *p;
  102         struct xenix_chsize_args *uap;
  103         int *retval;
  104 {
  105         struct ftruncate_args sa;
  106 
  107         DPRINTF(("IBCS2: 'xenix chsize'\n"));
  108         SCARG(&sa, fd) = SCARG(uap, fd);
  109         SCARG(&sa, pad) = 0;
  110         SCARG(&sa, length) = SCARG(uap, size);
  111         return ftruncate(p, &sa, retval);
  112 }
  113 
  114 
  115 int
  116 xenix_ftime(p, uap, retval)
  117         struct proc *p;
  118         struct xenix_ftime_args *uap;
  119         int *retval;
  120 {
  121         struct timeval tv;
  122         struct ibcs2_timeb {
  123                 unsigned long time __attribute__((packed));
  124                 unsigned short millitm;
  125                 short timezone;
  126                 short dstflag ;
  127         } itb;
  128 
  129         DPRINTF(("IBCS2: 'xenix ftime'\n"));
  130         microtime(&tv);
  131         itb.time = tv.tv_sec;
  132         itb.millitm = (tv.tv_usec / 1000);
  133         itb.timezone = tz.tz_minuteswest;
  134         itb.dstflag = tz.tz_dsttime != DST_NONE;
  135 
  136         return copyout((caddr_t)&itb, (caddr_t)SCARG(uap, tp),
  137                        sizeof(struct ibcs2_timeb));
  138 }
  139 
  140 int
  141 xenix_nap(struct proc *p, struct xenix_nap_args *uap, int *retval)
  142 {
  143         long period;
  144 
  145         DPRINTF(("IBCS2: 'xenix nap %d ms'\n", SCARG(uap, millisec)));
  146         period = (long)SCARG(uap, millisec) / (1000/hz);
  147         if (period)
  148                 while (tsleep(&period, PUSER, "nap", period) 
  149                        != EWOULDBLOCK) ;
  150         return 0;
  151 }
  152 
  153 int
  154 xenix_utsname(struct proc *p, struct xenix_utsname_args *uap, int *retval)
  155 {
  156         struct ibcs2_sco_utsname {
  157                 char sysname[9];
  158                 char nodename[9];
  159                 char release[16];
  160                 char kernelid[20];
  161                 char machine[9];
  162                 char bustype[9];
  163                 char sysserial[10];
  164                 unsigned short sysorigin;
  165                 unsigned short sysoem;
  166                 char numusers[9];
  167                 unsigned short numcpu;
  168         } ibcs2_sco_uname;
  169 
  170         DPRINTF(("IBCS2: 'xenix sco_utsname'\n"));
  171         bzero(&ibcs2_sco_uname, sizeof(struct ibcs2_sco_utsname));
  172         strncpy(ibcs2_sco_uname.sysname, ostype, 8);
  173         strncpy(ibcs2_sco_uname.nodename, hostname, 8);
  174         strncpy(ibcs2_sco_uname.release, osrelease, 15);
  175         strncpy(ibcs2_sco_uname.kernelid, version, 19);
  176         strncpy(ibcs2_sco_uname.machine, machine, 8);
  177         bcopy("ISA/EISA", ibcs2_sco_uname.bustype, 8);
  178         bcopy("no charge", ibcs2_sco_uname.sysserial, 9);
  179         bcopy("unlim", ibcs2_sco_uname.numusers, 8);
  180         ibcs2_sco_uname.sysorigin = 0xFFFF;
  181         ibcs2_sco_uname.sysoem = 0xFFFF;
  182         ibcs2_sco_uname.numcpu = 1;
  183         return copyout((caddr_t)&ibcs2_sco_uname, (caddr_t)uap->addr,
  184                        sizeof(struct ibcs2_sco_utsname));
  185 }
  186 
  187 int
  188 xenix_scoinfo(struct proc *p, struct xenix_scoinfo_args *uap, int *retval)
  189 {
  190   /* scoinfo (not documented) */
  191   *retval = 0;
  192   return 0;
  193 }
  194 
  195 int     
  196 xenix_eaccess(struct proc *p, struct xenix_eaccess_args *uap, int *retval)
  197 {
  198         struct ucred *cred = p->p_ucred;
  199         struct vnode *vp;
  200         struct nameidata nd;
  201         int error, flags;
  202         caddr_t sg = stackgap_init();
  203 
  204         CHECKALTEXIST(p, &sg, SCARG(uap, path));
  205 
  206         NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
  207             SCARG(uap, path), p);
  208         if (error = namei(&nd))
  209                 return error;
  210         vp = nd.ni_vp;
  211 
  212         /* Flags == 0 means only check for existence. */
  213         if (SCARG(uap, flags)) {
  214                 flags = 0;
  215                 if (SCARG(uap, flags) & IBCS2_R_OK)
  216                         flags |= VREAD;
  217                 if (SCARG(uap, flags) & IBCS2_W_OK)
  218                         flags |= VWRITE;
  219                 if (SCARG(uap, flags) & IBCS2_X_OK)
  220                         flags |= VEXEC;
  221                 if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
  222                         error = VOP_ACCESS(vp, flags, cred, p);
  223         }
  224         vput(vp);
  225         return error;
  226 }

Cache object: 088507a53a2db4199c6864fd2b3eb621


[ 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.