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/linux/linux_sysctl.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) 2001 Marcel Moolenaar
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer 
   10  *    in this position and unchanged.
   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. The name of the author may not be used to endorse or promote products
   15  *    derived from this software without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27  *
   28  * $FreeBSD: stable/4/sys/compat/linux/linux_sysctl.c 85267 2001-10-21 03:57:35Z marcel $
   29  */
   30 
   31 #include "opt_compat.h"
   32 
   33 #include <sys/param.h>
   34 #include <sys/systm.h>
   35 #include <sys/proc.h>
   36 #include <sys/sysproto.h>
   37 
   38 #include <machine/../linux/linux.h>
   39 #include <machine/../linux/linux_proto.h>
   40 #include <compat/linux/linux_util.h>
   41 
   42 #define LINUX_CTL_KERN          1
   43 #define LINUX_CTL_VM            2
   44 #define LINUX_CTL_NET           3
   45 #define LINUX_CTL_PROC          4
   46 #define LINUX_CTL_FS            5
   47 #define LINUX_CTL_DEBUG         6
   48 #define LINUX_CTL_DEV           7
   49 #define LINUX_CTL_BUS           8
   50 
   51 /* CTL_KERN names */
   52 #define LINUX_KERN_OSTYPE       1
   53 #define LINUX_KERN_OSRELEASE    2
   54 #define LINUX_KERN_OSREV        3
   55 #define LINUX_KERN_VERSION      4
   56 
   57 static int
   58 handle_string(struct l___sysctl_args *la, char *value)
   59 {
   60         int error;
   61 
   62         if (la->oldval != NULL) {
   63                 l_int len = strlen(value);
   64                 error = copyout(value, la->oldval, len + 1);
   65                 if (!error && la->oldlenp != NULL)
   66                         error = copyout(&len, la->oldlenp, sizeof(len));
   67                 if (error)
   68                         return (error);
   69         }
   70 
   71         if (la->newval != NULL)
   72                 return (ENOTDIR);
   73 
   74         return (0);
   75 }
   76 
   77 int
   78 linux_sysctl(struct proc *p, struct linux_sysctl_args *args)
   79 {
   80         struct l___sysctl_args la;
   81         l_int *mib;
   82         int error, i;
   83         caddr_t sg;
   84 
   85         error = copyin((caddr_t)args->args, &la, sizeof(la));
   86         if (error)
   87                 return (error);
   88 
   89         if (la.nlen == 0 || la.nlen > LINUX_CTL_MAXNAME)
   90                 return (ENOTDIR);
   91 
   92         sg = stackgap_init();
   93         mib = stackgap_alloc(&sg, la.nlen * sizeof(l_int));
   94         error = copyin(la.name, mib, la.nlen * sizeof(l_int));
   95         if (error)
   96                 return (error);
   97 
   98         switch (mib[0]) {
   99         case LINUX_CTL_KERN:
  100                 if (la.nlen < 2)
  101                         break;
  102 
  103                 switch (mib[1]) {
  104                 case LINUX_KERN_VERSION:
  105                         return (handle_string(&la, version));
  106                 default:
  107                         break;
  108                 }
  109                 break;
  110         default:
  111                 break;
  112         }
  113 
  114         printf("linux: sysctl: unhandled name=");
  115         for (i = 0; i < la.nlen; i++)
  116                 printf("%c%d", (i) ? ',' : '{', mib[i]);
  117         printf("}\n");
  118 
  119         return (ENOTDIR);
  120 }

Cache object: d44ec687ebd9bb37f2867f214a8cb85f


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