this repo has no description
1
fork

Configure Feed

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

Refactor sys_sysctl() (resolves #269)

+674 -580
+4
src/kernel/emulation/linux/CMakeLists.txt
··· 123 123 misc/proc_info.c 124 124 misc/sysctl.c 125 125 misc/sysctl_proc.c 126 + misc/sysctl_hw.c 127 + misc/sysctl_kern.c 128 + misc/sysctl_unspec.c 129 + misc/sysctl_machdep.c 126 130 misc/getrlimit.c 127 131 misc/setrlimit.c 128 132 misc/gethostuuid.c
+6
src/kernel/emulation/linux/bsdthread/workq_kernreturn.c
··· 47 47 static void list_add(struct parked_thread* head, struct parked_thread* item); 48 48 static void list_remove(struct parked_thread* head, struct parked_thread* item); 49 49 50 + struct timespec 51 + { 52 + long tv_sec; 53 + long tv_nsec; 54 + }; 55 + 50 56 long sys_workq_kernreturn(int options, void* item, int affinity, int prio) 51 57 { 52 58 #ifndef VARIANT_DYLD
+1 -5
src/kernel/emulation/linux/bsdthread/workq_kernreturn.h
··· 6 6 struct parked_thread *prev, *next; 7 7 int sem, prio; 8 8 }; 9 - struct timespec 10 - { 11 - long tv_sec; 12 - long tv_nsec; 13 - }; 9 + struct timespec; 14 10 15 11 long sys_workq_kernreturn(int options, void* item, int affinity, int prio); 16 12
+69 -575
src/kernel/emulation/linux/misc/sysctl.c
··· 2 2 #include "../base.h" 3 3 #include "../errno.h" 4 4 #include "../simple.h" 5 - #include <linux-syscalls/linux.h> 6 - #include <mach/host_info.h> 7 - #include <mach/machine.h> 8 - #include <mach/mach_init.h> 9 5 #include "../../../../../platform-include/sys/errno.h" 10 6 #include "sysctl_inc.h" 11 7 #include <stddef.h> 12 8 #include <limits.h> 13 - #include "../ext/sys/utsname.h" 14 - #include "../ext/sysinfo.h" 15 - #include "../ext/syslog.h" 16 - #include "../time/gettimeofday.h" 17 - #include "getrlimit.h" 18 - #include "darling-config.h" 19 - 20 - // TODO: This file needs a rework to eliminate all the switch()es 21 - // and replace them with lookup tables. 22 - 23 - static long sysctl_name_to_oid(const char* name, int* oid_name, 24 - unsigned long* oid_len); 25 - static long sysctl_get_type(const int* oid, int nlen, int* out, unsigned long* outlen); 26 - static long sysctl_oid_to_name(const int* oid, int nlen, char* name, unsigned long* outlen); 9 + #include "sysctl_hw.h" 10 + #include "sysctl_unspec.h" 11 + #include "sysctl_kern.h" 12 + #include "sysctl_machdep.h" 27 13 28 14 extern char *strchr(const char *s, int c); 29 15 extern int strncmp(const char *s1, const char *s2, __SIZE_TYPE__ n); 30 16 extern int strcmp(const char *s1, const char *s2); 31 - extern kern_return_t mach_port_deallocate(ipc_space_t task, mach_port_name_t name); 32 - extern kern_return_t host_info(mach_port_name_t host, int itype, void* hinfo, mach_msg_type_number_t* count); 33 - 34 - struct kinfo_proc; 35 - extern int _sysctl_proc(int what, int flag, struct kinfo_proc* out, unsigned long* buflen); 36 - extern int _sysctl_procargs(int pid, char* buf, unsigned long* buflen); 37 - static void get_cpu_brand(char* brand); 38 - 39 - extern int cerror(int err); 17 + extern int strlcpy(char* dst, const char* src, __SIZE_TYPE__ n); 18 + extern __SIZE_TYPE__ strlen(const char* src); 19 + extern char* strtok_r(char* str, const char* delim, char** saveptr); 40 20 41 - /* Darling specific */ 42 - enum { 43 - _HW_PHYSICAL_CPU = 1000, 44 - _HW_PHYSICAL_CPU_MAX, 45 - _HW_LOGICAL_CPU, 46 - _HW_LOGICAL_CPU_MAX, 47 - _HW_CPUTYPE, 48 - _HW_CPUSUBTYPE, 49 - _HW_CPUTHREADTYPE 21 + const struct known_sysctl sysctls_global[] = { 22 + { .oid = CTL_UNSPEC, .type = CTLTYPE_NODE, .exttype = "", .name = "unspec", .subctls = sysctls_unspec }, 23 + { .oid = CTL_HW, .type = CTLTYPE_NODE, .exttype = "", .name = "hw", .subctls = sysctls_hw }, 24 + { .oid = CTL_KERN, .type = CTLTYPE_NODE, .exttype = "", .name = "kern", .subctls = sysctls_kern }, 25 + { .oid = CTL_MACHDEP, .type = CTLTYPE_NODE, .exttype = "", .name = "machdep", .subctls = sysctls_machdep }, 26 + { .oid = -1 }, /* terminating entry */ 50 27 }; 51 28 52 - enum { 53 - _CPU_BRAND_STRING = 1000, 54 - }; 55 - enum { 56 - _KERN_MSGBUF = 1000, 29 + const struct known_sysctl sysctls_root = { 30 + .oid = 0, .type = CTLTYPE_NODE, .exttype = "", .name = "", .subctls = sysctls_global 57 31 }; 58 32 59 - enum { 60 - CTLTYPE_NODE = 1, 61 - CTLTYPE_INT, 62 - CTLTYPE_STRING, 63 - CTLTYPE_QUAD, 64 - CTLTYPE_OPAQUE, 65 - CTLTYPE_STRUCT = CTLTYPE_OPAQUE, 66 - }; 33 + void copyout_string(const char* str, char* out, unsigned long* out_len) 34 + { 35 + unsigned long len; 36 + if (out != NULL) 37 + len = strlcpy(out, str, *out_len); 38 + else 39 + len = strlen(str); 67 40 68 - static struct linux_utsname lu; 69 - static void copyout_string(const char* str, char* out, unsigned long* out_len); 70 - static void need_uname(void); 41 + *out_len = len; 42 + } 71 43 72 44 long sys_sysctl(int* name, unsigned int nlen, void* old, 73 45 unsigned long* oldlen, void* _new, unsigned long newlen) 74 46 { 75 - int ret; 76 - 77 - if (nlen < 2) 78 - return -EINVAL; 47 + int i; 48 + const struct known_sysctl* current = &sysctls_root; 79 49 80 50 // __simple_printf("sysctl %d,%d\n", name[0], name[1]); 81 - if (name[0] == CTL_UNSPEC) 82 - { 83 - switch (name[1]) 84 - { 85 - case 1: // oid to name 86 - return sysctl_oid_to_name(name + 2, nlen - 2, (char*) old, oldlen); 87 - case 3: // name to oid 88 - return sysctl_name_to_oid((const char*) _new, (int*) old, oldlen); 89 - case 4: // get data type 90 - return sysctl_get_type(name + 2, nlen - 2, (int*) old, oldlen); 91 - } 92 - } 93 - else if (name[0] == CTL_HW) 94 - { 95 - int* ovalue = (int*) old; 96 - struct host_basic_info hinfo; 97 - mach_msg_type_number_t hcount = HOST_BASIC_INFO_COUNT; 98 - mach_port_t hself; 99 - unsigned long orig_old_len = *oldlen; 100 51 101 - hself = mach_host_self(); 102 - host_info(hself, HOST_BASIC_INFO, &hinfo, &hcount); 103 - mach_port_deallocate(mach_task_self(), hself); 104 - 105 - if (nlen < 2) 106 - return -ENOTDIR; 107 - 108 - // String values 109 - switch (name[1]) 110 - { 111 - case HW_MACHINE: 112 - { 113 - need_uname(); 114 - copyout_string(lu.machine, (char*) old, oldlen); 115 - return 0; 116 - } 117 - } 118 - 119 - // Integer values 120 - if (*oldlen < sizeof(int)) 121 - return -EINVAL; 122 - *oldlen = sizeof(int); 123 - 124 - switch (name[1]) 125 - { 126 - case HW_AVAILCPU: 127 - case HW_NCPU: 128 - *ovalue = hinfo.avail_cpus; 129 - return 0; 130 - case _HW_PHYSICAL_CPU: 131 - *ovalue = hinfo.physical_cpu; 132 - return 0; 133 - case _HW_PHYSICAL_CPU_MAX: 134 - *ovalue = hinfo.physical_cpu_max; 135 - return 0; 136 - case _HW_LOGICAL_CPU: 137 - *ovalue = hinfo.logical_cpu; 138 - return 0; 139 - case _HW_LOGICAL_CPU_MAX: 140 - *ovalue = hinfo.logical_cpu_max; 141 - return 0; 142 - case HW_MEMSIZE: 143 - case HW_PHYSMEM: 144 - case HW_USERMEM: 145 - if (orig_old_len == sizeof(int)) 146 - { 147 - if (hinfo.max_mem < INT_MAX) 148 - *ovalue = hinfo.max_mem; 149 - else 150 - *ovalue = INT_MAX; 151 - } 152 - else 153 - { 154 - *oldlen = 2 * sizeof(int); 155 - *((unsigned long long*) ovalue) = hinfo.max_mem; 156 - } 157 - return 0; 158 - case HW_PAGESIZE: 159 - *ovalue = 4096; // True on all Darling platforms 160 - return 0; 161 - case _HW_CPUTYPE: 162 - *ovalue = hinfo.cpu_type; 163 - return 0; 164 - case _HW_CPUSUBTYPE: 165 - *ovalue = hinfo.cpu_subtype; 166 - return 0; 167 - case _HW_CPUTHREADTYPE: 168 - *ovalue = hinfo.cpu_threadtype; 169 - return 0; 170 - } 171 - } 172 - else if (name[0] == CTL_KERN) 52 + for (i = 0; i < nlen; i++) 173 53 { 174 - switch (name[1]) 54 + int j; 55 + const struct known_sysctl* next = NULL; 56 + 57 + for (j = 0; current->subctls[j].oid != -1; j++) 175 58 { 176 - case _KERN_MSGBUF: 59 + if (current->subctls[j].oid == name[i]) 177 60 { 178 - if (*oldlen <= 8) 179 - { 180 - // Caller is asking for buffer size 181 - if (*oldlen < sizeof(int)) 182 - return -EINVAL; 183 - 184 - *((int*) old) = __linux_syslog(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0); 185 - return 0; 186 - } 187 - else 188 - { 189 - // Caller is asking for buffer contents 190 - int ret; 191 - 192 - ret = __linux_syslog(SYSLOG_ACTION_READ_ALL, (char*) old, *oldlen); 193 - if (ret < 0) 194 - return errno_linux_to_bsd(ret); 195 - 196 - *oldlen = ret; 197 - return 0; 198 - } 61 + next = &current->subctls[j]; 199 62 break; 200 63 } 201 - case KERN_PROC: 202 - { 203 - if (nlen < 4) 204 - return -ENOTDIR; 205 - // Returns array of struct kinfo_proc 206 - return _sysctl_proc(name[2], name[3], (struct kinfo_proc*) old, oldlen); 207 - 208 - } 209 - case KERN_PROCARGS2: 210 - { 211 - if (nlen < 3) 212 - return -ENOTDIR; 213 - return _sysctl_procargs(name[2], (char*) old, oldlen); 214 - } 215 - case KERN_ARGMAX: 216 - { 217 - struct rlimit lim; 218 - int r; 219 - int* ovalue = (int*) old; 220 - 221 - r = sys_getrlimit(BSD_RLIMIT_STACK, &lim); 222 - if (r < 0) 223 - return r; 224 - 225 - if (ovalue != NULL) 226 - *ovalue = lim.rlim_cur / 4; 227 - *oldlen = sizeof(int); 228 - return 0; 229 - } 230 - case KERN_BOOTTIME: 231 - { 232 - // Fill in struct timeval { tv_sec, tv_usec } 233 - struct sysinfo info; 234 - struct bsd_timeval* tv; 235 - 236 - if (__linux_sysinfo(&info) == -1) 237 - return -errno; 238 - 239 - tv = (struct bsd_timeval*) old; 240 - if (tv != NULL) 241 - { 242 - if (*oldlen < sizeof(*tv)) 243 - return -EINVAL; 244 - sys_gettimeofday(tv, NULL); 245 - 246 - tv->tv_sec -= info.uptime; 247 - } 248 - *oldlen = sizeof(*tv); 249 - 250 - return 0; 251 - } 252 64 } 253 65 254 - need_uname(); 255 - 256 - // String values 257 - switch (name[1]) 258 - { 259 - case KERN_OSTYPE: 260 - { 261 - const char* s = EMULATED_SYSNAME; 262 - 263 - copyout_string(s, (char*) old, oldlen); 264 - return 0; 265 - } 266 - case KERN_HOSTNAME: 267 - copyout_string(lu.nodename, (char*) old, oldlen); 268 - return 0; 269 - case KERN_OSRELEASE: 270 - { 271 - const char* s = EMULATED_RELEASE; 272 - 273 - copyout_string(s, (char*) old, oldlen); 274 - return 0; 275 - } 276 - case KERN_VERSION: 277 - { 278 - const char* s = EMULATED_VERSION; 279 - 280 - copyout_string(s, (char*) old, oldlen); 281 - return 0; 282 - } 283 - case KERN_DOMAINNAME: 284 - copyout_string(lu.domainname, (char*) old, oldlen); 285 - return 0; 286 - } 287 - } 288 - else if (name[0] == CTL_MACHDEP) 289 - { 290 - switch (name[1]) 66 + if (!next) 291 67 { 292 - case _CPU_BRAND_STRING: 293 - { 294 - char brand[13]; 295 - get_cpu_brand(brand); 296 - copyout_string(brand, (char*) old, oldlen); 297 - return 0; 298 - } 68 + // __simple_printf("%d not found in %s\n", name[i], current->name); 69 + return -ENOENT; 299 70 } 300 - } 301 71 302 - return -ENOTDIR; 303 - } 304 - 305 - static void need_uname(void) 306 - { 307 - #ifndef VARIANT_DYLD 308 - // Cache __linux_uname results 309 - if (!lu.sysname[0]) 310 - { 311 - __linux_uname(&lu); 312 - } 313 - #endif 314 - } 315 - 316 - extern unsigned long strlcpy(char* dst, const char* src, unsigned long size); 317 - static void copyout_string(const char* str, char* out, unsigned long* out_len) 318 - { 319 - unsigned long len; 320 - if (out != NULL) 321 - len = strlcpy(out, str, *out_len); 322 - else 323 - len = strlen(str); 324 - 325 - *out_len = len; 326 - } 327 - 328 - static long sysctl_name_to_oid(const char* name, int* oid_name, 329 - unsigned long* oid_len) 330 - { 331 - const char* dot; 332 - unsigned long cat_len; 333 - 334 - if (*oid_len < 2) 335 - return -EINVAL; 336 - 337 - dot = strchr(name, '.'); 338 - if (dot == NULL) 339 - return -ENOTDIR; 340 - 341 - cat_len = dot - name; 342 - 343 - if (strncmp(name, "hw", cat_len) == 0) 344 - { 345 - oid_name[0] = CTL_HW; 346 - *oid_len = 2 * sizeof(int); 347 - 348 - if (strcmp(dot+1, "activecpu") == 0) 349 - oid_name[1] = HW_AVAILCPU; 350 - else if (strcmp(dot+1, "ncpu") == 0) 351 - oid_name[1] = HW_NCPU; 352 - else if (strcmp(dot+1, "physicalcpu") == 0) 353 - oid_name[1] = _HW_PHYSICAL_CPU; 354 - else if (strcmp(dot+1, "physicalcpu_max") == 0) 355 - oid_name[1] = _HW_PHYSICAL_CPU_MAX; 356 - else if (strcmp(dot+1, "logicalcpu") == 0) 357 - oid_name[1] = _HW_LOGICAL_CPU; 358 - else if (strcmp(dot+1, "logicalcpu_max") == 0) 359 - oid_name[1] = _HW_LOGICAL_CPU_MAX; 360 - else if (strcmp(dot+1, "memsize") == 0) 361 - oid_name[1] = HW_MEMSIZE; 362 - else if (strcmp(dot+1, "pagesize") == 0) 363 - oid_name[1] = HW_PAGESIZE; 364 - else if (strcmp(dot+1, "cputype") == 0) 365 - oid_name[1] = _HW_CPUTYPE; 366 - else if (strcmp(dot+1, "cpusubtype") == 0) 367 - oid_name[1] = _HW_CPUSUBTYPE; 368 - else if (strcmp(dot+1, "cputhreadtype") == 0) 369 - oid_name[1] = _HW_CPUTHREADTYPE; 370 - else 371 - return -ENOTDIR; 372 - 373 - return 0; 72 + current = next; 73 + if (next->type != CTLTYPE_NODE) 74 + break; 374 75 } 375 - else if (strncmp(name, "kern", cat_len) == 0) 376 - { 377 - oid_name[0] = CTL_KERN; 378 - *oid_len = 2 * sizeof(int); 379 76 380 - if (strcmp(dot+1, "msgbuf") == 0) 381 - oid_name[1] = _KERN_MSGBUF; 382 - else if (strcmp(dot+1, "boottime") == 0) 383 - oid_name[1] = KERN_BOOTTIME; 384 - else 385 - return -ENOTDIR; 386 - 387 - return 0; 388 - } 389 - else if (strncmp(name, "machdep", cat_len) == 0) 77 + if (current->type == CTLTYPE_NODE) 390 78 { 391 - oid_name[0] = CTL_MACHDEP; 392 - *oid_len = 2 * sizeof(int); 393 - 394 - if (strcmp(dot+1, "cpu.brand_string") == 0) 395 - oid_name[1] = _CPU_BRAND_STRING; 396 - else 397 - return -ENOTDIR; 398 - return 0; 79 + // __simple_printf("-->ISDIR: %s\n", current->name); 80 + return -EISDIR; 399 81 } 400 82 401 - __simple_printf("Unknown sysctl: %s\n", name); 402 - return -ENOTDIR; 83 + long rv = current->handler(name, nlen, old, oldlen, _new, newlen); 84 + // __simple_printf("sysctl rv %d\n", rv); 85 + return rv; 403 86 } 87 + 404 88 405 89 long sys_sysctlbyname(const char* name, unsigned long namelen, void* old, unsigned long* oldlen, void* _new, unsigned long newlen) 406 90 { 407 - long rv; 408 - int oid[4]; 409 - unsigned long oid_len = 4; 410 - 411 - rv = sysctl_name_to_oid(name, oid, &oid_len); 412 - if (rv < 0) 413 - return rv; 414 - 415 - return sys_sysctl(oid, oid_len, old, oldlen, _new, newlen); 416 - } 91 + const struct known_sysctl* current = &sysctls_root; 92 + char* saveptr; 93 + const char* token; 417 94 418 - #define settype(first, str) \ 419 - if (*outlen < sizeof(int) + sizeof(str)) \ 420 - return -EINVAL; \ 421 - out[0] = first; \ 422 - strcpy((char*) &out[1], str); \ 423 - *outlen = sizeof(int) + sizeof(str); 95 + token = strtok_r((char*) _new, ".", &saveptr); 424 96 425 - static long sysctl_get_type(const int* oid, int nlen, int* out, unsigned long* outlen) 426 - { 427 - switch (oid[0]) 97 + while (token != NULL) 428 98 { 429 - case CTL_HW: 430 - if (nlen < 2) 431 - { 432 - settype(CTLTYPE_NODE, ""); 433 - return 0; 434 - } 435 - 436 - switch (oid[1]) 437 - { 438 - case HW_AVAILCPU: 439 - case HW_NCPU: 440 - case _HW_PHYSICAL_CPU: 441 - case _HW_PHYSICAL_CPU_MAX: 442 - case _HW_LOGICAL_CPU: 443 - case _HW_LOGICAL_CPU_MAX: 444 - case HW_PAGESIZE: 445 - case _HW_CPUTYPE: 446 - case _HW_CPUSUBTYPE: 447 - case _HW_CPUTHREADTYPE: 448 - settype(CTLTYPE_INT, "I"); 449 - return 0; 450 - case HW_MEMSIZE: 451 - case HW_PHYSMEM: 452 - case HW_USERMEM: 453 - settype(CTLTYPE_QUAD, "QU"); 454 - return 0; 455 - } 456 - break; 457 - case CTL_KERN: 458 - if (nlen < 2) 459 - { 460 - settype(CTLTYPE_NODE, ""); 461 - return 0; 462 - } 463 - 464 - switch (oid[1]) 465 - { 466 - case _KERN_MSGBUF: 467 - case KERN_PROCARGS2: 468 - case KERN_OSTYPE: 469 - case KERN_HOSTNAME: 470 - case KERN_OSRELEASE: 471 - case KERN_VERSION: 472 - case KERN_DOMAINNAME: 473 - settype(CTLTYPE_STRING, ""); 474 - return 0; 475 - case KERN_PROC: 476 - settype(CTLTYPE_STRUCT, ""); 477 - return 0; 478 - case KERN_BOOTTIME: 479 - { 480 - settype(CTLTYPE_STRUCT, "S,timeval"); 481 - return 0; 482 - } 483 - case KERN_ARGMAX: 484 - settype(CTLTYPE_INT, "L"); 485 - return 0; 486 - } 487 - break; 488 - case CTL_MACHDEP: 489 - if (nlen < 2) 490 - { 491 - settype(CTLTYPE_NODE, ""); 492 - return 0; 493 - } 99 + const struct known_sysctl* next = NULL; 100 + int i; 494 101 495 - switch (oid[1]) 496 - { 497 - case _CPU_BRAND_STRING: 498 - settype(CTLTYPE_STRING, ""); 499 - return 0; 500 - } 501 - } 502 - return -ENOENT; 503 - } 102 + if (current->type != CTLTYPE_NODE) 103 + return -ENOTDIR; 504 104 505 - #define outstring(str) \ 506 - strncpy(name, str, *outlen - 1); \ 507 - name[*outlen - 1] = '\0'; \ 508 - if (*outlen > sizeof(str)-1) \ 509 - *outlen = sizeof(str)-1; 510 - 511 - static long sysctl_oid_to_name(const int* oid, int nlen, char* name, unsigned long* outlen) 512 - { 513 - if (nlen == 1) 514 - { 515 - switch (oid[0]) 105 + for (i = 0; current->subctls[i].oid != -1; i++) 516 106 { 517 - case CTL_HW: 518 - outstring("hw"); 519 - return 0; 520 - case CTL_KERN: 521 - outstring("kern"); 522 - return 0; 523 - } 524 - } 525 - else if (nlen == 2) 526 - { 527 - switch (oid[0]) 528 - { 529 - case CTL_HW: 530 - switch (oid[1]) 531 - { 532 - case HW_AVAILCPU: 533 - outstring("hw.activecpu"); 534 - return 0; 535 - case HW_NCPU: 536 - outstring("hw.ncpu"); 537 - return 0; 538 - case _HW_PHYSICAL_CPU: 539 - outstring("hw.physicalcpu"); 540 - return 0; 541 - case _HW_PHYSICAL_CPU_MAX: 542 - outstring("hw.physicalcpu_max"); 543 - return 0; 544 - case _HW_LOGICAL_CPU: 545 - outstring("hw.logicalcpu"); 546 - return 0; 547 - case _HW_LOGICAL_CPU_MAX: 548 - outstring("hw.logicalcpu_max"); 549 - return 0; 550 - case HW_MEMSIZE: 551 - outstring("hw.memsize"); 552 - return 0; 553 - case HW_PAGESIZE: 554 - outstring("hw.pagesize"); 555 - return 0; 556 - case _HW_CPUTYPE: 557 - outstring("hw.cputype"); 558 - return 0; 559 - case _HW_CPUSUBTYPE: 560 - outstring("hw.cpusubtype"); 561 - return 0; 562 - case _HW_CPUTHREADTYPE: 563 - outstring("hw.cputhreadtype"); 564 - return 0; 565 - } 107 + if (strcmp(current->subctls[i].name, token) == 0) 108 + { 109 + next = &current->subctls[i]; 566 110 break; 567 - case CTL_KERN: 568 - switch (oid[1]) 569 - { 570 - case _KERN_MSGBUF: 571 - outstring("kern.msgbuf"); 572 - return 0; 573 - case KERN_BOOTTIME: 574 - outstring("kern.boottime"); 575 - return 0; 576 - case KERN_OSTYPE: 577 - outstring("kern.ostype"); 578 - return 0; 579 - case KERN_VERSION: 580 - outstring("kern.version"); 581 - return 0; 582 - case KERN_OSRELEASE: 583 - outstring("kern.osrelease"); 584 - return 0; 585 - case KERN_HOSTNAME: 586 - outstring("kern.hostname"); 587 - return 0; 588 - case KERN_DOMAINNAME: 589 - outstring("kern.domainname"); 590 - return 0; 591 - } 592 - break; 593 - case CTL_MACHDEP: 594 - switch (oid[1]) 595 - { 596 - case _CPU_BRAND_STRING: 597 - outstring("machdep.cpu.brand_string"); 598 - return 0; 599 - } 111 + } 600 112 } 601 - } 602 113 603 - return -ENOENT; 604 - } 605 - 606 - #ifndef __cpuid 607 - #define __cpuid(level, a, b, c, d) \ 608 - __asm__ ("cpuid\n\t" \ 609 - : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ 610 - : "0" (level)) 611 - #endif 114 + if (next == NULL) 115 + return -ENOENT; 612 116 613 - void get_cpu_brand(char* brand) 614 - { 615 - unsigned int level = 0; 616 - unsigned int eax = 0; 617 - union 618 - { 619 - struct 620 - { 621 - unsigned int ebx; 622 - unsigned int edx; 623 - unsigned int ecx; 624 - }; 625 - char name[12]; 626 - } v; 117 + current = next; 118 + token = strtok_r(NULL, ".", &saveptr); 119 + } 627 120 628 - __cpuid(level, eax, v.ebx, v.ecx, v.edx); 121 + if (current->type == CTLTYPE_NODE) 122 + return -EISDIR; 629 123 630 - strncpy(brand, v.name, 12); 631 - brand[12] = 0; 124 + return current->handler(NULL, 0, old, oldlen, _new, newlen); 632 125 } 633 126 127 +
+29
src/kernel/emulation/linux/misc/sysctl.h
··· 1 1 #ifndef LINUX_SYSCTL_H 2 2 #define LINUX_SYSCTL_H 3 + #include <sys/sysctl.h> 3 4 4 5 long sys_sysctl(int* name, unsigned int nlen, void* old, unsigned long* oldlen, void* _new, unsigned long newlen); 5 6 long sys_sysctlbyname(const char* name, unsigned long namelen, void* old, unsigned long* oldlen, void* _new, unsigned long newlen); 7 + 8 + #define sysctl_handle_size(size) \ 9 + if (old == NULL) { \ 10 + *oldlen = size; \ 11 + return 0; \ 12 + } else if (*oldlen < size) \ 13 + return -EINVAL; \ 14 + else \ 15 + *oldlen = size; 16 + 17 + typedef long (*sysctl_handler_t)(const int* name, int nlen, void* old, unsigned long* oldlen, void* _new, unsigned long newlen); 18 + 19 + #define sysctl_handler(_hname) long _hname(const int* name, int nlen, void* old, unsigned long* oldlen, void* _new, unsigned long newlen) 20 + void copyout_string(const char* str, char* out, unsigned long* out_len); 21 + 22 + struct known_sysctl 23 + { 24 + int oid; // e.g. HW_MEMSIZE, terminating entry has oid -1 25 + int type; // e.g. CTLTYPE_QUAD 26 + const char* exttype; // e.g. "UQ" 27 + const char* name; // e.g. "memsize" 28 + 29 + union { 30 + const struct known_sysctl* subctls; // for CTLTYPE_NODE 31 + sysctl_handler_t handler; // for everything else 32 + }; 33 + }; 34 + extern const struct known_sysctl sysctls_root; 6 35 7 36 #endif 8 37
+142
src/kernel/emulation/linux/misc/sysctl_hw.c
··· 1 + #include "sysctl_hw.h" 2 + #include <mach/host_info.h> 3 + #include <mach/machine.h> 4 + #include <mach/mach_init.h> 5 + #include <sys/errno.h> 6 + #include "sysctl_kern.h" 7 + #include "../ext/sys/utsname.h" 8 + 9 + extern kern_return_t mach_port_deallocate(ipc_space_t task, mach_port_name_t name); 10 + extern kern_return_t host_info(mach_port_name_t host, int itype, void* hinfo, mach_msg_type_number_t* count); 11 + 12 + /* Darling specific */ 13 + enum { 14 + _HW_PHYSICAL_CPU = 1000, 15 + _HW_PHYSICAL_CPU_MAX, 16 + _HW_LOGICAL_CPU, 17 + _HW_LOGICAL_CPU_MAX, 18 + _HW_CPUTYPE, 19 + _HW_CPUSUBTYPE, 20 + _HW_CPUTHREADTYPE 21 + }; 22 + 23 + static sysctl_handler(handle_availcpu); 24 + static sysctl_handler(handle_physicalcpu); 25 + static sysctl_handler(handle_physicalcpu_max); 26 + static sysctl_handler(handle_logicalcpu); 27 + static sysctl_handler(handle_logicalcpu_max); 28 + static sysctl_handler(handle_memsize); 29 + static sysctl_handler(handle_pagesize); 30 + static sysctl_handler(handle_cputype); 31 + static sysctl_handler(handle_cpusubtype); 32 + static sysctl_handler(handle_cputhreadtype); 33 + static sysctl_handler(handle_machine); 34 + 35 + const struct known_sysctl sysctls_hw[] = { 36 + { .oid = HW_AVAILCPU, .type = CTLTYPE_INT, .exttype = "", .name = "availcpu", .handler = handle_availcpu }, 37 + { .oid = HW_NCPU, .type = CTLTYPE_INT, .exttype = "", .name = "ncpu", .handler = handle_availcpu }, 38 + { .oid = _HW_PHYSICAL_CPU, .type = CTLTYPE_INT, .exttype = "", .name = "physicalcpu", .handler = handle_physicalcpu }, 39 + { .oid = _HW_PHYSICAL_CPU_MAX, .type = CTLTYPE_INT, .exttype = "", .name = "physicalcpu_max", .handler = handle_physicalcpu_max }, 40 + { .oid = _HW_LOGICAL_CPU, .type = CTLTYPE_INT, .exttype = "", .name = "logicalcpu", .handler = handle_logicalcpu }, 41 + { .oid = _HW_LOGICAL_CPU_MAX, .type = CTLTYPE_INT, .exttype = "", .name = "logicalcpu_max", .handler = handle_logicalcpu_max }, 42 + { .oid = HW_MEMSIZE, .type = CTLTYPE_QUAD, .exttype = "U", .name = "memsize", .handler = handle_memsize }, 43 + { .oid = HW_PAGESIZE, .type = CTLTYPE_INT, .exttype = "", .name = "pagesize", .handler = handle_pagesize }, 44 + { .oid = _HW_CPUTYPE, .type = CTLTYPE_INT, .exttype = "", .name = "cputype", .handler = handle_cputype }, 45 + { .oid = _HW_CPUSUBTYPE, .type = CTLTYPE_INT, .exttype = "", .name = "cpusubtype", .handler = handle_cpusubtype }, 46 + { .oid = _HW_CPUTHREADTYPE, .type = CTLTYPE_INT, .exttype = "", .name = "cputhreadtype", .handler = handle_cputhreadtype }, 47 + { .oid = HW_MACHINE, .type = CTLTYPE_STRING, .exttype = "S", .name = "machine", .handler = handle_machine }, 48 + { .oid = -1 } 49 + }; 50 + 51 + static const struct host_basic_info* gethostinfo(void) 52 + { 53 + static struct host_basic_info hinfo; 54 + 55 + if (!hinfo.avail_cpus) 56 + { 57 + mach_msg_type_number_t hcount = HOST_BASIC_INFO_COUNT; 58 + mach_port_t hself; 59 + 60 + hself = mach_host_self(); 61 + host_info(hself, HOST_BASIC_INFO, &hinfo, &hcount); 62 + mach_port_deallocate(mach_task_self(), hself); 63 + } 64 + 65 + return &hinfo; 66 + } 67 + 68 + sysctl_handler(handle_availcpu) 69 + { 70 + sysctl_handle_size(sizeof(int)); 71 + *((int*) old) = gethostinfo()->avail_cpus; 72 + return 0; 73 + } 74 + 75 + sysctl_handler(handle_physicalcpu) 76 + { 77 + sysctl_handle_size(sizeof(int)); 78 + *((int*) old) = gethostinfo()->physical_cpu; 79 + return 0; 80 + } 81 + 82 + sysctl_handler(handle_physicalcpu_max) 83 + { 84 + sysctl_handle_size(sizeof(int)); 85 + *((int*) old) = gethostinfo()->physical_cpu_max; 86 + return 0; 87 + } 88 + 89 + sysctl_handler(handle_logicalcpu) 90 + { 91 + sysctl_handle_size(sizeof(int)); 92 + *((int*) old) = gethostinfo()->logical_cpu; 93 + return 0; 94 + } 95 + 96 + sysctl_handler(handle_logicalcpu_max) 97 + { 98 + sysctl_handle_size(sizeof(int)); 99 + *((int*) old) = gethostinfo()->logical_cpu_max; 100 + return 0; 101 + } 102 + 103 + sysctl_handler(handle_memsize) 104 + { 105 + sysctl_handle_size(sizeof(unsigned long long)); 106 + *((unsigned long long*) old) = gethostinfo()->max_mem; 107 + return 0; 108 + } 109 + 110 + sysctl_handler(handle_pagesize) 111 + { 112 + sysctl_handle_size(sizeof(int)); 113 + *((int*) old) = 4096; // true on all Darling platforms 114 + return 0; 115 + } 116 + 117 + sysctl_handler(handle_cputype) 118 + { 119 + sysctl_handle_size(sizeof(int)); 120 + *((int*) old) = gethostinfo()->cpu_type; 121 + return 0; 122 + } 123 + 124 + sysctl_handler(handle_cpusubtype) 125 + { 126 + sysctl_handle_size(sizeof(int)); 127 + *((int*) old) = gethostinfo()->cpu_subtype; 128 + return 0; 129 + } 130 + 131 + sysctl_handler(handle_cputhreadtype) 132 + { 133 + sysctl_handle_size(sizeof(int)); 134 + *((int*) old) = gethostinfo()->cpu_threadtype; 135 + return 0; 136 + } 137 + 138 + sysctl_handler(handle_machine) 139 + { 140 + copyout_string(need_uname()->machine, (char*) old, oldlen); 141 + return 0; 142 + }
+8
src/kernel/emulation/linux/misc/sysctl_hw.h
··· 1 + #ifndef _SYSCTL_HW_H 2 + #define _SYSCTL_HW_H 3 + #include "sysctl.h" 4 + 5 + extern const struct known_sysctl sysctls_hw[]; 6 + 7 + #endif 8 +
+173
src/kernel/emulation/linux/misc/sysctl_kern.c
··· 1 + #include "sysctl_kern.h" 2 + #include "getrlimit.h" 3 + #include "../ext/sysinfo.h" 4 + #include "../ext/syslog.h" 5 + #include "../ext/sys/utsname.h" 6 + #include <linux-syscalls/linux.h> 7 + #include "../time/gettimeofday.h" 8 + #include "darling-config.h" 9 + #include "../errno.h" 10 + #include <sys/errno.h> 11 + 12 + enum { 13 + _KERN_MSGBUF = 1000, 14 + }; 15 + 16 + static sysctl_handler(handle_msgbuf); 17 + static sysctl_handler(handle_proc); 18 + static sysctl_handler(handle_procargs32); 19 + static sysctl_handler(handle_argmax); 20 + static sysctl_handler(handle_boottime); 21 + static sysctl_handler(handle_ostype); 22 + static sysctl_handler(handle_hostname); 23 + static sysctl_handler(handle_domainname); 24 + static sysctl_handler(handle_osrelease); 25 + static sysctl_handler(handle_version); 26 + 27 + extern int _sysctl_proc(int what, int flag, struct kinfo_proc* out, unsigned long* buflen); 28 + extern int _sysctl_procargs(int pid, char* buf, unsigned long* buflen); 29 + extern int strlcpy(char* dst, const char* src, __SIZE_TYPE__ dst_size); 30 + extern __SIZE_TYPE__ strlen(const char* str); 31 + 32 + const struct known_sysctl sysctls_kern[] = { 33 + { .oid = _KERN_MSGBUF, .type = CTLTYPE_STRING, .exttype = "S", .name = "msgbuf", .handler = handle_msgbuf }, 34 + { .oid = KERN_PROC, .type = CTLTYPE_STRUCT, .exttype = "", .name = "proc", .handler = handle_proc }, 35 + { .oid = KERN_PROCARGS2, .type = CTLTYPE_STRUCT, .exttype = "", .name = "procargs2", .handler = handle_procargs32 }, 36 + { .oid = KERN_ARGMAX, .type = CTLTYPE_INT, .exttype = "I", .name = "argmax", .handler = handle_argmax }, 37 + { .oid = KERN_BOOTTIME, .type = CTLTYPE_STRUCT, .exttype = "S,timeval", .name = "boottime", .handler = handle_boottime }, 38 + { .oid = KERN_OSTYPE, .type = CTLTYPE_STRING, .exttype = "S", .name = "ostype", .handler = handle_ostype }, 39 + { .oid = KERN_HOSTNAME, .type = CTLTYPE_STRING, .exttype = "S", .name = "hostname", .handler = handle_hostname }, 40 + { .oid = KERN_DOMAINNAME, .type = CTLTYPE_STRING, .exttype = "S", .name = "domainname", .handler = handle_domainname }, 41 + { .oid = KERN_OSRELEASE, .type = CTLTYPE_STRING, .exttype = "S", .name = "osrelease", .handler = handle_osrelease }, 42 + { .oid = KERN_VERSION, .type = CTLTYPE_STRING, .exttype = "S", .name = "version", .handler = handle_version }, 43 + { .oid = -1 } 44 + }; 45 + 46 + sysctl_handler(handle_msgbuf) 47 + { 48 + if (*oldlen <= 8) 49 + { 50 + // Caller is asking for buffer size 51 + if (*oldlen < sizeof(int)) 52 + return -EINVAL; 53 + 54 + *((int*) old) = __linux_syslog(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0); 55 + } 56 + else 57 + { 58 + // Caller is asking for buffer contents 59 + int ret; 60 + 61 + ret = __linux_syslog(SYSLOG_ACTION_READ_ALL, (char*) old, *oldlen); 62 + if (ret < 0) 63 + return errno_linux_to_bsd(ret); 64 + 65 + *oldlen = ret; 66 + } 67 + return 0; 68 + } 69 + 70 + sysctl_handler(handle_proc) 71 + { 72 + if (nlen < 4) 73 + return -ENOENT; 74 + return _sysctl_proc(name[2], name[3], (struct kinfo_proc*) old, oldlen); 75 + } 76 + 77 + sysctl_handler(handle_procargs32) 78 + { 79 + if (nlen < 3) 80 + return -ENOENT; 81 + return _sysctl_procargs(name[2], (char*) old, oldlen); 82 + } 83 + 84 + sysctl_handler(handle_argmax) 85 + { 86 + struct rlimit lim; 87 + int r; 88 + int* ovalue = (int*) old; 89 + 90 + r = sys_getrlimit(BSD_RLIMIT_STACK, &lim); 91 + if (r < 0) 92 + return r; 93 + 94 + if (ovalue != NULL) 95 + *ovalue = lim.rlim_cur / 4; 96 + *oldlen = sizeof(int); 97 + return 0; 98 + } 99 + 100 + sysctl_handler(handle_boottime) 101 + { 102 + // Fill in struct timeval { tv_sec, tv_usec } 103 + struct sysinfo info; 104 + struct bsd_timeval* tv; 105 + 106 + if (__linux_sysinfo(&info) == -1) 107 + return -errno; 108 + 109 + tv = (struct bsd_timeval*) old; 110 + if (tv != NULL) 111 + { 112 + if (*oldlen < sizeof(*tv)) 113 + return -EINVAL; 114 + sys_gettimeofday(tv, NULL); 115 + 116 + tv->tv_sec -= info.uptime; 117 + } 118 + *oldlen = sizeof(*tv); 119 + 120 + return 0; 121 + } 122 + 123 + sysctl_handler(handle_ostype) 124 + { 125 + const char* s = EMULATED_SYSNAME; 126 + 127 + copyout_string(s, (char*) old, oldlen); 128 + return 0; 129 + } 130 + 131 + sysctl_handler(handle_osrelease) 132 + { 133 + const char* s = EMULATED_RELEASE; 134 + 135 + copyout_string(s, (char*) old, oldlen); 136 + return 0; 137 + } 138 + 139 + sysctl_handler(handle_version) 140 + { 141 + const char* s = EMULATED_VERSION; 142 + 143 + copyout_string(s, (char*) old, oldlen); 144 + return 0; 145 + } 146 + 147 + static struct linux_utsname lu; 148 + struct linux_utsname* need_uname(void) 149 + { 150 + #ifndef VARIANT_DYLD 151 + // Cache __linux_uname results 152 + if (!lu.sysname[0]) 153 + { 154 + __linux_uname(&lu); 155 + } 156 + #endif 157 + return &lu; 158 + } 159 + 160 + sysctl_handler(handle_hostname) 161 + { 162 + need_uname(); 163 + copyout_string(lu.nodename, (char*) old, oldlen); 164 + return 0; 165 + } 166 + 167 + sysctl_handler(handle_domainname) 168 + { 169 + need_uname(); 170 + copyout_string(lu.domainname, (char*) old, oldlen); 171 + return 0; 172 + } 173 +
+10
src/kernel/emulation/linux/misc/sysctl_kern.h
··· 1 + #ifndef _SYSCTL_KERN_H 2 + #define _SYSCTL_KERN_H 3 + #include "sysctl.h" 4 + 5 + extern const struct known_sysctl sysctls_kern[]; 6 + 7 + struct linux_utsname* need_uname(void); 8 + 9 + #endif 10 +
+53
src/kernel/emulation/linux/misc/sysctl_machdep.c
··· 1 + #include "sysctl_machdep.h" 2 + #include <sys/errno.h> 3 + 4 + enum { 5 + _MACHDEP_CPU = 1000, 6 + }; 7 + 8 + enum { 9 + _CPU_BRAND_STRING = 1000, 10 + }; 11 + 12 + static sysctl_handler(handle_brand_string); 13 + 14 + const struct known_sysctl sysctls_machdep_cpu[] = { 15 + { .oid = _CPU_BRAND_STRING, .type = CTLTYPE_STRING, .exttype = "S", .name = "brand_string", .handler = handle_brand_string }, 16 + { .oid = -1 } 17 + }; 18 + 19 + const struct known_sysctl sysctls_machdep[] = { 20 + { .oid = _MACHDEP_CPU, .type = CTLTYPE_NODE, .exttype = "", .name = "cpu", .subctls = sysctls_machdep_cpu }, 21 + { .oid = -1 } 22 + }; 23 + 24 + #ifndef __cpuid 25 + #define __cpuid(level, a, b, c, d) \ 26 + __asm__ ("cpuid\n\t" \ 27 + : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ 28 + : "0" (level)) 29 + #endif 30 + 31 + sysctl_handler(handle_brand_string) 32 + { 33 + unsigned int level = 0; 34 + unsigned int eax = 0; 35 + union 36 + { 37 + struct 38 + { 39 + unsigned int ebx; 40 + unsigned int edx; 41 + unsigned int ecx; 42 + }; 43 + char name[13]; 44 + } v; 45 + 46 + __cpuid(level, eax, v.ebx, v.ecx, v.edx); 47 + 48 + v.name[12] = 0; 49 + copyout_string(v.name, (char*) old, oldlen); 50 + 51 + return 0; 52 + } 53 +
+8
src/kernel/emulation/linux/misc/sysctl_machdep.h
··· 1 + #ifndef _SYSCTL_MACHDEP_H 2 + #define _SYSCTL_MACHDEP_H 3 + #include "sysctl.h" 4 + 5 + extern const struct known_sysctl sysctls_machdep[]; 6 + 7 + #endif 8 +
+163
src/kernel/emulation/linux/misc/sysctl_unspec.c
··· 1 + #include "sysctl_unspec.h" 2 + #include <sys/errno.h> 3 + 4 + enum { 5 + _OID_TO_NAME = 1, 6 + _NAME_TO_OID = 3, 7 + _GET_DATA_TYPE = 4, 8 + }; 9 + 10 + extern char* strtok_r(char* str, const char* delim, char** saveptr); 11 + extern void* memcpy(void* dst, const void* src, __SIZE_TYPE__ len); 12 + extern char* strcpy(char* dst, const char* src); 13 + extern char* strcat(char* dst, const char* src); 14 + extern __SIZE_TYPE__ strlen(const char* str); 15 + extern int strcmp(const char* str1, const char* str2); 16 + 17 + static sysctl_handler(handle_oid_to_name); 18 + static sysctl_handler(handle_name_to_oid); 19 + static sysctl_handler(handle_get_data_type); 20 + 21 + const struct known_sysctl sysctls_unspec[] = { 22 + { .oid = _OID_TO_NAME, .type = CTLTYPE_STRING, .exttype = "S", .name = "oid_to_name", .handler = handle_oid_to_name }, 23 + { .oid = _NAME_TO_OID, .type = CTLTYPE_STRUCT, .exttype = "I,oid", .name = "name_to_oid", .handler = handle_name_to_oid }, 24 + { .oid = _GET_DATA_TYPE, .type = CTLTYPE_STRUCT, .exttype = "I,type", .name = "get_data_type", .handler = handle_get_data_type }, 25 + { .oid = -1 } 26 + }; 27 + 28 + sysctl_handler(handle_oid_to_name) 29 + { 30 + const int* oid = name + 2; 31 + const int oid_len = nlen - 2; 32 + char sname[64] = ""; 33 + int i; 34 + const struct known_sysctl* current = &sysctls_root; 35 + 36 + for (i = 0; i < oid_len; i++) 37 + { 38 + int j; 39 + const struct known_sysctl* next = NULL; 40 + 41 + for (j = 0; current->subctls[j].oid != -1; j++) 42 + { 43 + if (current->subctls[j].oid == oid[i]) 44 + { 45 + next = &current->subctls[j]; 46 + break; 47 + } 48 + } 49 + 50 + if (!next) 51 + return -ENOENT; 52 + 53 + if (sname[0]) 54 + strcat(sname, "."); 55 + strcat(sname, next->name); 56 + 57 + if (next->type != CTLTYPE_NODE) 58 + break; 59 + 60 + current = next; 61 + } 62 + 63 + copyout_string(sname, old, oldlen); 64 + return 0; 65 + } 66 + 67 + sysctl_handler(handle_name_to_oid) 68 + { 69 + const struct known_sysctl* current = &sysctls_root; 70 + int oid[4]; 71 + int oid_len = 0; 72 + char* saveptr; 73 + const char* token; 74 + 75 + token = strtok_r((char*) _new, ".", &saveptr); 76 + 77 + while (token != NULL) 78 + { 79 + const struct known_sysctl* next = NULL; 80 + int i; 81 + 82 + if (current->type != CTLTYPE_NODE) 83 + return -ENOTDIR; 84 + 85 + for (i = 0; current->subctls[i].oid != -1; i++) 86 + { 87 + if (strcmp(current->subctls[i].name, token) == 0) 88 + { 89 + next = &current->subctls[i]; 90 + break; 91 + } 92 + } 93 + 94 + if (next == NULL) 95 + return -ENOENT; 96 + 97 + oid[oid_len++] = next->oid; 98 + current = next; 99 + token = strtok_r(NULL, ".", &saveptr); 100 + } 101 + 102 + if (old == NULL) 103 + { 104 + *oldlen = sizeof(int) * oid_len; 105 + } 106 + else 107 + { 108 + if (*oldlen < sizeof(int) * oid_len) 109 + return -EINVAL; 110 + *oldlen = sizeof(int) * oid_len; 111 + memcpy(old, oid, *oldlen); 112 + } 113 + 114 + return 0; 115 + } 116 + 117 + sysctl_handler(handle_get_data_type) 118 + { 119 + const int* oid = name + 2; 120 + const int oid_len = nlen - 2; 121 + int i; 122 + const struct known_sysctl* current = &sysctls_root; 123 + 124 + for (i = 0; i < oid_len; i++) 125 + { 126 + int j; 127 + const struct known_sysctl* next = NULL; 128 + 129 + if (current->type != CTLTYPE_NODE) 130 + return -ENOTDIR; 131 + 132 + for (j = 0; current->subctls[j].oid != -1; j++) 133 + { 134 + if (current->subctls[j].oid == oid[i]) 135 + { 136 + next = &current->subctls[j]; 137 + break; 138 + } 139 + } 140 + 141 + if (!next) 142 + return -ENOENT; 143 + 144 + current = next; 145 + } 146 + 147 + int typelen = sizeof(int) + strlen(current->exttype) + 1; 148 + if (old == NULL) 149 + { 150 + *oldlen = typelen; 151 + } 152 + else 153 + { 154 + if (*oldlen < typelen) 155 + return -EINVAL; 156 + *oldlen = typelen; 157 + 158 + *((int*)old) = current->type; 159 + strcpy((char*) (((int*)old)+1), current->exttype); 160 + } 161 + return 0; 162 + } 163 +
+8
src/kernel/emulation/linux/misc/sysctl_unspec.h
··· 1 + #ifndef _SYSCTL_UNSPEC_H 2 + #define _SYSCTL_UNSPEC_H 3 + #include "sysctl.h" 4 + 5 + extern const struct known_sysctl sysctls_unspec[]; 6 + 7 + #endif 8 +