this repo has no description
1
fork

Configure Feed

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

Merge branch 'master' into feature/sigprocess

+350 -6
+1
src/kernel/emulation/linux/CMakeLists.txt
··· 265 265 ext/futex.c 266 266 ext/mremap.c 267 267 ext/file_handle.c 268 + ext/fanotify.c 268 269 bsdthread/bsdthread_register.c 269 270 bsdthread/bsdthread_create.c 270 271 bsdthread/bsdthread_terminate.c
+47
src/kernel/emulation/linux/ext/fanotify.c
··· 1 + #include "fanotify.h" 2 + #include "../errno.h" 3 + #include "../vchroot_expand.h" 4 + #include "../bsdthread/per_thread_wd.h" 5 + #include "../../../../../platform-include/sys/errno.h" 6 + #include <linux-syscalls/linux.h> 7 + 8 + extern long cerror(int __err); 9 + 10 + int fanotify_init(unsigned flags, unsigned event_f_flags) 11 + { 12 + int rv = LINUX_SYSCALL(__NR_fanotify_init, flags, event_f_flags); 13 + if (rv < 0) 14 + { 15 + cerror(errno_linux_to_bsd(-rv)); 16 + return -1; 17 + } 18 + return rv; 19 + } 20 + 21 + int fanotify_mark(int fanotify_fd, unsigned flags, unsigned long long mask, int dfd, const char *pathname) 22 + { 23 + struct vchroot_expand_args vc; 24 + 25 + if (!pathname) 26 + return -EFAULT; 27 + 28 + vc.flags = 0; 29 + vc.dfd = dfd; 30 + 31 + strcpy(vc.path, pathname); 32 + int rv = vchroot_expand(&vc); 33 + 34 + if (rv < 0) 35 + { 36 + cerror(errno_linux_to_bsd(-rv)); 37 + return -1; 38 + } 39 + 40 + rv = LINUX_SYSCALL(__NR_fanotify_mark, fanotify_fd, flags, mask, dfd, vc.path); 41 + if (rv < 0) 42 + { 43 + cerror(errno_linux_to_bsd(-rv)); 44 + return -1; 45 + } 46 + return rv; 47 + }
+20
src/kernel/emulation/linux/ext/fanotify.h
··· 1 + #ifndef _EXT_FANOTIFY_H 2 + #define _EXT_FANOTIFY_H 3 + #include "../base.h" 4 + 5 + #ifdef __cplusplus 6 + extern "C" { 7 + #endif 8 + 9 + VISIBLE 10 + int fanotify_init(unsigned flags, unsigned event_f_flags); 11 + 12 + VISIBLE 13 + int fanotify_mark(int fanotify_fd, unsigned flags, unsigned long long mask, int dfd, const char *pathname); 14 + 15 + 16 + #ifdef __cplusplus 17 + } 18 + #endif 19 + 20 + #endif
+49
src/kernel/emulation/linux/linux-syscalls/linux-x86.h
··· 377 377 #define __NR_copy_file_range 377 378 378 #define __NR_preadv2 378 379 379 #define __NR_pwritev2 379 380 + #define __NR_pkey_mprotect 380 381 + #define __NR_pkey_alloc 381 382 + #define __NR_pkey_free 382 383 + #define __NR_statx 383 384 + #define __NR_arch_prctl 384 385 + #define __NR_io_pgetevents 385 386 + #define __NR_rseq 386 387 + #define __NR_semget 393 388 + #define __NR_semctl 394 389 + #define __NR_shmget 395 390 + #define __NR_shmctl 396 391 + #define __NR_shmat 397 392 + #define __NR_shmdt 398 393 + #define __NR_msgget 399 394 + #define __NR_msgsnd 400 395 + #define __NR_msgrcv 401 396 + #define __NR_msgctl 402 397 + #define __NR_clock_gettime64 403 398 + #define __NR_clock_settime64 404 399 + #define __NR_clock_adjtime64 405 400 + #define __NR_clock_getres_time64 406 401 + #define __NR_clock_nanosleep_time64 407 402 + #define __NR_timer_gettime64 408 403 + #define __NR_timer_settime64 409 404 + #define __NR_timerfd_gettime64 410 405 + #define __NR_timerfd_settime64 411 406 + #define __NR_utimensat_time64 412 407 + #define __NR_pselect6_time64 413 408 + #define __NR_ppoll_time64 414 409 + #define __NR_io_pgetevents_time64 416 410 + #define __NR_recvmmsg_time64 417 411 + #define __NR_mq_timedsend_time64 418 412 + #define __NR_mq_timedreceive_time64 419 413 + #define __NR_semtimedop_time64 420 414 + #define __NR_rt_sigtimedwait_time64 421 415 + #define __NR_futex_time64 422 416 + #define __NR_sched_rr_get_interval_time64 423 417 + #define __NR_pidfd_send_signal 424 418 + #define __NR_io_uring_setup 425 419 + #define __NR_io_uring_enter 426 420 + #define __NR_io_uring_register 427 421 + #define __NR_open_tree 428 422 + #define __NR_move_mount 429 423 + #define __NR_fsopen 430 424 + #define __NR_fsconfig 431 425 + #define __NR_fsmount 432 426 + #define __NR_fspick 433 427 + #define __NR_pidfd_open 434 428 + #define __NR_clone3 435 380 429 381 430 #endif /* _ASM_X86_UNISTD_32_H */
+18
src/kernel/emulation/linux/linux-syscalls/linux-x86_64.h
··· 330 330 #define __NR_copy_file_range 326 331 331 #define __NR_preadv2 327 332 332 #define __NR_pwritev2 328 333 + #define __NR_pkey_mprotect 329 334 + #define __NR_pkey_alloc 330 335 + #define __NR_pkey_free 331 336 + #define __NR_statx 332 337 + #define __NR_io_pgetevents 333 338 + #define __NR_rseq 334 339 + #define __NR_pidfd_send_signal 424 340 + #define __NR_io_uring_setup 425 341 + #define __NR_io_uring_enter 426 342 + #define __NR_io_uring_register 427 343 + #define __NR_open_tree 428 344 + #define __NR_move_mount 429 345 + #define __NR_fsopen 430 346 + #define __NR_fsconfig 431 347 + #define __NR_fsmount 432 348 + #define __NR_fspick 433 349 + #define __NR_pidfd_open 434 350 + #define __NR_clone3 435 333 351 334 352 #endif /* _ASM_X86_UNISTD_64_H */
+206 -3
src/kernel/emulation/linux/misc/sysctl_machdep.c
··· 1 1 #include "sysctl_machdep.h" 2 + #include "simple.h" 2 3 #include <sys/errno.h> 4 + #include <alloca.h> 5 + 6 + extern char *strncpy(char *dest, const char *src, __SIZE_TYPE__ n); 3 7 4 8 enum { 5 9 _MACHDEP_CPU = 1000, 6 10 }; 7 11 8 12 enum { 9 - _CPU_BRAND_STRING = 1000, 13 + _CPU_VENDOR = 1000, 14 + _CPU_MAX_BASIC, 15 + _CPU_FAMILY, 16 + _CPU_MODEL, 17 + _CPU_STEPPING, 18 + _CPU_BRAND_STRING, 19 + _CPU_FEATURES, 10 20 }; 11 21 22 + static sysctl_handler(handle_vendor); 23 + static sysctl_handler(handle_max_basic); 24 + static sysctl_handler(handle_family); 25 + static sysctl_handler(handle_model); 26 + static sysctl_handler(handle_stepping); 12 27 static sysctl_handler(handle_brand_string); 28 + static sysctl_handler(handle_features); 13 29 14 30 const struct known_sysctl sysctls_machdep_cpu[] = { 15 - { .oid = _CPU_BRAND_STRING, .type = CTLTYPE_STRING, .exttype = "S", .name = "brand_string", .handler = handle_brand_string }, 31 + { .oid = _CPU_MAX_BASIC, .type = CTLTYPE_INT, .exttype = "I", .name = "max_basic", .handler = handle_max_basic }, 32 + { .oid = _CPU_VENDOR, .type = CTLTYPE_STRING, .exttype = "S", .name = "vendor", .handler = handle_vendor }, 33 + { .oid = _CPU_FAMILY, .type = CTLTYPE_INT, .exttype = "I", .name = "family", .handler = handle_family }, 34 + { .oid = _CPU_MODEL, .type = CTLTYPE_INT, .exttype = "I", .name = "model", .handler = handle_model }, 35 + { .oid = _CPU_STEPPING, .type = CTLTYPE_INT, .exttype = "I", .name = "stepping", .handler = handle_stepping }, 36 + { .oid = _CPU_BRAND_STRING, .type = CTLTYPE_STRING, .exttype = "S", .name = "vendor", .handler = handle_brand_string }, 37 + { .oid = _CPU_FEATURES, .type = CTLTYPE_STRING, .exttype = "S", .name = "features", .handler = handle_features }, 16 38 { .oid = -1 } 17 39 }; 18 40 ··· 28 50 : "0" (level)) 29 51 #endif 30 52 31 - sysctl_handler(handle_brand_string) 53 + #ifndef setup 54 + #define setup(value)\ 55 + unsigned int level = 0; \ 56 + unsigned int eax = value; \ 57 + unsigned int ebx; \ 58 + unsigned int edx; \ 59 + unsigned int ecx 60 + #endif 61 + 62 + 63 + static inline void copyout_int(int value, char* to_copy, size_t* to_copy_length) 64 + { 65 + char tmp[64]; 66 + __simple_sprintf(tmp, "%d", value); 67 + copyout_string(tmp, to_copy, to_copy_length); 68 + } 69 + 70 + 71 + sysctl_handler(handle_vendor) 32 72 { 33 73 unsigned int level = 0; 34 74 unsigned int eax = 0; ··· 51 91 return 0; 52 92 } 53 93 94 + sysctl_handler(handle_max_basic) 95 + { 96 + setup(0); 97 + 98 + 99 + __cpuid(level, eax, ebx, ecx, edx); 100 + 101 + copyout_int(eax, (char*)old,oldlen); 102 + 103 + return 0; 104 + } 105 + 106 + sysctl_handler(handle_family) 107 + { 108 + setup(1); 109 + 110 + __cpuid(level, eax, ebx, ecx, edx); 111 + 112 + eax = eax >> 7; 113 + eax &= 15; 114 + 115 + copyout_int(eax, old, oldlen); 116 + 117 + return 0; 118 + } 119 + 120 + sysctl_handler(handle_model) 121 + { 122 + setup(1); 123 + 124 + __cpuid(level, eax, ebx, ecx, edx); 125 + 126 + eax = eax >> 3; 127 + eax &= 15; 128 + 129 + copyout_int(eax,(char*)old, oldlen); 130 + 131 + return 0; 132 + } 133 + 134 + sysctl_handler(handle_stepping) 135 + { 136 + setup(1); 137 + 138 + __cpuid(level, eax, ebx, ecx, edx); 139 + 140 + eax &= 15; 141 + 142 + copyout_int(eax,(char*)old, oldlen); 143 + 144 + return 0; 145 + } 146 + 147 + sysctl_handler(handle_brand_string) 148 + { 149 + setup(0x80000000); 150 + 151 + __cpuid(level,eax,ebx, ecx, edx); 152 + 153 + if (eax < 0x80000004) // the information is not implemented 154 + return 2; 155 + 156 + 157 + 158 + union 159 + { 160 + unsigned int brand[12]; 161 + char name[49]; 162 + } v; 163 + 164 + for (int i = 1; i < 4; i++) 165 + { 166 + eax = 0x80000000+i; 167 + __cpuid(level, eax, ebx, ecx, edx); 168 + v.brand[0x0+(i-1)*4] = eax; 169 + v.brand[0x1+(i-1)*4] = ebx; 170 + v.brand[0x2+(i-1)*4] = ecx; 171 + v.brand[0x3+(i-1)*4] = edx; 172 + } 173 + 174 + v.name[48] = 0; 175 + copyout_string(v.name, (char*) old, oldlen); 176 + 177 + return 0; 178 + } 179 + 180 + sysctl_handler(handle_features) 181 + { 182 + 183 + setup(1); 184 + 185 + static const char features[][7] = {"FPU","VME", "DE", "PSE", "TSC", "MSR", "PAE", "MCE", "CX8", "APIC", "","SEP","MTRR","PGE", 186 + "MCA", "CMOV", "PAT", "PSE-36", "PSN", "CLFSH", "", "DS", "ACPI", "MMX", "FXSR", "SSE", "SSE2", "SS", 187 + "HTT", "TM","IA64","PBE"}; 188 + 189 + __cpuid(0,eax,ebx,ecx,edx); 190 + int current_length = 0; 191 + 192 + if (old != NULL) 193 + { 194 + 195 + char *outsr = (char*)old; 196 + 197 + for (int i = 0; i < 32; i++) 198 + { 199 + if (i == 10 || i == 20) 200 + continue; 201 + 202 + if ( (edx & (1<<i)) && current_length < *oldlen) 203 + { 204 + if (current_length) 205 + { 206 + outsr[current_length] = ' '; 207 + 208 + current_length++; 209 + } 210 + if (current_length < *oldlen) 211 + { 212 + int len = __simple_strlen(features[i]); 213 + 214 + strncpy(outsr + current_length, features[i], 215 + *oldlen - current_length); 216 + 217 + current_length += len; 218 + } 219 + } 220 + } 221 + 222 + if (current_length < *oldlen) 223 + { 224 + outsr[current_length] = '\0'; 225 + } 226 + 227 + } 228 + else 229 + { 230 + 231 + for (int i = 0; i < 32; i++) 232 + { 233 + 234 + if (i == 10 || i == 20) 235 + continue; 236 + 237 + if (edx & (1<<i)) 238 + { 239 + if (current_length != 0) 240 + current_length++; 241 + 242 + current_length += __simple_strlen(features[i]); 243 + } 244 + 245 + } 246 + 247 + if (oldlen) 248 + *oldlen = current_length; 249 + 250 + } 251 + 252 + 253 + 254 + return 0; 255 + 256 + }
+9 -3
src/startup/darling.c
··· 58 58 const char* DARLING_INIT_COMM = "darling-init"; 59 59 char *prefix; 60 60 uid_t g_originalUid, g_originalGid; 61 + bool g_fixPermissions = false; 61 62 char **g_argv, **g_envp; 62 63 char g_workingDirectory[4096]; 63 64 ··· 106 107 if (!checkPrefixDir()) 107 108 { 108 109 setupPrefix(); 110 + g_fixPermissions = true; 109 111 } 110 112 checkPrefixOwner(); 111 113 ··· 765 767 766 768 opts = (char*) malloc(strlen(prefix)*2 + sizeof(LIBEXEC_PATH) + 100); 767 769 768 - const char* opts_fmt = "lowerdir=%s,upperdir=%s,workdir=%s.workdir,nfs_export=on,uid=%d"; 770 + const char* opts_fmt = "lowerdir=%s,upperdir=%s,workdir=%s.workdir"; 769 771 770 - sprintf(opts, opts_fmt, LIBEXEC_PATH, prefix, prefix, g_originalUid); 772 + sprintf(opts, opts_fmt, LIBEXEC_PATH, prefix, prefix); 771 773 772 774 // Mount overlay onto our prefix 773 - if (mount("darling-overlay", prefix, "darling-overlay", 0, opts) != 0) 775 + if (mount("overlay", prefix, "overlay", 0, opts) != 0) 774 776 { 775 777 fprintf(stderr, "Cannot mount overlay: %s\n", strerror(errno)); 776 778 exit(1); 777 779 } 778 780 779 781 free(opts); 782 + 783 + // This is executed once at prefix creation 784 + if (g_fixPermissions) 785 + fixDirectoryPermissions(prefix); 780 786 781 787 snprintf(putOld, sizeof(putOld), "%s/proc", prefix); 782 788