Skip to content

Commit

Permalink
add -S option to increase rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
xerub committed Jun 28, 2015
1 parent 9fccdd9 commit 2c8076d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ipsw-patch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ int main(int argc, char* argv[]) {
Volume* rootVolume;
size_t rootSize;
size_t preferredRootSize = 0;
size_t preferredRootSizeAdd = 0;
size_t minimumRootSize = 0;

char* ramdiskFSPathInIPSW;
Expand Down Expand Up @@ -132,7 +133,7 @@ int main(int argc, char* argv[]) {
unsigned int* pIV = NULL;

if(argc < 3) {
XLOG(0, "usage %s <input.ipsw> <target.ipsw> [-b <bootimage.png>] [-r <recoveryimage.png>] [-s <system partition size>] [-memory] [-bbupdate] [-nowipe] [-e \"<action to exclude>\"] [-ramdiskgrow <blocks>] [[-unlock] [-use39] [-use46] [-cleanup] -3 <bootloader 3.9 file> -4 <bootloader 4.6 file>] <package1.tar> <package2.tar>...\n", argv[0]);
XLOG(0, "usage %s <input.ipsw> <target.ipsw> [-b <bootimage.png>] [-r <recoveryimage.png>] [-s <system partition size>] [-S <system partition add>] [-memory] [-bbupdate] [-nowipe] [-e \"<action to exclude>\"] [-ramdiskgrow <blocks>] [[-unlock] [-use39] [-use46] [-cleanup] -3 <bootloader 3.9 file> -4 <bootloader 4.6 file>] <package1.tar> <package2.tar>...\n", argv[0]);
return 0;
}

Expand All @@ -159,6 +160,14 @@ int main(int argc, char* argv[]) {
continue;
}

if(strcmp(argv[i], "-S") == 0) {
int size;
sscanf(argv[i + 1], "%d", &size);
preferredRootSizeAdd = size;
i++;
continue;
}

if(strcmp(argv[i], "-ramdiskgrow") == 0) {
int size;
sscanf(argv[i + 1], "%d", &size);
Expand Down Expand Up @@ -417,15 +426,15 @@ int main(int argc, char* argv[]) {
for(j = mergePaths; j < argc; j++) {
AbstractFile* tarFile = createAbstractFileFromFile(fopen(argv[j], "rb"));
if(tarFile) {
defaultRootSize += (tarFile->getLength(tarFile) + 1024 * 1024 - 1) / (1024 * 1024) + 1; // duh
defaultRootSize += (tarFile->getLength(tarFile) + 1024 * 1024 - 1) / (1024 * 1024); // poor estimate
tarFile->close(tarFile);
}
}
minimumRootSize = defaultRootSize * 1024 * 1024;
minimumRootSize -= minimumRootSize % 512;

if(preferredRootSize == 0) {
preferredRootSize = defaultRootSize;
preferredRootSize = defaultRootSize + preferredRootSizeAdd;
}

rootSize = preferredRootSize * 1024 * 1024;
Expand Down

0 comments on commit 2c8076d

Please sign in to comment.