summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/utils.c')
-rw-r--r--mdk-stage1/utils.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/mdk-stage1/utils.c b/mdk-stage1/utils.c
index 434704bef..6ad3a8f6f 100644
--- a/mdk-stage1/utils.c
+++ b/mdk-stage1/utils.c
@@ -1,7 +1,7 @@
/*
- * Guillaume Cottenceau (gc@mandrakesoft.com)
+ * Guillaume Cottenceau (gc)
*
- * Copyright 2000 Mandrakesoft
+ * Copyright 2000 Mandriva
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <ctype.h>
#include <dirent.h>
+#include <sys/sysinfo.h>
#include <sys/utsname.h>
#include "utils.h"
@@ -83,16 +84,19 @@ int line_counts(const char * buf) {
int total_memory(void)
{
int value;
-
- /* drakx powered: use /proc/kcore and rounds every 4 Mbytes */
- value = 4 * ((int)((float)file_size("/proc/kcore") / 1024 / 1024 / 4 + 0.5));
+ struct sysinfo sys_info;
+ if (sysinfo(&sys_info) < 0) {
+ log_perror("sysinfo");
+ return 0;
+ }
+ value = sys_info.totalram * sys_info.mem_unit / 1024 / 1024;
log_message("Total Memory: %d Mbytes", value);
return value;
}
/* pixel's */
-void * memdup(void *src, size_t size)
+void * _memdup(void *src, size_t size)
{
void * r;
r = malloc(size);
@@ -128,7 +132,7 @@ char ** list_directory(char * direct)
if (dp)
closedir(dp);
tmp[i] = NULL;
- return memdup(tmp, sizeof(char*) * (i+1));
+ return _memdup(tmp, sizeof(char*) * (i+1));
}
@@ -144,16 +148,6 @@ int string_array_length(char ** a)
return i;
}
-int kernel_version(void)
-{
- struct utsname val;
- if (uname(&val)) {
- log_perror("uname failed");
- return -1;
- }
- return charstar_to_int(val.release + 2);
-}
-
char * asprintf_(const char *msg, ...)
{
int n;
@@ -172,14 +166,6 @@ char * asprintf_(const char *msg, ...)
return strdup("");
}
-int scall_(int retval, char * msg, char * file, int line)
-{
- char tmp[5000];
- sprintf(tmp, "%s(%s:%d) failed", msg, file, line);
- if (retval)
- log_perror(tmp);
- return retval;
-}
void lowercase(char *s)
{
@@ -189,3 +175,17 @@ void lowercase(char *s)
i++;
}
}
+
+char *my_dirname(char *path) {
+ char *p = strrchr (path, '/');
+ char *tmp;
+ int len;
+ if (!p)
+ return path;
+ len = p-path+1;
+ tmp = malloc(len);
+ strncpy(tmp, path, len-1);
+ tmp[len-1] = '\0';
+ return tmp;
+}
+