Run a virtual iPhone on an Apple Silicon Mac.
Swift
Grow an OS image diskutil will not grow before merging the cryptexes
Maximilian Paßecb7416c9db3
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex 97f9a856..d0b0ff0b 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -3817,6 +3817,18 @@ On macOS 26.6.2 two more steps failed (2026-10-23, Mac mini M4):which gave the same image 2.7 GB free. The iOS images, which diskutil cangrow, are resized as before.+Corrected 2026-10-24 (macOS 26.5.1, Minimal preset): the iOS OS images have+no partition map either. iPhone17,3 26.5 23F77's `094-54920-099` converts to a+9.31 GB RAW image with 537 MB free, and `diskutil image resize -plist` reports+max = current for it, so `convertToRawImage`'s resize to max left it as it+was. Merging the System OS cryptex (5.2 GB) then ran out of space in the image+("dyld_shared_cache_arm64e.09: No space left on device"), for iOS 18.6 22G86+as well; a 2.12.0 bundle that had built both a day earlier failed the same+way on the same host. `convertToRawImage` keeps the resize to max where it+grows the image and otherwise grows it as `growImage` does, by 16 GiB+(`mergeHeadroom`): the room is sparse, and `shrinkImage` gives it back after+the merge.+The binaries the merge patches (`launchd_cache_loader`, `mobileactivationd`)are re-signed in Apple's ad-hoc shape (`VPhoneSignOptions.Style.appleAdHoc`),like the stock binaries around them. The guest's TXM is stock here: it takesdiff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swiftindex 710caad3..25a6536f 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swift@@ -41,11 +41,24 @@ extension CryptexFilesystemPatcher {"image", "resize", "-plist", output.path,])let maxsize = try Self.maxResizeSize(fromDiskutilPlist: sizes)- _ = try runProcess("/usr/sbin/diskutil", [- "image", "resize", "-size", maxsize, output.path,- ])+ let size = (try FileManager.default.attributesOfItem(atPath: output.path)[.size] as? NSNumber)?.int64Value ?? 0+ if let limit = Int64(maxsize), limit > size {+ _ = try runProcess("/usr/sbin/diskutil", [+ "image", "resize", "-size", maxsize, output.path,+ ])+ return+ }+ // An OS image with no partition map (iOS 26.5's 094-54920-099, 9.3 GB+ // with 537 MB free) has its container on the whole file, and diskutil's+ // max is then its current size: merging the System OS cryptex ran out+ // of space in the image. It grows as growImage grows such an image;+ // the room is sparse, and shrinkImage gives it back after the merge.+ try growImage(dmg: output, by: Self.mergeHeadroom)}+ /// Room the cryptexes and the guest additions need on the OS volume.+ static let mergeHeadroom: Int64 = 16 << 30+/// The `max` value out of `diskutil image resize --plist`, as the string/// `--size` wants back.///@@ -126,7 +139,7 @@ extension CryptexFilesystemPatcher {let probe = try runProcess("/usr/sbin/diskutil", ["image", "attach", "-noMount", dmg.path])detachReportedImage(in: probe)guard !Self.hasPartitionMap(attachOutput: probe) else {- throw ProcessError.failed(0, "\(dmg.lastPathComponent) has a partition map, and diskutil grows it no further than \(limit.map(String.init) ?? "its current size") bytes; the seal needs \(bytes) more")+ throw ProcessError.failed(0, "\(dmg.lastPathComponent) has a partition map, and diskutil grows it no further than \(limit.map(String.init) ?? "its current size") bytes; \(bytes) more are needed")}let handle = try FileHandle(forWritingTo: dmg)try handle.truncate(atOffset: UInt64(size + bytes))