From 8df8474409b9aae1fe3e460863134b78e3e047df Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 14 Sep 2020 17:27:25 +0000 Subject: [PATCH] Libinfo-542.40.3.tar.gz --- Libinfo.xcodeproj/project.pbxproj | 1 + lookup.subproj/file_module.c | 117 ++++++++++++++++++++++++++++++++++++++ lookup.subproj/muser_module.c | 48 ++++++++++++---- lookup.subproj/si_getaddrinfo.c | 4 +- xcodescripts/install_files.sh | 1 - 5 files changed, 156 insertions(+), 15 deletions(-) diff --git a/Libinfo.xcodeproj/project.pbxproj b/Libinfo.xcodeproj/project.pbxproj index 5df1489..fe67206 100644 --- a/Libinfo.xcodeproj/project.pbxproj +++ b/Libinfo.xcodeproj/project.pbxproj @@ -827,6 +827,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */; buildSettings = { + GCC_OPTIMIZATION_LEVEL = s; IS_ZIPPERED = YES; PRODUCT_NAME = info; }; diff --git a/lookup.subproj/file_module.c b/lookup.subproj/file_module.c index 4f56dbc..9431069 100644 --- a/lookup.subproj/file_module.c +++ b/lookup.subproj/file_module.c @@ -38,6 +38,10 @@ #include #include #include +#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) +#include +#include +#endif /* notify SPI */ uint32_t notify_peek(int token, uint32_t *val); @@ -1716,6 +1720,32 @@ _fsi_get_name_number_aliases(si_mod_t *si, const char *name, int num, int which, /* MOUNT */ +#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) +static si_item_t * +_fsi_parse_edt_fs(si_mod_t *si, const char *name, int which, struct edt_fstab *fs, uint64_t va, uint64_t vb) +{ + int match; + si_item_t *item; + + if (fs == NULL) return NULL; + + match = 0; + + if (which == SEL_ALL) match = 1; + else if ((which == SEL_NAME) && (string_equal(name, fs->fs_spec))) match = 1; + else if ((which == SEL_NUMBER) && (string_equal(name, fs->fs_file))) match = 1; + + if (match == 0) + { + return NULL; + } + + item = (si_item_t *)LI_ils_create("L4488sssss44", (unsigned long)si, CATEGORY_FS, 1, va, vb, fs->fs_spec, fs->fs_file, fs->fs_vfstype, fs->fs_mntops, fs->fs_type, fs->fs_freq, fs->fs_passno); + + return item; +} +#endif + static si_item_t * _fsi_parse_fs(si_mod_t *si, const char *name, int which, char *data, uint64_t va, uint64_t vb) { @@ -1883,6 +1913,75 @@ _fsi_fs_root(si_mod_t *si) return si_item_retain(rootfs); } +#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) +static void * +_fsi_get_edt_fs(si_mod_t *si, const char *name, int which) +{ + void *data; + struct edt_fstab *fstab; + size_t i, size; + si_item_t *item; + si_list_t *all; + uint64_t va, vb; + + if ((which != SEL_ALL) && (name == NULL)) return NULL; + + all = NULL; + item = NULL; + fstab = NULL; + i = 0; + size = 0; + + // obtain fstab information from the EDT provided through this sysctl + if (sysctlbyname(APFS_FSTAB_SYSCTL, NULL, &size, NULL, 0) || !size) + { + return all; + } + + fstab = malloc(size); + if (!fstab) + { + return all; + } + + if (sysctlbyname(APFS_FSTAB_SYSCTL, fstab, &size, NULL, 0)) + { + free(fstab); + return all; + } + size = size / sizeof(struct edt_fstab); + + _fsi_get_validation(si, VALIDATION_FSTAB, _PATH_FSTAB, NULL, &va, &vb); + + forever + { + if (i >= size) + { + free(fstab); + break; + } + + data = fstab + i; + i++; + + item = _fsi_parse_edt_fs(si, name, which, data, va, vb); + + if (item == NULL) continue; + + if (which == SEL_ALL) + { + all = si_list_add(all, item); + si_item_release(item); + continue; + } + + return item; + } + + return all; +} +#endif + static void * _fsi_get_fs(si_mod_t *si, const char *name, int which) { @@ -1904,6 +2003,24 @@ _fsi_get_fs(si_mod_t *si, const char *name, int which) synthesize_root = 0; #endif +#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) + // We still boot using HFS sometimes (e.g. ramdisks) and therefore + // need to conditionalize using the EDT over the fstab file. + // Certain HFS ramdisks rely on the EDT entries. Prefer the EDT + // over the fstab file, but fall back to use the file upon failure + // to obtain the EDT entries. + struct statfs rootfs; + const char *root_path = "/"; + + if (statfs(root_path, &rootfs)) return NULL; + + all = _fsi_get_edt_fs(si, name, which); + if (all || string_equal(rootfs.f_fstypename, "apfs")) + { + return all; + } +#endif + f = fopen(_PATH_FSTAB, "r"); if ((f == NULL) || (synthesize_root == 1)) { diff --git a/lookup.subproj/muser_module.c b/lookup.subproj/muser_module.c index 9de0993..436378c 100644 --- a/lookup.subproj/muser_module.c +++ b/lookup.subproj/muser_module.c @@ -32,6 +32,7 @@ #include #include #include +#include static int _si_muser_disabled = 0; static xpc_pipe_t __muser_pipe; @@ -47,7 +48,9 @@ _muser_call(const char *procname, xpc_object_t payload) xpc_object_t result = NULL; xpc_object_t reply; xpc_pipe_t pipe; - + int rv; + bool retried = false; /* try again incase of usermanager jetsam */ + bool retryagain = false; if (!payload) { return NULL; } pipe = _muser_xpc_pipe(false); @@ -55,17 +58,38 @@ _muser_call(const char *procname, xpc_object_t payload) xpc_dictionary_set_string(payload, kLIMMessageRPCName, procname); xpc_dictionary_set_uint64(payload, kLIMMessageVersion, 1); - - int rv = xpc_pipe_routine(pipe, payload, &reply); - switch (rv) { - case 0: - result = reply; - break; - case EAGAIN: - case EPIPE: - default: - break; - } + + /* if EPIPE, EAGAIN retry once */ + do { + retryagain = false; /* if set from previous pass, reset now */ + rv = xpc_pipe_routine(pipe, payload, &reply); + switch (rv) { + case 0: + result = reply; + break; + case EAGAIN: + case EPIPE: + { + if (retried) { + /* retried already, so bail out */ + os_log_error(OS_LOG_DEFAULT, "_muser_call: Failure (%d) with retry, bailing", rv); + break; + } + /* lets retry one more time as jetsam of usermanager results in EPIPE */ + retried = true; + retryagain = true; + os_log_debug(OS_LOG_DEFAULT, "_muser_call: Error from xpc pipe (%d), retrying", rv); + /* reestablish connetion */ + xpc_release(pipe); + /* reestablish muser pipe */ + pipe = _muser_xpc_pipe(true); + if (!pipe) { return NULL; } + } + break; + default: + break; + } + } while (retryagain); xpc_release(pipe); return result; diff --git a/lookup.subproj/si_getaddrinfo.c b/lookup.subproj/si_getaddrinfo.c index dc7677a..610ec8c 100644 --- a/lookup.subproj/si_getaddrinfo.c +++ b/lookup.subproj/si_getaddrinfo.c @@ -1127,10 +1127,10 @@ static int _gai_nat64_v4_synthesize(uint32_t *index, const struct in_addr *ipv4, if (nat64_v4_synthesize == NULL) { return 0; } - int result = nat64_v4_synthesize(index, ipv4, out_ipv6_addrs); + const int result = nat64_v4_synthesize(index, ipv4, out_ipv6_addrs); os_log_debug(gai_log(), "nat64_v4_synthesize(%d, %{network:in_addr}d, ...) returned %d", index != NULL ? *index : 0, ipv4->s_addr, result); - return nat64_v4_synthesize(index, ipv4, out_ipv6_addrs); + return result; } LIBINFO_EXPORT diff --git a/xcodescripts/install_files.sh b/xcodescripts/install_files.sh index 6f13fa9..d14fbff 100755 --- a/xcodescripts/install_files.sh +++ b/xcodescripts/install_files.sh @@ -58,7 +58,6 @@ if [[ "${ACTION}" == "installhdrs" ]] || [[ "${ACTION}" == "installapi" ]]; then fi if [[ "${PLATFORM_NAME}" =~ "simulator" ]]; then - ln -s libsystem_info.dylib ${DSTROOT}${INSTALL_PATH}/libsystem_sim_info.dylib exit 0 fi -- 2.7.4