From: maniacikarus Date: Sat, 25 Aug 2007 16:49:41 +0000 (+0000) Subject: Disk Berechnung im Installer umgestellt X-Git-Tag: v2.3-beta1~436 X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=commitdiff_plain;h=ffd4d19666a57d8665cc19b0abb2ea7e5dbbd403 Disk Berechnung im Installer umgestellt git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@827 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- diff --git a/src/install+setup/install/main.c b/src/install+setup/install/main.c index 3847beba89..ee476358bb 100644 --- a/src/install+setup/install/main.c +++ b/src/install+setup/install/main.c @@ -51,33 +51,6 @@ int detect_smp() { return (cpu_count > 1); } -long calc_swapsize(long memory, long disk) { - if (memory < 128) { - return 256; - } - else if (memory > 1024) { - return 512; - } - else { - return memory; - } -} - -long calc_rootsize(long free, long max) { - long root; - - root = max / 2; - if (root < 256) { - return 0; - } - else if (root > 2048) { - return 2048; - } - else { - return 400; - } -} - int main(int argc, char *argv[]) { char *langnames[] = { "Deutsch", "English", NULL }; @@ -108,8 +81,7 @@ int main(int argc, char *argv[]) FILE *handle, *cmdfile; char line[STRING_SIZE]; char string[STRING_SIZE]; - long maximum_free = 0, current_free; - long memory = 0; + long memory = 0; disk = 0, free; long system_partition, boot_partition, root_partition, swap_file; int scsi_disk = 0; char *yesnoharddisk[3]; // char *yesnoharddisk = { "NO", "YES", NULL }; @@ -372,21 +344,28 @@ int main(int argc, char *argv[]) if ((handle = fopen("/tmp/disksize", "r"))) { fgets(line, STRING_SIZE-1, handle); if (sscanf (line, "%s", string)) { - maximum_free = atoi(string) / 1024; + disk = atoi(string) / 1024; } fclose(handle); } - fprintf(flog, "maximum_free = %ld, memory = %ld", maximum_free, memory); + fprintf(flog, "Disksize = %ld, memory = %ld", disk, memory); - swap_file = calc_swapsize(memory, maximum_free); - - if (maximum_free < 400 + swap_file ) { - if (maximum_free < 700) { - errorbox(ctr[TR_DISK_TOO_SMALL]); - goto EXIT; - } - + /* Calculating Swap-Size dependend of Ram Size */ + if (memory < 128) { swap_file = 256; } + else if (memory > 1024) { swap_file = 512; } + else { swap_file = memory;} + + /* Calculating Root-Size dependend of Max Disk Space */ + if ( disk < 512 ) { errorbox(ctr[TR_DISK_TOO_SMALL]);goto EXIT; } + else if ( disk < 1024 && disk > 512 ) { root_partition = 256; } + else if ( disk > 1024 && disk < 2048 ) { root_partition = 512; } + else { root_partition = 2048; } + + /* Calculating the amount of free space */ + boot_partition = 20; /* in MB */ + system_partition = disk - ( root_partition + swap_file + boot_partition ); + if (!unattended) { rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]); } else { @@ -397,26 +376,7 @@ int main(int argc, char *argv[]) goto EXIT; swap_file = 0; } - - boot_partition = 20; /* in MB */ - current_free = maximum_free - boot_partition - swap_file; - - root_partition = calc_rootsize(current_free, maximum_free); - - if (root_partition == 0) { - errorbox(ctr[TR_DISK_TOO_SMALL]); - goto EXIT; - } else { - current_free = current_free - root_partition; - } - if (current_free < 256) { - errorbox(ctr[TR_DISK_TOO_SMALL]); - goto EXIT; - } - - system_partition = current_free; - fprintf(flog, "boot = %ld, swap = %ld, mylog = %ld, root = %ld\n", boot_partition, swap_file, system_partition, root_partition);