linux_sysctl.c (116173) | linux_sysctl.c (133816) |
---|---|
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 --- 13 unchanged lines hidden (view full) --- 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 29#include <sys/cdefs.h> | 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 --- 13 unchanged lines hidden (view full) --- 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 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_sysctl.c 116173 2003-06-10 21:29:12Z obrien $"); | 30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_sysctl.c 133816 2004-08-16 07:28:16Z tjr $"); |
31 32#include <sys/param.h> 33#include <sys/lock.h> 34#include <sys/malloc.h> 35#include <sys/mutex.h> 36#include <sys/proc.h> 37#include <sys/sysctl.h> 38#include <sys/systm.h> 39#include <sys/sbuf.h> 40 | 31 32#include <sys/param.h> 33#include <sys/lock.h> 34#include <sys/malloc.h> 35#include <sys/mutex.h> 36#include <sys/proc.h> 37#include <sys/sysctl.h> 38#include <sys/systm.h> 39#include <sys/sbuf.h> 40 |
41#include "opt_compat.h" 42 43#if !COMPAT_LINUX32 |
|
41#include <machine/../linux/linux.h> 42#include <machine/../linux/linux_proto.h> | 44#include <machine/../linux/linux.h> 45#include <machine/../linux/linux_proto.h> |
46#else 47#include <machine/../linux32/linux.h> 48#include <machine/../linux32/linux32_proto.h> 49#endif |
|
43 44#include <compat/linux/linux_util.h> 45 46#define LINUX_CTL_KERN 1 47#define LINUX_CTL_VM 2 48#define LINUX_CTL_NET 3 49#define LINUX_CTL_PROC 4 50#define LINUX_CTL_FS 5 --- 7 unchanged lines hidden (view full) --- 58#define LINUX_KERN_OSREV 3 59#define LINUX_KERN_VERSION 4 60 61static int 62handle_string(struct l___sysctl_args *la, char *value) 63{ 64 int error; 65 | 50 51#include <compat/linux/linux_util.h> 52 53#define LINUX_CTL_KERN 1 54#define LINUX_CTL_VM 2 55#define LINUX_CTL_NET 3 56#define LINUX_CTL_PROC 4 57#define LINUX_CTL_FS 5 --- 7 unchanged lines hidden (view full) --- 65#define LINUX_KERN_OSREV 3 66#define LINUX_KERN_VERSION 4 67 68static int 69handle_string(struct l___sysctl_args *la, char *value) 70{ 71 int error; 72 |
66 if (la->oldval != NULL) { | 73 if (la->oldval != 0) { |
67 l_int len = strlen(value); | 74 l_int len = strlen(value); |
68 error = copyout(value, la->oldval, len + 1); 69 if (!error && la->oldlenp != NULL) 70 error = copyout(&len, la->oldlenp, sizeof(len)); | 75 error = copyout(value, PTRIN(la->oldval), len + 1); 76 if (!error && la->oldlenp != 0) 77 error = copyout(&len, PTRIN(la->oldlenp), sizeof(len)); |
71 if (error) 72 return (error); 73 } 74 | 78 if (error) 79 return (error); 80 } 81 |
75 if (la->newval != NULL) | 82 if (la->newval != 0) |
76 return (ENOTDIR); 77 78 return (0); 79} 80 81int 82linux_sysctl(struct thread *td, struct linux_sysctl_args *args) 83{ --- 5 unchanged lines hidden (view full) --- 89 error = copyin(args->args, &la, sizeof(la)); 90 if (error) 91 return (error); 92 93 if (la.nlen <= 0 || la.nlen > LINUX_CTL_MAXNAME) 94 return (ENOTDIR); 95 96 mib = malloc(la.nlen * sizeof(l_int), M_TEMP, M_WAITOK); | 83 return (ENOTDIR); 84 85 return (0); 86} 87 88int 89linux_sysctl(struct thread *td, struct linux_sysctl_args *args) 90{ --- 5 unchanged lines hidden (view full) --- 96 error = copyin(args->args, &la, sizeof(la)); 97 if (error) 98 return (error); 99 100 if (la.nlen <= 0 || la.nlen > LINUX_CTL_MAXNAME) 101 return (ENOTDIR); 102 103 mib = malloc(la.nlen * sizeof(l_int), M_TEMP, M_WAITOK); |
97 error = copyin(la.name, mib, la.nlen * sizeof(l_int)); | 104 error = copyin(PTRIN(la.name), mib, la.nlen * sizeof(l_int)); |
98 if (error) { 99 free(mib, M_TEMP); 100 return (error); 101 } 102 103 switch (mib[0]) { 104 case LINUX_CTL_KERN: 105 if (la.nlen < 2) --- 31 unchanged lines hidden --- | 105 if (error) { 106 free(mib, M_TEMP); 107 return (error); 108 } 109 110 switch (mib[0]) { 111 case LINUX_CTL_KERN: 112 if (la.nlen < 2) --- 31 unchanged lines hidden --- |