this repo has no description
1
fork

Configure Feed

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

Provide usrstack sysctls, libc backtrace() now works

+36
+36
src/kernel/emulation/linux/misc/sysctl_kern.c
··· 1 1 #include "sysctl_kern.h" 2 + #include "sysctl_proc.h" 2 3 #include "getrlimit.h" 3 4 #include "../ext/sysinfo.h" 4 5 #include "../ext/syslog.h" ··· 33 34 static sysctl_handler(handle_maxproc); 34 35 static sysctl_handler(handle_netboot); 35 36 static sysctl_handler(handle_safeboot); 37 + static sysctl_handler(handle_usrstack32); 38 + static sysctl_handler(handle_usrstack64); 36 39 static sysctl_handler(handle_sysv_semmns); 37 40 38 41 extern int _sysctl_proc(int what, int flag, struct kinfo_proc* out, unsigned long* buflen); ··· 60 63 { .oid = KERN_OSRELEASE, .type = CTLTYPE_STRING, .exttype = "S", .name = "osrelease", .handler = handle_osrelease }, 61 64 { .oid = KERN_VERSION, .type = CTLTYPE_STRING, .exttype = "S", .name = "version", .handler = handle_version }, 62 65 { .oid = KERN_OSVERSION, .type = CTLTYPE_STRING, .exttype = "S", .name = "osversion", .handler = handle_osversion }, 66 + { .oid = KERN_USRSTACK32, .type = CTLTYPE_INT, .exttype = "I", .name = "usrstack", .handler = handle_usrstack32 }, 67 + { .oid = KERN_USRSTACK64, .type = CTLTYPE_QUAD, .exttype = "Q", .name = "usrstack64", .handler = handle_usrstack64 }, 63 68 { .oid = KERN_SYSV, .type = CTLTYPE_NODE, .exttype = "", .name = "sysv", .subctls = sysctls_kern_sysv }, 64 69 { .oid = -1 } 65 70 }; ··· 287 292 return 0; 288 293 } 289 294 295 + static void* mystack(void) 296 + { 297 + char buf[400]; 298 + char* ptr = buf; 299 + 300 + if (!read_string("/proc/self/stat", buf, sizeof(buf))) 301 + return NULL; 302 + 303 + skip_stat_elems(&ptr, 27); 304 + 305 + const char* stack = next_stat_elem(&ptr); 306 + return (void*) __simple_atoi(stack, NULL); 307 + } 308 + 309 + sysctl_handler(handle_usrstack32) 310 + { 311 + unsigned int* ovalue = (unsigned int*) old; 312 + if (ovalue) 313 + *ovalue = mystack(); 314 + *oldlen = sizeof(*ovalue); 315 + return 0; 316 + } 317 + 318 + sysctl_handler(handle_usrstack64) 319 + { 320 + unsigned long long* ovalue = (unsigned long long*) old; 321 + if (ovalue) 322 + *ovalue = mystack(); 323 + *oldlen = sizeof(*ovalue); 324 + return 0; 325 + }