]> git.saurik.com Git - apple/libinfo.git/commitdiff
Libinfo-542.40.3.tar.gz master macos-1101 v542.40.3
authorApple <opensource@apple.com>
Mon, 14 Sep 2020 17:27:25 +0000 (17:27 +0000)
committerApple <opensource@apple.com>
Mon, 14 Sep 2020 17:27:25 +0000 (17:27 +0000)
Libinfo.xcodeproj/project.pbxproj
lookup.subproj/file_module.c
lookup.subproj/muser_module.c
lookup.subproj/si_getaddrinfo.c
xcodescripts/install_files.sh

index 5df148929c546bdfbdc68a9c0f85a7ecfe7d1770..fe6720631f21ed877a00ab57867f770928b15e35 100644 (file)
                        isa = XCBuildConfiguration;
                        baseConfigurationReference = 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */;
                        buildSettings = {
+                               GCC_OPTIMIZATION_LEVEL = s;
                                IS_ZIPPERED = YES;
                                PRODUCT_NAME = info;
                        };
index 4f56dbc22d8fe8e87370da631608dde627cda231..94310691d863c4e6460b3d5b05bda03ea4746da9 100644 (file)
 #include <ils.h>
 #include <dispatch/dispatch.h>
 #include <TargetConditionals.h>
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
+#include <sys/sysctl.h>
+#include <apfs/apfs_sysctl.h>
+#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))
        {
index 9de0993da5465118abe3166b178cee7df0984fa2..436378c574fe14f43f3c6a6f47ff6888555823d4 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include <xpc/xpc.h>
 #include <xpc/private.h>
+#include <os/log.h>
 
 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;
index dc7677a7a67083928cc52b4df0d7a729e6cb5e69..610ec8c3a01f2618330326bf3c8008c4ccee9bf7 100644 (file)
@@ -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
index 6f13fa94e197376a095dda85286c79356996c071..d14fbffc5b65c866e581a4ac59b25020ac755aae 100755 (executable)
@@ -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