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-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 /*-
    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 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/cdefs.h>
   32 __FBSDID("$FreeBSD$");
   33 
   34 #include <sys/param.h>
   35 #include <sys/systm.h>
   36 #include <sys/namei.h> 
   37 #include <sys/sysproto.h>
   38 #include <sys/clock.h>
   39 #include <sys/jail.h>
   40 #include <sys/kernel.h>
   41 #include <sys/malloc.h>
   42 #include <sys/filio.h>
   43 #include <sys/vnode.h>
   44 #include <sys/syscallsubr.h>
   45 #include <sys/sysctl.h>
   46 #include <sys/sysent.h>
   47 #include <sys/unistd.h>
   48 
   49 #include <machine/cpu.h>
   50 
   51 #include <i386/ibcs2/ibcs2_types.h>
   52 #include <i386/ibcs2/ibcs2_unistd.h>
   53 #include <i386/ibcs2/ibcs2_signal.h>
   54 #include <i386/ibcs2/ibcs2_util.h>
   55 #include <i386/ibcs2/ibcs2_proto.h>
   56 #include <i386/ibcs2/ibcs2_xenix.h>
   57 #include <i386/ibcs2/ibcs2_xenix_syscall.h>
   58 
   59 
   60 extern struct sysent xenix_sysent[];
   61 
   62 int
   63 ibcs2_xenix(struct thread *td, struct ibcs2_xenix_args *uap)
   64 {
   65         struct trapframe *tf = td->td_frame;
   66         struct sysent *callp;
   67         u_int code;
   68         int error;
   69 
   70         code = (tf->tf_eax & 0xff00) >> 8;
   71         callp = &xenix_sysent[code];
   72 
   73         if (code < IBCS2_XENIX_MAXSYSCALL)
   74                 error = ((*callp->sy_call)(td, (void *)uap));
   75         else
   76                 error = ENOSYS;
   77         return (error);
   78 }
   79 
   80 int
   81 xenix_rdchk(td, uap)
   82         struct thread *td;
   83         struct xenix_rdchk_args *uap;
   84 {
   85         int data, error;
   86 
   87         DPRINTF(("IBCS2: 'xenix rdchk'\n"));
   88         
   89         error = kern_ioctl(td, uap->fd, FIONREAD, (caddr_t)&data);
   90         if (error)
   91                 return (error);
   92         td->td_retval[0] = data ? 1 : 0;
   93         return (0);
   94 }
   95 
   96 int
   97 xenix_chsize(td, uap)
   98         struct thread *td;
   99         struct xenix_chsize_args *uap;
  100 {
  101         struct ftruncate_args sa;
  102 
  103         DPRINTF(("IBCS2: 'xenix chsize'\n"));
  104         sa.fd = uap->fd;
  105         sa.length = uap->size;
  106         return ftruncate(td, &sa);
  107 }
  108 
  109 
  110 int
  111 xenix_ftime(td, uap)
  112         struct thread *td;
  113         struct xenix_ftime_args *uap;
  114 {
  115         struct timeval tv;
  116         struct ibcs2_timeb {
  117                 unsigned long time __packed;
  118                 unsigned short millitm;
  119                 short timezone;
  120                 short dstflag;
  121         } itb;
  122 
  123         DPRINTF(("IBCS2: 'xenix ftime'\n"));
  124         microtime(&tv);
  125         itb.time = tv.tv_sec;
  126         itb.millitm = (tv.tv_usec / 1000);
  127         itb.timezone = tz_minuteswest;
  128         itb.dstflag = tz_dsttime != DST_NONE;
  129 
  130         return copyout((caddr_t)&itb, (caddr_t)uap->tp,
  131                        sizeof(struct ibcs2_timeb));
  132 }
  133 
  134 int
  135 xenix_nap(struct thread *td, struct xenix_nap_args *uap)
  136 {
  137         long period;
  138 
  139         DPRINTF(("IBCS2: 'xenix nap %d ms'\n", uap->millisec));
  140         period = (long)uap->millisec / (1000/hz);
  141         if (period)
  142                 pause("nap", period);
  143         return 0;
  144 }
  145 
  146 int
  147 xenix_utsname(struct thread *td, struct xenix_utsname_args *uap)
  148 {
  149         struct ibcs2_sco_utsname {
  150                 char sysname[9];
  151                 char nodename[9];
  152                 char release[16];
  153                 char kernelid[20];
  154                 char machine[9];
  155                 char bustype[9];
  156                 char sysserial[10];
  157                 unsigned short sysorigin;
  158                 unsigned short sysoem;
  159                 char numusers[9];
  160                 unsigned short numcpu;
  161         } ibcs2_sco_uname;
  162 
  163         DPRINTF(("IBCS2: 'xenix sco_utsname'\n"));
  164         bzero(&ibcs2_sco_uname, sizeof(struct ibcs2_sco_utsname));
  165         strncpy(ibcs2_sco_uname.sysname, ostype,
  166                 sizeof(ibcs2_sco_uname.sysname) - 1);
  167         getcredhostname(td->td_ucred, ibcs2_sco_uname.nodename,
  168             sizeof(ibcs2_sco_uname.nodename) - 1);
  169         strncpy(ibcs2_sco_uname.release, osrelease,
  170                 sizeof(ibcs2_sco_uname.release) - 1);
  171         strncpy(ibcs2_sco_uname.kernelid, version,
  172                 sizeof(ibcs2_sco_uname.kernelid) - 1);
  173         strncpy(ibcs2_sco_uname.machine, machine,
  174                 sizeof(ibcs2_sco_uname.machine) - 1);
  175         strncpy(ibcs2_sco_uname.bustype, "ISA/EISA",
  176                 sizeof(ibcs2_sco_uname.bustype) - 1);
  177         strncpy(ibcs2_sco_uname.sysserial, "no charge",
  178                 sizeof(ibcs2_sco_uname.sysserial) - 1);
  179         strncpy(ibcs2_sco_uname.numusers, "unlim",
  180                 sizeof(ibcs2_sco_uname.numusers) - 1);
  181         ibcs2_sco_uname.sysorigin = 0xFFFF;
  182         ibcs2_sco_uname.sysoem = 0xFFFF;
  183         ibcs2_sco_uname.numcpu = 1;
  184         return copyout((caddr_t)&ibcs2_sco_uname,
  185                        (caddr_t)(void *)(intptr_t)uap->addr,
  186                        sizeof(struct ibcs2_sco_utsname));
  187 }
  188 
  189 int
  190 xenix_scoinfo(struct thread *td, struct xenix_scoinfo_args *uap)
  191 {
  192   /* scoinfo (not documented) */
  193   td->td_retval[0] = 0;
  194   return 0;
  195 }
  196 
  197 int     
  198 xenix_eaccess(struct thread *td, struct xenix_eaccess_args *uap)
  199 {
  200         char *path;
  201         int error, bsd_flags;
  202 
  203         bsd_flags = 0;
  204         if (uap->flags & IBCS2_R_OK)
  205                 bsd_flags |= R_OK;
  206         if (uap->flags & IBCS2_W_OK)
  207                 bsd_flags |= W_OK;
  208         if (uap->flags & IBCS2_X_OK)
  209                 bsd_flags |= X_OK;
  210 
  211         CHECKALTEXIST(td, uap->path, &path);
  212         error = kern_eaccess(td, path, UIO_SYSSPACE, bsd_flags);
  213         free(path, M_TEMP);
  214         return (error);
  215 }

Cache object: 924ce0e3836be20ccc5ed83ee3f244cf


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