Skip to content

Commit

Permalink
Fix iOS 15 container_name
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfugil committed Aug 9, 2024
1 parent c2d6623 commit a69d194
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
20 changes: 20 additions & 0 deletions apfs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <mach/mach.h>

extern kern_return_t APFSVolumeDelete(const char *dev);

int main(int argc, const char **argv)
{
if(argc != 2)
{
fprintf(stderr, "Usage: %s diskN\n", argv[0]);
return -1;
}
kern_return_t ret = APFSVolumeDelete(argv[1]);
if(ret != KERN_SUCCESS)
{
fprintf(stderr, "APFSVolumeDelete: %s\n", mach_error_string(ret));
return -1;
}
return 0;
}
26 changes: 4 additions & 22 deletions src/payload/loader/setup_fakefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,11 @@ const char* volume_prefix(void) {
}

const char* container_name(void) {
static char prefix[32] = {'\0'};
static char prefix[32] = { '\0' };
if (prefix[0] != '\0') return prefix;
struct statfs rootfs_st;
CHECK_ERROR(statfs("/", &rootfs_st), 1, "statfs / failed");
if (strcmp(rootfs_st.f_fstypename, "apfs")) {
_panic("unexpected filesystem type of /");
}

char* pBSDName;
if ((pBSDName = strstr(rootfs_st.f_mntfromname, "@/dev/"))) {
pBSDName = &pBSDName[6];
} else {
pBSDName = rootfs_st.f_mntfromname;
}

char* suffix = pBSDName;
for (size_t i = 4; pBSDName[i] != '\0'; i++) {
if (pBSDName[i] == 's') {
pBSDName[i] = '\0';
break;
}
}
snprintf(prefix, 32, "%s", pBSDName);
const char* volume_pre = volume_prefix();
snprintf(prefix, 32, "%s", volume_pre);
prefix[strlen(prefix)-1] = '\0';
return prefix;
}

Expand Down

0 comments on commit a69d194

Please sign in to comment.