return (cpu_count > 1);
}
-long calc_swapsize(long memory, long disk) {
- if (memory < 128) {
- return 256;
- }
- if (memory > 1024) {
- return 512;
- }
-
- return memory*2;
-}
-
-long calc_rootsize(long free, long max) {
- long root;
-
- root = max / 2;
- if (root < 256) {
- return 0;
- }
- if (root > 2048) {
- root = 2048;
- }
- return root;
-}
-
int main(int argc, char *argv[])
{
char *langnames[] = { "Deutsch", "English", NULL };
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 };
mysystem("/sbin/modprobe generic");
mysystem("/sbin/modprobe ide-cd");
mysystem("/sbin/modprobe ide-disk");
+ mysystem("/sbin/modprobe uhci-hcd");
+ mysystem("/sbin/modprobe ohci-hcd");
+ mysystem("/sbin/modprobe ehci-hcd");
+ mysystem("/sbin/modprobe ohci1394");
mysystem("/sbin/modprobe sd_mod");
mysystem("/sbin/modprobe sr_mod");
mysystem("/sbin/modprobe usb-storage");
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 < 512 + swap_file ) {
- if (maximum_free < 700) {
- errorbox(ctr[TR_DISK_TOO_SMALL]);
- goto EXIT;
- }
-
- if (!unattended) {
- rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]);
- } else {
- rc = 1;
- }
-
- if (rc != 1)
- goto EXIT;
- swap_file = 0;
- }
-
- boot_partition = 20; /* in MB */
- current_free = maximum_free - boot_partition - swap_file;
-
- if (current_free < 700) {
- errorbox(ctr[TR_DISK_TOO_SMALL]);
- goto EXIT;
- }
+ /* Calculating Swap-Size dependend of Ram Size */
+ if (memory < 128)
+ swap_file = 32;
+ else if (memory >= 1024)
+ swap_file = 512;
+ else
+ swap_file = memory;
- root_partition = calc_rootsize(current_free, maximum_free);
+ /* Calculating Root-Size dependend of Max Disk Space */
+ if ( disk < 756 )
+ root_partition = 256;
+ else if ( disk >= 1024 && disk <= 3072 )
+ root_partition = 512;
+ else
+ root_partition = 2048;
+
- if (root_partition == 0) {
- errorbox(ctr[TR_DISK_TOO_SMALL]);
- goto EXIT;
- } else {
- current_free = current_free - root_partition;
- }
+ /* Calculating the amount of free space */
+ boot_partition = 20; /* in MB */
+ system_partition = disk - ( root_partition + swap_file + boot_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);
-
+ fprintf(flog, ", boot = %ld, swap = %ld, mylog = %ld, root = %ld\n",
+ boot_partition, swap_file, system_partition, root_partition);
+
+ if ( (!unattended) && (((disk - (root_partition + swap_file + boot_partition)) < 256 ) && ((disk - (root_partition + boot_partition + 32 )) > 256)) ) {
+ rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]);
+ if (rc != 0){
+ swap_file = 32;
+ system_partition = disk - ( root_partition + swap_file + boot_partition );
+ fprintf(flog, "Changing Swap Size to 32 MB.\n");
+ }
+ else {
+ fprintf(flog, "Disk is too small.\n");
+ errorbox(ctr[TR_DISK_TOO_SMALL]);goto EXIT;
+ }
+ }
+ else if (disk - (root_partition + swap_file + boot_partition) >= 256) {
+
+ }
+ else {
+ fprintf(flog, "Disk is too small.\n");
+ errorbox(ctr[TR_DISK_TOO_SMALL]);goto EXIT;
+ }
+
handle = fopen("/tmp/partitiontable", "w");
/* Make swapfile */