diff --git a/src/payload/loader/prelaunchd.c b/src/payload/loader/prelaunchd.c index de17d7d..463dd05 100644 --- a/src/payload/loader/prelaunchd.c +++ b/src/payload/loader/prelaunchd.c @@ -54,7 +54,6 @@ int prelaunchd(uint32_t payload_options, struct paleinfo* pinfo_p) { if ((pinfo_p->flags & (palerain_option_rootful | palerain_option_force_revert)) == (palerain_option_rootful | palerain_option_force_revert)) { if (pinfo_p->flags & palerain_option_ssv) { - char dev_rootdev[32]; CFMutableArrayRef fsArray; int retval = APFSVolumeRoleFind(container_name(), APFS_VOL_ROLE_RECOVERY, &fsArray); if (retval && retval != 49245) { @@ -62,22 +61,23 @@ int prelaunchd(uint32_t payload_options, struct paleinfo* pinfo_p) { } if (!retval) { - CFStringGetCString(CFArrayGetValueAtIndex(fsArray, 0), dev_rootdev, 32, kCFStringEncodingUTF8); - CFRelease(fsArray); - } - - if (!retval && access(dev_rootdev, F_OK) == 0) { - printf("will delete %s\n", dev_rootdev); - int16_t role = 0; - // 49154 = container not found, 49254 = volume with role not found - CHECK_ERROR(APFSVolumeRole(dev_rootdev, &role, NULL), 0, "APFSVolumeRole(%s) Failed", dev_rootdev); - printf("found apfs volume role: 0x%04x\n", role); - if (role != APFS_VOL_ROLE_RECOVERY) { - _panic("BUG: SAFETY: deleting non-recovery volume is not allowed\n"); - } else { - CHECK_ERROR(errno = APFSVolumeDelete(&dev_rootdev[5]), 1, "failed to delete fakefs"); - nvram(kIONVRAMDeletePropertyKey, "p1-fakefs-rootdev"); + CFIndex fsCount = CFArrayGetCount(fsArray); + for (CFIndex i = 0; i < fsCount; i++) { + char dev_rootdev[32]; + CFStringGetCString(CFArrayGetValueAtIndex(fsArray, i), dev_rootdev, 32, kCFStringEncodingUTF8); + printf("will delete %s\n", dev_rootdev); + int16_t role = 0; + // 49154 = container not found, 49254 = volume with role not found + CHECK_ERROR(APFSVolumeRole(dev_rootdev, &role, NULL), 0, "APFSVolumeRole(%s) Failed", dev_rootdev); + printf("found apfs volume role: 0x%04x\n", role); + if (role != APFS_VOL_ROLE_RECOVERY) { + _panic("BUG: SAFETY: deleting non-recovery volume is not allowed\n"); + } else { + CHECK_ERROR(errno = APFSVolumeDelete(&dev_rootdev[5]), 1, "failed to delete fakefs"); + } } + CFRelease(fsArray); + nvram(kIONVRAMDeletePropertyKey, "p1-fakefs-rootdev"); } } }