this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement sysctl(sysctl.proc_cputype) (#304)

+62
+1
src/kernel/emulation/linux/CMakeLists.txt
··· 160 160 misc/sysctl_kern.c 161 161 misc/sysctl_unspec.c 162 162 misc/sysctl_machdep.c 163 + misc/sysctl_sysctl.c 163 164 misc/getrlimit.c 164 165 misc/setrlimit.c 165 166 misc/gethostuuid.c
+4
src/kernel/emulation/linux/misc/sysctl.c
··· 10 10 #include "sysctl_unspec.h" 11 11 #include "sysctl_kern.h" 12 12 #include "sysctl_machdep.h" 13 + #include "sysctl_sysctl.h" 13 14 14 15 extern char *strchr(const char *s, int c); 15 16 extern int strncmp(const char *s1, const char *s2, __SIZE_TYPE__ n); ··· 18 19 extern __SIZE_TYPE__ strlen(const char* src); 19 20 extern char* strtok_r(char* str, const char* delim, char** saveptr); 20 21 22 + #define _CTL_SYSCTL 100 23 + 21 24 const struct known_sysctl sysctls_global[] = { 22 25 { .oid = CTL_UNSPEC, .type = CTLTYPE_NODE, .exttype = "", .name = "unspec", .subctls = sysctls_unspec }, 23 26 { .oid = CTL_HW, .type = CTLTYPE_NODE, .exttype = "", .name = "hw", .subctls = sysctls_hw }, 24 27 { .oid = CTL_KERN, .type = CTLTYPE_NODE, .exttype = "", .name = "kern", .subctls = sysctls_kern }, 25 28 { .oid = CTL_MACHDEP, .type = CTLTYPE_NODE, .exttype = "", .name = "machdep", .subctls = sysctls_machdep }, 29 + { .oid = _CTL_SYSCTL, .type = CTLTYPE_NODE, .exttype = "", .name = "sysctl", .subctls = sysctls_sysctl }, 26 30 { .oid = -1 }, /* terminating entry */ 27 31 }; 28 32
+49
src/kernel/emulation/linux/misc/sysctl_sysctl.c
··· 1 + #include "sysctl_sysctl.h" 2 + #include <lkm/api.h> 3 + #include <mach/machine.h> 4 + #include <sys/errno.h> 5 + 6 + extern int lkm_call(int call, void*); 7 + 8 + enum { 9 + _PROC_CPUTYPE = 1000, 10 + }; 11 + 12 + static sysctl_handler(handle_proc_cputype); 13 + 14 + const struct known_sysctl sysctls_sysctl[] = { 15 + { .oid = _PROC_CPUTYPE, .type = CTLTYPE_INT, .exttype = "I", .name = "proc_cputype", .handler = handle_proc_cputype }, 16 + { .oid = -1 } 17 + }; 18 + 19 + sysctl_handler(handle_proc_cputype) 20 + { 21 + if (nlen < 3) 22 + return -ENOENT; 23 + 24 + int pid = name[2]; 25 + int is64bit = lkm_call(NR_task_64bit, (void*)(long)pid); 26 + 27 + if (is64bit < 0) 28 + return -ENOENT; 29 + else 30 + { 31 + if (*oldlen < sizeof(int)) 32 + return -EINVAL; 33 + 34 + #if defined(__i386__) || defined(__x86_64__) 35 + *((unsigned int*) old) = CPU_TYPE_I386; 36 + #elif defined(__arm__) || defined(__aarch64__) 37 + *((unsigned int*) old) = CPU_TYPE_ARM; 38 + #else 39 + # warning Missing code for this arch! 40 + *((unsigned int*) old) = 0; 41 + #endif 42 + 43 + if (is64bit) 44 + *((unsigned int*) old) |= CPU_ARCH_ABI64; 45 + } 46 + 47 + return 0; 48 + } 49 +
+8
src/kernel/emulation/linux/misc/sysctl_sysctl.h
··· 1 + #ifndef _SYSCTL_SYSCTL_H 2 + #define _SYSCTL_SYSCTL_H 3 + #include "sysctl.h" 4 + 5 + extern const struct known_sysctl sysctls_sysctl[]; 6 + 7 + #endif 8 +