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/irix/irix_systeminfo.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: irix_systeminfo.c,v 1.16 2008/04/28 20:23:42 martin Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Emmanuel Dreyfus.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #include <sys/cdefs.h>
   33 __KERNEL_RCSID(0, "$NetBSD: irix_systeminfo.c,v 1.16 2008/04/28 20:23:42 martin Exp $");
   34 
   35 #include <sys/types.h>
   36 #include <sys/signal.h>
   37 #include <sys/param.h>
   38 #include <sys/mount.h>
   39 #include <sys/kernel.h>
   40 #include <sys/proc.h>
   41 #include <sys/systm.h>
   42 #include <sys/sysctl.h>
   43 #include <sys/syscallargs.h>
   44 
   45 #include <compat/common/compat_util.h>
   46 
   47 #include <compat/svr4/svr4_systeminfo.h>
   48 #include <compat/svr4/svr4_types.h>
   49 #include <compat/svr4/svr4_signal.h>
   50 #include <compat/svr4/svr4_ucontext.h>
   51 #include <compat/svr4/svr4_lwp.h>
   52 #include <compat/svr4/svr4_syscallargs.h>
   53 
   54 #include <compat/irix/irix_types.h>
   55 #include <compat/irix/irix_signal.h>
   56 #include <compat/irix/irix_sysctl.h>
   57 #include <compat/irix/irix_syscallargs.h>
   58 
   59 char irix_si_vendor[128] = "Silicon Graphics, Inc.";
   60 char irix_si_os_provider[128] = "Silicon Graphics, Inc.";
   61 char irix_si_os_name[128] = "IRIX";
   62 char irix_si_hw_name[128] = "IP22"; /* XXX */
   63 char irix_si_osrel_maj[128] = "6";
   64 char irix_si_osrel_min[128] = "5";
   65 char irix_si_osrel_patch[128] = "";
   66 char irix_si_processors[128] = "R5000 1.0"; /* XXX */
   67 char irix_si_version[128] = "04131232";
   68 
   69 #define BUF_SIZE 16
   70 
   71 int
   72 irix_sys_systeminfo(struct lwp *l, const struct irix_sys_systeminfo_args *uap, register_t *retval)
   73 {
   74         /* {
   75                 syscallarg(int) what;
   76                 syscallarg(char *) buf;
   77                 syscallarg(long) len;
   78         } */
   79         const char *str = NULL;
   80         char strbuf[BUF_SIZE + 1];
   81         int error = 0;
   82         size_t len = 0;
   83         char buf[256];
   84 
   85         u_int rlen = SCARG(uap, len);
   86 
   87         switch (SCARG(uap, what)) {
   88         case SVR4_MIPS_SI_VENDOR:
   89                 str = irix_si_vendor;
   90                 break;
   91 
   92         case SVR4_MIPS_SI_OS_PROVIDER:
   93                 str = irix_si_os_provider;
   94                 break;
   95 
   96         case SVR4_MIPS_SI_OS_NAME:
   97                 str = irix_si_os_name;
   98                 break;
   99 
  100         case SVR4_MIPS_SI_HW_NAME:
  101                 str = irix_si_hw_name;
  102                 break;
  103 
  104         case SVR4_MIPS_SI_OSREL_MAJ:
  105                 str = irix_si_osrel_maj;
  106                 break;
  107 
  108         case SVR4_MIPS_SI_OSREL_MIN:
  109                 str = irix_si_osrel_min;
  110                 break;
  111 
  112         case SVR4_MIPS_SI_OSREL_PATCH:
  113                 str = irix_si_osrel_patch;
  114                 break;
  115 
  116         case SVR4_MIPS_SI_PROCESSORS:
  117                 str = irix_si_processors;
  118                 break;
  119 
  120         case SVR4_MIPS_SI_NUM_PROCESSORS:
  121         case SVR4_MIPS_SI_AVAIL_PROCESSORS: {
  122                 snprintf(strbuf, BUF_SIZE, "%d", ncpu);
  123                 str = strbuf;
  124                 break;
  125         }
  126 
  127         case SVR4_SI_HW_SERIAL:
  128                 snprintf(strbuf, BUF_SIZE, "%d", (int32_t)hostid);
  129                 str = strbuf;
  130                 break;
  131 
  132         case SVR4_MIPS_SI_HOSTID:
  133                 snprintf(strbuf, BUF_SIZE, "%08x", (int32_t)hostid);
  134                 str = strbuf;
  135                 break;
  136 
  137         case SVR4_MIPS_SI_SERIAL: /* Unimplemented yet */
  138         default:
  139                 return svr4_sys_systeminfo(l, (const void *)uap, retval);
  140                 break;
  141         }
  142 
  143         /*
  144          * This duplicates some code in
  145          * svr4_sys_systeminfo().
  146          * Ideally, it should be merged.
  147          */
  148         if (str) {
  149                 len = strlen(str) + 1;
  150                 if (len > rlen)
  151                         len = rlen;
  152 
  153                 if (SCARG(uap, buf)) {
  154                         error = copyout(str, SCARG(uap, buf), len);
  155                         if (error)
  156                                 return error;
  157                         /* make sure we are NULL terminated */
  158                         buf[0] = '\0';
  159                         error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
  160                 }
  161                 else
  162                         error = 0;
  163         }
  164 
  165         *retval = len;
  166         return error;
  167 }

Cache object: ac576a41accb06250f5c0f75ebdd946b


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