summaryrefslogtreecommitdiffstats
path: root/mdk-stage1
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2003-10-22 22:27:30 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2003-10-22 22:27:30 +0000
commit080a042d018b681a0007c18f5656a384a99689e3 (patch)
treefc2236b32b6579ca112060a2bcb40af7b91859d0 /mdk-stage1
parent24a0ca11e3dc675319d4e0b1cf1811e78170bcc8 (diff)
downloaddrakx-080a042d018b681a0007c18f5656a384a99689e3.tar
drakx-080a042d018b681a0007c18f5656a384a99689e3.tar.gz
drakx-080a042d018b681a0007c18f5656a384a99689e3.tar.bz2
drakx-080a042d018b681a0007c18f5656a384a99689e3.tar.xz
drakx-080a042d018b681a0007c18f5656a384a99689e3.zip
file_size
Diffstat (limited to 'mdk-stage1')
-rw-r--r--mdk-stage1/tools.c20
-rw-r--r--mdk-stage1/tools.h1
2 files changed, 14 insertions, 7 deletions
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c
index aa9be8f83..58c9203df 100644
--- a/mdk-stage1/tools.c
+++ b/mdk-stage1/tools.c
@@ -191,15 +191,21 @@ int charstar_to_int(const char * s)
return number;
}
+off_t file_size(const char * path)
+{
+ struct stat statr;
+ if (stat(path, &statr))
+ return -1;
+ else
+ return statr.st_size;
+}
+
int total_memory(void)
{
int value;
- struct stat statr;
- if (stat("/proc/kcore", &statr))
- return 0;
/* drakx powered: use /proc/kcore and rounds every 4 Mbytes */
- value = 4 * ((int)((float)statr.st_size / 1024 / 1024 / 4 + 0.5));
+ value = 4 * ((int)((float)file_size("/proc/kcore") / 1024 / 1024 / 4 + 0.5));
log_message("Total Memory: %d Mbytes", value);
return value;
@@ -346,7 +352,7 @@ char * get_ramdisk_realname(void)
enum return_type load_ramdisk(void)
{
int st2_fd;
- struct stat statr;
+ off_t size;
char img_name[500];
strcpy(img_name, IMAGE_LOCATION);
@@ -362,10 +368,10 @@ enum return_type load_ramdisk(void)
return RETURN_ERROR;
}
- if (stat(img_name, &statr))
+ if ((size = file_size(img_name)) == -1)
return RETURN_ERROR;
else
- return load_ramdisk_fd(st2_fd, statr.st_size);
+ return load_ramdisk_fd(st2_fd, size);
}
/* pixel's */
diff --git a/mdk-stage1/tools.h b/mdk-stage1/tools.h
index 9da8c3445..29bfc5f62 100644
--- a/mdk-stage1/tools.h
+++ b/mdk-stage1/tools.h
@@ -29,6 +29,7 @@ int get_param(int i);
void set_param(int i);
void unset_param(int i);
int charstar_to_int(const char * s);
+off_t file_size(const char * path);
int total_memory(void);
int ramdisk_possible(void);
char * get_ramdisk_realname(void);