Run a virtual iPhone on an Apple Silicon Mac.
Swift
Keep the host's fseventsd log out of the restore image
Maximilian Paß89736979d2fe
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex 40b99398..450e7c48 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -3319,3 +3319,12 @@ seal. So for a VM whose plan enables `filesystem-boot-cryptex_merge`:`vm create` and Launchpad now record the preset before `fw prepare`, whichread `standard` before: the GPU staging followed the wrong selection for anyother preset as well.++The merged image must not carry the host's `.fseventsd`. `diskutil image+attach` mounts it browsable, so fseventsd starts a log on every writable+mount, and Apple's system volumes have none. With the log in the image, the+mtree listed `.fseventsd`, the restore wrote `.fseventsd/.ramdisk-boot-done`+into the restored volume, and `seal_system_volume` failed ("mtree: cannot+generate the XML dictionary", 26.6 on cloudOS 23E5207q, 2026-10-19). Each+writable mount now deletes the directory before it unmounts, which also stops+fseventsd writing it again for that mount.diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcher.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcher.swiftindex 74b2ff1a..2742d54b 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcher.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcher.swift@@ -180,6 +180,7 @@ public final class CryptexFilesystemPatcher: BufferedPatcher {if gate.isEnabled(FirmwareRestoreImagePatchSet.launchdCacheLoader) {try patchLaunchdCacheLoader(targetMount: targetMount)}+ try removeHostEventLog(mount: targetMount)}guard attachedDevices.isEmpty else {diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swiftindex 73ffb409..3c1c0adc 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherDiskImage.swift@@ -142,6 +142,21 @@ extension CryptexFilesystemPatcher {])}+ /// Delete the event log the host's fseventsd keeps on a writable mount.+ ///+ /// Apple's system volumes have no `.fseventsd`, and the restore writes+ /// `.fseventsd/.ramdisk-boot-done` into the one it restores. A log the host+ /// left in the image shows up in the mtree, the restored volume then no+ /// longer matches it, and the restore fails at `seal_system_volume`+ /// ("mtree: cannot generate the XML dictionary"). Deleting the directory on+ /// the mounted volume also stops fseventsd writing it again for this mount.+ func removeHostEventLog(mount: String) throws {+ let log = URL(fileURLWithPath: mount).appending(path: ".fseventsd")+ if FileManager.default.fileExists(atPath: log.path) {+ try FileManager.default.removeItem(at: log)+ }+ }+func unmount(mount: String) throws {_ = try runProcess("/usr/sbin/diskutil", ["unmount", mount])}diff --git a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherSealing.swift b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherSealing.swiftindex d0a7f21b..557071f8 100644--- a/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherSealing.swift+++ b/VPhoneExecutable/VPhoneCommand/FirmwarePatcher/CryptexFilesystem/CryptexFilesystemPatcherSealing.swift@@ -96,6 +96,7 @@ extension CryptexFilesystemPatcher {print("Modification time: \(remap ? modificationTime : "none")")FileManager.default.createFile(atPath: mtreeRemapPath.path, contents: remapContent.data(using: .utf8))+ try removeHostEventLog(mount: mount)try unmount(mount: mount)let sealvolume = try identifyApfsSealvolume()FileManager.default.createFile(atPath: sealLogPath.path, contents: nil)@@ -179,6 +180,9 @@ extension CryptexFilesystemPatcher {"/private/var/MobileAsset/PreinstalledAssetsV2","/private/var/staged_system_apps",]+ // First: createDigestAndHash takes the remap time from /private/var,+ // so the removals below have to be the last change to the volume.+ try removeHostEventLog(mount: mount)var didEdit = falsefor path in removedPaths {if FileManager.default.fileExists(atPath: mount.appending(path)) {