return dest;
}
+
+unsigned long long hw_memory() {
+ FILE* handle = NULL;
+ char line[STRING_SIZE];
+
+ unsigned long long memory = 0;
+
+ /* Calculate amount of memory in machine */
+ if ((handle = fopen("/proc/meminfo", "r"))) {
+ while (fgets(line, sizeof(line), handle)) {
+ if (!sscanf (line, "MemTotal: %llu kB", memory)) {
+ memory = 0;
+ }
+ }
+
+ fclose(handle);
+ }
+
+ return memory * 1024;
+}
unsigned int hw_count_disks(struct hw_disk** disks);
struct hw_disk** hw_select_disks(struct hw_disk** disks, int* selection);
+unsigned long long hw_memory();
+
#endif /* HEADER_HW_H */
if (rc == 2)
goto EXIT;
- /* Calculate amount of memory in machine */
- if ((handle = fopen("/proc/meminfo", "r")))
- {
- while (fgets(line, STRING_SIZE-1, handle)) {
- if (sscanf (line, "MemTotal: %s kB", string)) {
- memory = atoi(string) / 1024 ;
- }
- }
- fclose(handle);
- }
+ memory = hw_memory() / 1024 / 1024;
/* Partition, mkswp, mkfs.
* before partitioning, first determine the sizes of each