this repo has no description
1
fork

Configure Feed

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

Add utimensat (#609)

* Update compatibility_hacks.c

* Add utimensat Wrapper

* Add utimensat to stat.h

* It Works! (kinda)

authored by

TheBrokenRail and committed by
Andrew Hyatt
c0dd7599 edef755d

+226 -15
+7
platform-include/sys/stat.h
··· 362 362 int fchmodat(int, const char *, mode_t, int) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 363 363 int fstatat(int, const char *, struct stat *, int) __DARWIN_INODE64(fstatat) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 364 364 int mkdirat(int, const char *, mode_t) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 365 + 366 + #define UTIME_NOW -1 367 + #define UTIME_OMIT -2 368 + 369 + int futimens(int __fd, const struct timespec __times[2]) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)); 370 + int utimensat(int __fd, const char *__path, const struct timespec __times[2], 371 + int __flag) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)); 365 372 #endif 366 373 367 374 #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
+16 -6
platform-include/sys/syscall.h
··· 29 29 * System call switch table. 30 30 * 31 31 * DO NOT EDIT-- this file is automatically generated. 32 - * created from /home/lubos/Projects/darling/src/kernel/libsyscall/xcodescripts/syscalls.master 32 + * created from bsd/kern/syscalls.master 33 33 */ 34 34 35 35 #ifndef _SYS_SYSCALL_H_ ··· 223 223 #define SYS_seteuid 183 224 224 #define SYS_sigreturn 184 225 225 /* 185 old chud */ 226 - /* 186 */ 226 + #define SYS_thread_selfcounts 186 227 227 #define SYS_fdatasync 187 228 228 #define SYS_stat 188 229 229 #define SYS_fstat 189 ··· 412 412 #define SYS_thread_selfid 372 413 413 #define SYS_ledger 373 414 414 #define SYS_kevent_qos 374 415 - /* 375 */ 415 + #define SYS_kevent_id 375 416 416 /* 376 */ 417 417 /* 377 */ 418 418 /* 378 */ ··· 472 472 #define SYS_audit_session_port 432 473 473 #define SYS_pid_suspend 433 474 474 #define SYS_pid_resume 434 475 - /* 435 */ 476 - /* 436 */ 475 + #define SYS_pid_hibernate 435 476 + #define SYS_pid_shutdown_sockets 436 477 477 /* 437 old shared_region_slide_np */ 478 478 #define SYS_shared_region_map_and_slide_np 438 479 479 #define SYS_kas_info 439 ··· 559 559 /* 519 */ 560 560 #define SYS_terminate_with_payload 520 561 561 #define SYS_abort_with_payload 521 562 - #define SYS_MAXSYSCALL 522 562 + #define SYS_necp_session_open 522 563 + #define SYS_necp_session_action 523 564 + #define SYS_setattrlistat 524 565 + #define SYS_net_qos_guideline 525 566 + #define SYS_fmount 526 567 + #define SYS_ntp_adjtime 527 568 + #define SYS_ntp_gettime 528 569 + #define SYS_os_fault_with_payload 529 570 + /* 530 */ 571 + /* 531 */ 572 + #define SYS_MAXSYSCALL 532 563 573 #define SYS_invalid 63 564 574 565 575 #endif /* __APPLE_API_PRIVATE */
+1
src/kernel/emulation/linux/CMakeLists.txt
··· 206 206 stat/common.c 207 207 xattr/getattrlistbulk.c 208 208 xattr/getattrlistat.c 209 + xattr/setattrlistat.c 209 210 xattr/listxattr.c 210 211 xattr/flistxattr.c 211 212 xattr/removexattr.c
+2
src/kernel/emulation/linux/syscalls.c
··· 170 170 #include "hfs/stub.h" 171 171 #include "xattr/getattrlistbulk.h" 172 172 #include "xattr/getattrlistat.h" 173 + #include "xattr/setattrlistat.h" 173 174 #include "xattr/listxattr.h" 174 175 #include "xattr/flistxattr.h" 175 176 #include "xattr/removexattr.h" ··· 445 446 [500] = sys_getentropy, 446 447 [515] = sys_ulock_wait, 447 448 [516] = sys_ulock_wake, 449 + [524] = sys_setattrlistat, 448 450 }; 449 451
+7
src/kernel/emulation/linux/xattr/setattrlistat.c
··· 1 + #include "setattrlistat.h" 2 + 3 + long sys_setattrlistat() 4 + { 5 + return 0; 6 + } 7 +
+7
src/kernel/emulation/linux/xattr/setattrlistat.h
··· 1 + #ifndef LINUX_SETATTRLISTAT_H 2 + #define LINUX_SETATTRLISTAT_H 3 + 4 + long sys_setattrlistat(); 5 + 6 + #endif 7 +
+2
src/kernel/libsyscall/CMakeLists.txt
··· 114 114 wrappers/unlinkat.c 115 115 wrappers/unlink.c 116 116 wrappers/work_interval.c 117 + wrappers/utimensat.c 117 118 118 119 wrappers/legacy/select-pre1050.c 119 120 ··· 257 258 bsdsyscalls/_fremovexattr.S 258 259 bsdsyscalls/_fsctl.S 259 260 bsdsyscalls/_fsetattrlist.S 261 + bsdsyscalls/_setattrlistat.S 260 262 bsdsyscalls/_fsetxattr.S 261 263 bsdsyscalls/_fsgetpath.S 262 264 bsdsyscalls/___fsgetpath.S
+11
src/kernel/libsyscall/bsdsyscalls/_setattrlistat.S
··· 1 + #define __SYSCALL_32BIT_ARG_BYTES 20 2 + #include "SYS.h" 3 + 4 + #ifndef SYS_setattrlistat 5 + #error "SYS_setattrlistat not defined. The header files libsyscall is building against do not match syscalls.master." 6 + #endif 7 + 8 + #if defined(__i386__) || defined(__x86_64__) 9 + __SYSCALL2(_setattrlistat, setattrlistat, 6, cerror_nocancel) 10 + #endif 11 +
+134
src/kernel/libsyscall/wrappers/utimensat.c
··· 1 + /* 2 + * Copyright (c) 2006, 2017 Apple Computer, Inc. All rights reserved. 3 + * 4 + * @APPLE_LICENSE_HEADER_START@ 5 + * 6 + * This file contains Original Code and/or Modifications of Original Code 7 + * as defined in and that are subject to the Apple Public Source License 8 + * Version 2.0 (the 'License'). You may not use this file except in 9 + * compliance with the License. Please obtain a copy of the License at 10 + * http://www.opensource.apple.com/apsl/ and read it before using this 11 + * file. 12 + * 13 + * The Original Code and all software distributed under the License are 14 + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 + * Please see the License for the specific language governing rights and 19 + * limitations under the License. 20 + * 21 + * @APPLE_LICENSE_HEADER_END@ 22 + */ 23 + 24 + #include <sys/types.h> 25 + #include <sys/stat.h> 26 + #include <sys/attr.h> 27 + #include <sys/time.h> 28 + #include <sys/fcntl.h> 29 + #include <unistd.h> 30 + #include <strings.h> 31 + 32 + extern int __gettimeofday(struct timeval *, struct timezone *); 33 + extern int __commpage_gettimeofday(struct timeval *); 34 + 35 + static struct timespec times_now[2] = { 36 + { .tv_nsec = UTIME_NOW }, 37 + { .tv_nsec = UTIME_NOW } 38 + }; 39 + 40 + /* 41 + * Resolve any UTIME_NOW or UTIME_OMIT and return the attributes buffer and 42 + * attributes to pass. Assumes times_in is writable. 43 + */ 44 + static int 45 + prepare_times_array_and_attrs(struct timespec times_in[2], 46 + struct timespec times_out[2], size_t *times_out_size) 47 + { 48 + if (times_in[0].tv_nsec == UTIME_OMIT && 49 + times_in[1].tv_nsec == UTIME_OMIT) { 50 + return 0; 51 + } 52 + 53 + if (times_in[0].tv_nsec == UTIME_NOW || 54 + times_in[1].tv_nsec == UTIME_NOW) { 55 + struct timespec now = {}; 56 + { 57 + /* 58 + * TODO: Replace with nanosecond time when available 59 + */ 60 + struct timeval tv; 61 + if (__commpage_gettimeofday(&tv) != 0) { 62 + __gettimeofday(&tv, NULL); 63 + } 64 + TIMEVAL_TO_TIMESPEC(&tv, &now); 65 + } 66 + 67 + if (times_in[0].tv_nsec == UTIME_NOW) { 68 + times_in[0] = now; 69 + } 70 + if (times_in[1].tv_nsec == UTIME_NOW) { 71 + times_in[1] = now; 72 + } 73 + } 74 + 75 + int attrs = 0; 76 + *times_out_size = 0; 77 + struct timespec *times_cursor = times_out; 78 + if (times_in[1].tv_nsec != UTIME_OMIT) { 79 + attrs |= ATTR_CMN_MODTIME; 80 + *times_cursor++ = times_in[1]; 81 + *times_out_size += sizeof(struct timespec); 82 + } 83 + if (times_in[0].tv_nsec != UTIME_OMIT) { 84 + attrs |= ATTR_CMN_ACCTIME; 85 + *times_cursor = times_in[0]; 86 + *times_out_size += sizeof(struct timespec); 87 + } 88 + return attrs; 89 + } 90 + 91 + int 92 + futimens(int fd, const struct timespec _times_in[2]) 93 + { 94 + struct timespec times_in[2]; 95 + if (_times_in != NULL) { 96 + memcpy(&times_in, _times_in, sizeof(times_in)); 97 + } else { 98 + memcpy(&times_in, times_now, sizeof(times_in)); 99 + } 100 + 101 + size_t attrbuf_size = 0; 102 + struct timespec times_out[2] = {}; 103 + struct attrlist a = { 104 + .bitmapcount = ATTR_BIT_MAP_COUNT 105 + }; 106 + a.commonattr = prepare_times_array_and_attrs(times_in, times_out, &attrbuf_size); 107 + 108 + return fsetattrlist(fd, &a, &times_out, attrbuf_size, 0); 109 + } 110 + 111 + int 112 + utimensat(int fd, const char *path, const struct timespec _times_in[2], int flags) 113 + { 114 + struct timespec times_in[2]; 115 + if (_times_in != NULL) { 116 + memcpy(&times_in, _times_in, sizeof(times_in)); 117 + } else { 118 + memcpy(&times_in, times_now, sizeof(times_in)); 119 + } 120 + 121 + size_t attrbuf_size = 0; 122 + struct timespec times_out[2] = {}; 123 + struct attrlist a = { 124 + .bitmapcount = ATTR_BIT_MAP_COUNT 125 + }; 126 + a.commonattr = prepare_times_array_and_attrs(times_in, times_out, &attrbuf_size); 127 + 128 + int flags_out = 0; 129 + if (flags & AT_SYMLINK_NOFOLLOW) { 130 + flags_out |= FSOPT_NOFOLLOW; 131 + } 132 + 133 + return setattrlistat(fd, path, &a, &times_out, attrbuf_size, flags_out); 134 + }
+36 -9
src/kernel/libsyscall/xcodescripts/syscalls.master
··· 102 102 52 AUE_SIGPENDING ALL { int sigpending(struct sigvec *osv); } 103 103 53 AUE_SIGALTSTACK ALL { int sigaltstack(struct sigaltstack *nss, struct sigaltstack *oss) NO_SYSCALL_STUB ; } 104 104 54 AUE_IOCTL ALL { int ioctl(int fd, u_long com, caddr_t data) NO_SYSCALL_STUB; } 105 - 55 AUE_REBOOT ALL { int reboot(int opt, char *command); } 105 + 55 AUE_REBOOT ALL { int reboot(int opt, char *command) NO_SYSCALL_STUB; } 106 106 56 AUE_REVOKE ALL { int revoke(char *path); } 107 107 57 AUE_SYMLINK ALL { int symlink(char *path, char *link); } 108 108 58 AUE_READLINK ALL { int readlink(char *path, char *buf, int count); } ··· 262 262 174 AUE_NULL ALL { int nosys(void); } { old getdents } 263 263 175 AUE_NULL ALL { int nosys(void); } { old gc_control } 264 264 176 AUE_NULL ALL { int nosys(void); } { old add_profil } 265 - 177 AUE_KDEBUGTRACE ALL { int kdebug_typefilter(void** addr, size_t* size) NO_SYSCALL_STUB; } 266 - 178 AUE_KDEBUGTRACE ALL { uint64_t kdebug_trace_string(uint32_t debugid, uint64_t str_id, const char *str) NO_SYSCALL_STUB; } 267 - 179 AUE_KDEBUGTRACE ALL { int kdebug_trace64(uint32_t code, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) NO_SYSCALL_STUB; } 268 - 180 AUE_KDEBUGTRACE ALL { int kdebug_trace(uint32_t code, u_long arg1, u_long arg2, u_long arg3, u_long arg4) NO_SYSCALL_STUB; } 265 + 177 AUE_NULL ALL { int kdebug_typefilter(void** addr, size_t* size) NO_SYSCALL_STUB; } 266 + 178 AUE_NULL ALL { uint64_t kdebug_trace_string(uint32_t debugid, uint64_t str_id, const char *str) NO_SYSCALL_STUB; } 267 + 179 AUE_NULL ALL { int kdebug_trace64(uint32_t code, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) NO_SYSCALL_STUB; } 268 + 180 AUE_NULL ALL { int kdebug_trace(uint32_t code, u_long arg1, u_long arg2, u_long arg3, u_long arg4) NO_SYSCALL_STUB; } 269 269 181 AUE_SETGID ALL { int setgid(gid_t gid); } 270 270 182 AUE_SETEGID ALL { int setegid(gid_t egid); } 271 271 183 AUE_SETEUID ALL { int seteuid(uid_t euid); } 272 272 184 AUE_SIGRETURN ALL { int sigreturn(struct ucontext *uctx, int infostyle) NO_SYSCALL_STUB; } 273 273 185 AUE_NULL ALL { int enosys(void); } { old chud } 274 - 186 AUE_NULL ALL { int nosys(void); } 274 + 186 AUE_NULL ALL { int thread_selfcounts(int type, user_addr_t buf, user_size_t nbytes); } 275 275 187 AUE_FDATASYNC ALL { int fdatasync(int fd); } 276 276 188 AUE_STAT ALL { int stat(user_addr_t path, user_addr_t ub); } 277 277 189 AUE_FSTAT ALL { int fstat(int fd, user_addr_t ub); } ··· 565 565 372 AUE_NULL ALL { uint64_t thread_selfid (void) NO_SYSCALL_STUB; } 566 566 373 AUE_LEDGER ALL { int ledger(int cmd, caddr_t arg1, caddr_t arg2, caddr_t arg3); } 567 567 374 AUE_NULL ALL { int kevent_qos(int fd, const struct kevent_qos_s *changelist, int nchanges, struct kevent_qos_s *eventlist, int nevents, void *data_out, size_t *data_available, unsigned int flags); } 568 - 375 AUE_NULL ALL { int nosys(void); } 568 + 375 AUE_NULL ALL { int kevent_id(uint64_t id, const struct kevent_qos_s *changelist, int nchanges, struct kevent_qos_s *eventlist, int nevents, void *data_out, size_t *data_available, unsigned int flags); } 569 569 376 AUE_NULL ALL { int nosys(void); } 570 570 377 AUE_NULL ALL { int nosys(void); } 571 571 378 AUE_NULL ALL { int nosys(void); } ··· 666 666 432 AUE_NULL ALL { int audit_session_port(au_asid_t asid, user_addr_t portnamep); } 667 667 433 AUE_NULL ALL { int pid_suspend(int pid); } 668 668 434 AUE_NULL ALL { int pid_resume(int pid); } 669 + #if CONFIG_EMBEDDED 670 + 435 AUE_NULL ALL { int pid_hibernate(int pid); } 671 + #else 669 672 435 AUE_NULL ALL { int nosys(void); } 673 + #endif 674 + #if SOCKETS 675 + 436 AUE_NULL ALL { int pid_shutdown_sockets(int pid, int level); } 676 + #else 670 677 436 AUE_NULL ALL { int nosys(void); } 678 + #endif 671 679 437 AUE_NULL ALL { int nosys(void); } { old shared_region_slide_np } 672 680 438 AUE_NULL ALL { int shared_region_map_and_slide_np(int fd, uint32_t count, const struct shared_file_mapping_np *mappings, uint32_t slide, uint64_t* slide_start, uint32_t slide_size) NO_SYSCALL_STUB; } 673 681 439 AUE_NULL ALL { int kas_info(int selector, void *value, size_t *size); } ··· 676 684 #else 677 685 440 AUE_NULL ALL { int nosys(void); } 678 686 #endif 679 - 441 AUE_OPEN_RWTC ALL { int guarded_open_np(const char *path, const guardid_t *guard, u_int guardflags, int flags, int mode) NO_SYSCALL_STUB; } 687 + 441 AUE_OPEN_RWTC ALL { int guarded_open_np(user_addr_t path, const guardid_t *guard, u_int guardflags, int flags, int mode) NO_SYSCALL_STUB; } 680 688 442 AUE_CLOSE ALL { int guarded_close_np(int fd, const guardid_t *guard); } 681 689 443 AUE_KQUEUE ALL { int guarded_kqueue_np(const guardid_t *guard, u_int guardflags); } 682 690 444 AUE_NULL ALL { int change_fdguard_np(int fd, const guardid_t *guard, u_int guardflags, const guardid_t *nguard, u_int nguardflags, int *fdflagsp); } ··· 752 760 #else 753 761 483 AUE_NULL ALL { int enosys(void); } 754 762 #endif /* CSR */ 755 - 484 AUE_NULL ALL { int guarded_open_dprotected_np(const char *path, const guardid_t *guard, u_int guardflags, int flags, int dpclass, int dpflags, int mode) NO_SYSCALL_STUB; } 763 + 484 AUE_NULL ALL { int guarded_open_dprotected_np(user_addr_t path, const guardid_t *guard, u_int guardflags, int flags, int dpclass, int dpflags, int mode) NO_SYSCALL_STUB; } 756 764 485 AUE_NULL ALL { user_ssize_t guarded_write_np(int fd, const guardid_t *guard, user_addr_t cbuf, user_size_t nbyte); } 757 765 486 AUE_PWRITE ALL { user_ssize_t guarded_pwrite_np(int fd, const guardid_t *guard, user_addr_t buf, user_size_t nbyte, off_t offset); } 758 766 487 AUE_WRITEV ALL { user_ssize_t guarded_writev_np(int fd, const guardid_t *guard, struct iovec *iovp, int iovcnt); } ··· 773 781 #else 774 782 492 AUE_NULL ALL { int enosys(void); } 775 783 #endif /* CONFIG_TELEMETRY */ 784 + #if PGO 776 785 493 AUE_NULL ALL { user_ssize_t grab_pgo_data (user_addr_t uuid, int flags, user_addr_t buffer, user_ssize_t size); } 786 + #else 787 + 493 AUE_NULL ALL { int enosys(void); } 788 + #endif 777 789 #if CONFIG_PERSONAS 778 790 494 AUE_PERSONA ALL { int persona(uint32_t operation, uint32_t flags, struct kpersona_info *info, uid_t *id, size_t *idlen) NO_SYSCALL_STUB; } 779 791 #else ··· 811 823 519 AUE_NULL ALL { int enosys(void); } 812 824 520 AUE_KILL ALL { int terminate_with_payload(int pid, uint32_t reason_namespace, uint64_t reason_code, void *payload, uint32_t payload_size, const char *reason_string, uint64_t reason_flags) NO_SYSCALL_STUB; } 813 825 521 AUE_EXIT ALL { void abort_with_payload(uint32_t reason_namespace, uint64_t reason_code, void *payload, uint32_t payload_size, const char *reason_string, uint64_t reason_flags) NO_SYSCALL_STUB; } 826 + #if NECP 827 + 522 AUE_NECP ALL { int necp_session_open(int flags); } } 828 + 523 AUE_NECP ALL { int necp_session_action(int necp_fd, uint32_t action, uint8_t *in_buffer, size_t in_buffer_length, uint8_t *out_buffer, size_t out_buffer_length); } 829 + #else /* NECP */ 830 + 522 AUE_NULL ALL { int enosys(void); } 831 + 523 AUE_NULL ALL { int enosys(void); } 832 + #endif /* NECP */ 833 + 524 AUE_SETATTRLISTAT ALL { int setattrlistat(int fd, const char *path, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, uint32_t options); } 834 + 525 AUE_NET ALL { int net_qos_guideline(struct net_qos_param *param, uint32_t param_len); } 835 + 526 AUE_FMOUNT ALL { int fmount(const char *type, int fd, int flags, void *data); } 836 + 527 AUE_NULL ALL { int ntp_adjtime(struct timex *tp); } 837 + 528 AUE_NULL ALL { int ntp_gettime(struct ntptimeval *ntvp); } 838 + 529 AUE_NULL ALL { int os_fault_with_payload(uint32_t reason_namespace, uint64_t reason_code, void *payload, uint32_t payload_size, const char *reason_string, uint64_t reason_flags); } 839 + 530 AUE_NULL ALL { int enosys(void); } 840 + 531 AUE_NULL ALL { int enosys(void); }
+3
src/libc/darwin/compatibility_hacks.c
··· 36 36 ".previous") 37 37 38 38 #define ADDED_IN_10_12(sym) WEAK_SYMBOL_LD_CMD(sym, 10.11) 39 + #define ADDED_IN_10_13(sym) WEAK_SYMBOL_LD_CMD(sym, 10.12) 39 40 40 41 ADDED_IN_10_12(getentropy); 41 42 ··· 48 49 49 50 ADDED_IN_10_12(mkostemp); 50 51 ADDED_IN_10_12(mkostemps); 52 + 53 + ADDED_IN_10_13(utimensat); 51 54 52 55 #endif /* TARGET_OS_IPHONE */