this repo has no description
1
fork

Configure Feed

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

Update darlingserver and libkqueue

This commit includes support for Mach port filters in kqueue (via the new kqchan facility in darlingserver).

Additionally, ccache usage can now be disabled via DARLING_NO_CCACHE.

+60 -2
+3 -1
CMakeLists.txt
··· 28 28 ) 29 29 endif(NOT DEFINED CMAKE_CXX_COMPILER) 30 30 31 + option(DARLING_NO_CCACHE "Disable ccache usage" OFF) 32 + 31 33 find_program(CCACHE_PROGRAM ccache) 32 - if(CCACHE_PROGRAM) 34 + if(CCACHE_PROGRAM AND NOT DARLING_NO_CCACHE) 33 35 set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") 34 36 endif() 35 37
+1
Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/darling/emulation/ext/for-libkqueue.h
··· 1 + ../../../../../../../../../../../src/kernel/emulation/linux/ext/for-libkqueue.h
+38 -1
src/hosttools/src/coredump/main.c
··· 7 7 #include <stdbool.h> 8 8 #include <errno.h> 9 9 #include <sys/stat.h> 10 + #include <pwd.h> 10 11 11 12 #include <mach-o/loader.h> 12 13 #include <elf.h> ··· 25 26 26 27 struct vm_area { 27 28 const char* filename; 29 + size_t filename_length; 28 30 uintptr_t memory_address; 29 31 size_t memory_size; 30 32 size_t file_offset; ··· 83 85 struct thread_info* thread_infos; 84 86 size_t thread_info_count; 85 87 size_t written; 88 + const char* prefix; 89 + size_t prefix_length; 86 90 }; 87 91 88 92 static char default_output_name[4096]; 93 + static char default_prefix[4096]; 89 94 90 95 static uint64_t round_up_pow2(uint64_t number, uint64_t multiple) { 91 96 return (number + (multiple - 1)) & -multiple; ··· 121 126 return 1; 122 127 } 123 128 129 + const char* homedir = NULL; 130 + 131 + if (getenv("HOME")) { 132 + homedir = getenv("HOME"); 133 + } else { 134 + struct passwd* pwd = getpwuid(getuid()); 135 + homedir = pwd->pw_dir; 136 + } 137 + 138 + if (snprintf(default_prefix, sizeof(default_prefix), "%s/.darling", homedir) < 0) { 139 + perror("snprintf"); 140 + return 1; 141 + } 142 + 124 143 struct coredump_params cprm = {0}; 125 144 145 + cprm.prefix = getenv("DPREFIX"); 146 + 147 + if (!cprm.prefix) { 148 + cprm.prefix = default_prefix; 149 + } 150 + 151 + cprm.prefix_length = strlen(cprm.prefix); 152 + 126 153 cprm.input_corefile = open(argv[1], O_RDONLY); 127 154 if (cprm.input_corefile < 0) { 128 155 perror("open input"); ··· 308 335 } 309 336 310 337 vm_area->filename = filename; 338 + vm_area->filename_length = strlen(vm_area->filename); 311 339 vm_area->file_offset = entry->offset * cprm.nt_file->page_size; 312 340 vm_area->file_size = entry->end - entry->start; 313 341 ··· 324 352 } else { 325 353 // contents contained within this corefile 326 354 vm_area->filename = NULL; 355 + vm_area->filename_length = 0; 327 356 vm_area->file_size = program_header->p_filesz; 328 357 } 329 358 ··· 360 389 struct vm_area* vm_area = &cprm.vm_areas[vm_area_index++]; 361 390 362 391 vm_area->filename = filename; 392 + vm_area->filename_length = strlen(vm_area->filename); 363 393 vm_area->memory_address = entry->start; 364 394 vm_area->memory_size = entry->end - entry->start; 365 395 vm_area->file_size = vm_area->memory_size; ··· 689 719 exit(EXIT_FAILURE); 690 720 } else { 691 721 if (vma->filename) { 692 - int fd = open(vma->filename, O_RDONLY); 722 + int fd = -1; 723 + fd = open(vma->filename, O_RDONLY); 724 + if (fd < 0 && vma->filename_length >= cprm->prefix_length && strncmp(vma->filename, cprm->prefix, cprm->prefix_length) == 0) { 725 + char* filename = malloc(sizeof("/usr/local/libexec/darling/") + (vma->filename_length - cprm->prefix_length)); 726 + sprintf(filename, "%s/%s", "/usr/local/libexec/darling", &vma->filename[cprm->prefix_length]); 727 + fd = open(filename, O_RDONLY); 728 + free(filename); 729 + } 693 730 if (fd < 0) { 694 731 fprintf(stderr, "Failed to open %s: %d (%s)\n", vma->filename, errno, strerror(errno)); 695 732 exit(EXIT_FAILURE);
+1
src/kernel/emulation/linux/CMakeLists.txt
··· 268 268 ext/fanotify.c 269 269 ext/for-xtrace.c 270 270 ext/for-libelfloader.c 271 + ext/for-libkqueue.c 271 272 bsdthread/bsdthread_register.c 272 273 bsdthread/bsdthread_create.c 273 274 bsdthread/bsdthread_ctl.c
+6
src/kernel/emulation/linux/ext/for-libkqueue.c
··· 1 + #include "for-libkqueue.h" 2 + #include <darlingserver/rpc.h> 3 + 4 + int _dserver_rpc_kqchan_mach_port_open_4libkqueue(uint32_t port_name, void* receive_buffer, uint64_t receive_buffer_size, uint64_t saved_filter_flags, int* out_socket) { 5 + return dserver_rpc_kqchan_mach_port_open(port_name, receive_buffer, receive_buffer_size, saved_filter_flags, out_socket); 6 + };
+11
src/kernel/emulation/linux/ext/for-libkqueue.h
··· 1 + #ifndef _DARLING_EMULATION_FOR_LIBKQUEUE_H_ 2 + #define _DARLING_EMULATION_FOR_LIBKQUEUE_H_ 3 + 4 + #include <stdint.h> 5 + 6 + #include <darling/emulation/base.h> 7 + 8 + VISIBLE 9 + int _dserver_rpc_kqchan_mach_port_open_4libkqueue(uint32_t port_name, void* receive_buffer, uint64_t receive_buffer_size, uint64_t saved_filter_flags, int* out_socket); 10 + 11 + #endif // _DARLING_EMULATION_FOR_LIBKQUEUE_H_