Revision: 2704
http://ipcop.svn.sourceforge.net/ipcop/?rev=2704&view=rev
Author: owes
Date: 2009-04-13 09:08:40 +0000 (Mon, 13 Apr 2009)
Log Message:
-----------
Use GiB, MiB, KiB troughout installation.
Modified Paths:
--------------
ipcop/trunk/src/installer/hardware.c
ipcop/trunk/src/installer/installer.c
Modified: ipcop/trunk/src/installer/hardware.c
===================================================================
--- ipcop/trunk/src/installer/hardware.c 2009-04-13 09:06:06 UTC (rev
2703)
+++ ipcop/trunk/src/installer/hardware.c 2009-04-13 09:08:40 UTC (rev
2704)
@@ -17,14 +17,13 @@
* along with IPCop; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * (c) 2007-2008, the IPCop team
+ * (c) 2007-2009, the IPCop team
*
* $Id$
*
*/
-#include <discover/discover.h>
#include <discover/discover-conf.h>
#include <dirent.h>
@@ -55,8 +54,8 @@
/* Retrieve disk capacity from proc or sys.
- Size is reported in blocks of 512 bytes, make a string with info GB, MB, KB.
- Return size in MB.
+ Size is reported in blocks of 512 bytes, make a string with info GiB, MiB,
KiB.
+ Return size in MiB.
*/
static unsigned long getdrivesize(char *procname, char *strsize)
{
@@ -65,25 +64,25 @@
unsigned long mbsize;
mbsize = 0;
- strcpy(strsize, "? KB");
+ strcpy(strsize, "? KiB");
if ((f = fopen(procname, "r")) != NULL) {
if (fgets(strsize, STRING_SIZE, f)) {
size = strtoull(strsize, NULL, 10);
- size = size * 512 / 1000; /* use the disk vendor way of
specifying KBytes */
- mbsize = size / 1000;
+ size = size * 512 / 1024; /* do not use the disk vendor way of
specifying KBytes */
+ mbsize = size / 1024;
if (size >= 4000000) {
/* Everything larger than 4000 MB */
- snprintf(strsize, STRING_SIZE, "%llu GB", size / 1000000);
+ snprintf(strsize, STRING_SIZE, "%llu GiB", size / (1024*1024));
}
else if (size >= 4000) {
/* Everything larger than 4000 KB */
- snprintf(strsize, STRING_SIZE, "%llu MB", size / 1000);
+ snprintf(strsize, STRING_SIZE, "%llu MiB", size / 1024);
}
else {
/* Anything else, unlikely since we need something like 100+
MB anyway */
- snprintf(strsize, STRING_SIZE, "%llu KB", size);
+ snprintf(strsize, STRING_SIZE, "%llu KiB", size);
}
}
}
Modified: ipcop/trunk/src/installer/installer.c
===================================================================
--- ipcop/trunk/src/installer/installer.c 2009-04-13 09:06:06 UTC (rev
2703)
+++ ipcop/trunk/src/installer/installer.c 2009-04-13 09:08:40 UTC (rev
2704)
@@ -53,11 +53,11 @@
supported_media_t medium_sources = none;
supported_media_t medium_target = none;
char network_source[STRING_SIZE];
-unsigned int memtotal = 0; /* Total memory in MB */
+unsigned int memtotal = 0; /* Total memory in MB */
struct utsname utsbuf;
/* local variables */
-static int codepath = 0; /* for better test, allow testing
dhcp and manual path even on pxe boot */
+static int codepath = 0; /* for better test, allow testing
dhcp and manual path even on pxe boot */
static NODEKV *kv = NULL; /* contains a list key=value pairs
from boot parameters */
static char command[STRING_SIZE];
static char message[STRING_SIZE_LARGE];
@@ -251,9 +251,10 @@
static void read_codepath(void)
{
char string[STRING_SIZE];
- char strboot[STRING_SIZE] = "none";
- find_kv_default(kv, "ipcopboot", strboot);
+ char strboot[STRING_SIZE] = "none";
+ find_kv_default(kv, "ipcopboot", strboot);
+
if (find_kv_default(kv, "codepath", string) == SUCCESS) {
if (!strcmp(string, "1") || !strcmp(string, "2")) {
codepath = atoi(string);
@@ -326,7 +327,7 @@
for (i = 0; i < numnetwork; i++) {
/* 3 probes at approx. 3 second interval with 1 second pause after
failure should suffice */
if (!find_network_by_dhcp(i)) {
- fprintf(flog, "Find dhcp server at eth%d\n", i);
+ fprintf(flog, "Found dhcp server at eth%d\n", i);
}
newtScaleSet(scale, (i+1) * 100 / numnetwork);
newtRefresh();
@@ -642,7 +643,7 @@
handle = fopen(string, "r");
fgets(string, STRING_SIZE - 1, handle);
fclose(handle);
- /* Value is in 512 byte sectors, convert to MB */
+ /* Value is in 512 byte sectors, convert to MiB */
disksize[raid] = strtoull(string, NULL, 10) >> 11;
if (disksize[raid] < DISK_MINIMUM) {
@@ -650,7 +651,7 @@
errorbox(ipcop_gettext("TR_DISK_TOO_SMALL"));
continue; // give option to choose another disk
}
- fprintf(flog, "Hard disk selected %s. Size:%ld MByte\n",
hardwares[disklist[raid]].device, disksize[raid]);
+ fprintf(flog, "Hard disk selected %s. Size:%ld MiB\n",
hardwares[disklist[raid]].device, disksize[raid]);
if (raid == 1) {
raid = 2;
@@ -677,7 +678,7 @@
*ddisk = disklist[1];
*ddisk2 = disklist[2];
*disk_size = (disksize[1] < disksize[2]) ? disksize[1] :
disksize[2];
- fprintf(flog, "RAID size:%ld MByte\n", *disk_size);
+ fprintf(flog, "RAID size:%ld MiB\n", *disk_size);
}
else {
*ddisk = disklist[0];
@@ -720,10 +721,10 @@
*ramdisk_size = atoi(values[0]);
/* Verify against minimum sensible size and total
available memory here.
- Maximize againt total memory minus 16 MB, though we
probably need more than 16 MB. */
+ Maximize against total memory minus 16 MiB, though we
probably need more than 16 MiB. */
if ((strlen(values[0]) < 5) && (*ramdisk_size >= 32) &&
(*ramdisk_size <= (memtotal - 16))) {
medium_target = flash;
- fprintf(flog, "FLASH installation, RAM disk size
wanted: %ld MB\n", *ramdisk_size);
+ fprintf(flog, "FLASH installation, RAM disk size
wanted: %ld MiB\n", *ramdisk_size);
return SUCCESS; // OK flash
}
}
@@ -841,7 +842,7 @@
int noscsi = 0;
int parted = 0;
long int swapfilesize = -1;
- int32_t maxdisksize = INT32_MAX;
+ int32_t userdisksize = INT32_MAX;
if (find_kv(kv, "nopcmcia") != NULL) {
nopcmcia = 1;
fprintf(flog, "Skip PCMCIA/PC-CARD detection\n");
@@ -862,22 +863,22 @@
if (find_kv_default(kv, "swapfilesize", line) == SUCCESS) {
swapfilesize = atoi(line);
if ((swapfilesize == 0) || ((swapfilesize >= SWAP_MINIMUM) &&
(swapfilesize <= SWAP_MAXIMUM))) {
- fprintf(flog, "swapfilesize %ld MB\n", swapfilesize);
+ fprintf(flog, "swapfilesize %ld MiB\n", swapfilesize);
}
else {
- fprintf(flog, "Ignoring swapfilesize %ld MB\n", swapfilesize);
+ fprintf(flog, "Ignoring swapfilesize %ld MiB\n", swapfilesize);
swapfilesize = -1;
}
}
- sprintf(line, "%d", maxdisksize);
+ sprintf(line, "%d", userdisksize);
if (find_kv_default(kv, "disksize", line) == SUCCESS) {
- maxdisksize = atoi(line);
- if (maxdisksize < DISK_MINIMUM) {
- fprintf(flog, "Ignoring disksize %d MB\n", maxdisksize);
- maxdisksize = INT32_MAX;
+ userdisksize = atoi(line);
+ if (userdisksize < DISK_MINIMUM) {
+ fprintf(flog, "Ignoring disksize %d MiB\n", userdisksize);
+ userdisksize = INT32_MAX;
}
else {
- fprintf(flog, "Max. disksize %d MB\n", maxdisksize);
+ fprintf(flog, "User max. disksize %d MiB\n", userdisksize);
}
}
@@ -925,8 +926,9 @@
goto EXIT;
}
- if (maxdisksize < disk_size) {
- disk_size = maxdisksize;
+ if (userdisksize < disk_size) {
+ disk_size = userdisksize;
+ fprintf(flog, "Use user selected max. disksize: %d MiB\n", disk_size);
}
/* Partition, format, mount, initramfs and make bootable
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn