[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

memdetect code



Attached is some new memdetect code, it uses cdebconf, it doesnt use
libdetect or anything as its pretty simple to detect memory.

Its only a few KB, so its probably best to roll this code in with
something else.

We will need to detect memory to determine how much space we have for
ramfs, or ramdisk. So this can put the value in debconf db and then be
used somewhere else.


Glenn
/*
 * file : ddetect 
 * purpose : detect ethernet cards for the Debian/GNU Linux installer
 * author : David Whedon <dwhedon@gordian.com>
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/sysinfo.h>
#include <cdebconf/debconfclient.h>

int main (int argc, char *argv[])
{
	char *memtotal;
	static struct debconfclient *client;
	struct sysinfo info;

	memtotal = (char *) malloc(15);
	memset(memtotal, 0, 15);
	sysinfo(&info);

	if (info.mem_unit == 0) {
		info.mem_unit = 1;
	}
	info.mem_unit *= 1024 ;
	info.totalram /= info.mem_unit;
	
	client = debconfclient_new ();
	client->command (client, "title", "Detection physical memory", NULL);
	
	/* set the default value */
	sprintf(memtotal, "%ld", info.totalram);
	client->command (client, "set", "ddetect/memdetect", memtotal, NULL);	

	/* ask the user to input value only if priority is low */
	/* if memory isnt detected correctly then this will help */
	client->command (client, "input", "low", "ddetect/memdetect", NULL);
	client->command (client, "go", NULL);

	printf("done\n");
	return EXIT_SUCCESS;
}
Template: ddetect/physical_memory
Type: string
Description: How many kbytes of memory does this computer have ? 
 The default value should be correct however in some extreme situations the value may have to be entered manually.


Reply to: