コード例 #1
0
int module_checkall(void)
{
	MODULE *mod;
	int count=0;
	for (mod=first_module; mod!=NULL; mod=mod->next)
			count += module_check(mod);
	return count;
}
コード例 #2
0
int sys_init_module(void* image, unsigned long len, const char* param_values) {
    if(unlikely(!image || !len)) {
        errno = EINVAL;
        return -1;
    }

    if(unlikely(current_task->uid != TASK_ROOT_UID)) {
        errno = EPERM;
        return -1;
    }

    char* name;
    if(module_check(image, (size_t) len, &name) != 0)
        return -1;

    if(module_load(name) != 0)
        return -1;

    if(module_run(name) != 0)
        return -1;

    return 0;
});
コード例 #3
0
STATUS original_test_start(int argc, char *argv[])
{
	OBJECT *obj[6];
	MODULE *network;
	CLASS *node, *link;
	MODULE *tape;
	CLASS *player, *recorder, *collector;

	network = module_load("network",argc,argv);
	if (network==NULL)
	{
#ifndef WIN32
		fprintf(stderr,"%s\n",dlerror());
#else
		perror("network module load failed");
#endif
		return FAILED;
	}
	output_verbose("network module loaded ok");

	node = class_get_class_from_classname("node");
	if (node==NULL)
	{
		output_fatal("network module does not implement class node");
		/*	TROUBLESHOOT
			The <b>network</b> module test can't find the <b>node</b>
			class definition.  This is probably caused by either
			an internal system error or a version of the network module
			that doesn't implement node object as expected (or at all).
		 */
		return FAILED;
	}
	output_verbose("class node implementation loaded ok");

	link = class_get_class_from_classname("link");
	if (node==NULL || link==NULL)
	{
		output_fatal("network module does not implement class link");
		/*	TROUBLESHOOT
			The <b>network</b> module test can't find the <b>link</b>
			class definition.  This is probably caused by either
			an internal system error or a version of the network module
			that doesn't implement link object as expected (or at all).
		 */
		return FAILED;
	}
	output_verbose("class link implementation loaded ok");

	tape = module_load("tape",argc,argv);
	if (tape==NULL)
	{
#ifndef WIN32
		fprintf(stderr,"%s\n",dlerror());
#else
		perror("tape module load failed");
#endif
		return FAILED;
	}

	player = class_get_class_from_classname("player");
	if (player==NULL)
	{
		output_fatal("tape module does not implement class player");
		/*	TROUBLESHOOT
			The <b>tape</b> module test can't find the <b>player</b>
			class definition.  This is probably caused by either
			an internal system error or a version of the tape module
			that doesn't implement player object as expected (or at all).
		 */
		return FAILED;
	}
	recorder = class_get_class_from_classname("recorder");
	if (recorder==NULL)
	{
		output_fatal("tape module does not implement class recorder");
		/*	TROUBLESHOOT
			The <b>tape</b> module test can't find the <b>recorder</b>
			class definition.  This is probably caused by either
			an internal system error or a version of the tape module
			that doesn't implement recorder object as expected (or at all).
		 */
		return FAILED;
	}
	collector = class_get_class_from_classname("collector");
	if (collector==NULL)
	{
		output_fatal("tape module does not implement class collector");
		/*	TROUBLESHOOT
			The <b>tape</b> module test can't find the <b>collector</b>
			class definition.  This is probably caused by either
			an internal system error or a version of the tape module
			that doesn't implement collector object as expected (or at all).
		 */
		return FAILED;
	}

	if (module_import(network,"../test/pnnl2bus.cdf")<=0)
		return FAILED;

	/* tape player */
	if ((*player->create)(&obj[3],object_get_first())==FAILED)
	{
		output_fatal("player creation failed");
		/*	TROUBLESHOOT
			The <b>tape</b> module test can't create a <b>player</b>
			object.  This is probably caused by either
			an internal system error or a version of the tape module
			that doesn't implement player object as expected (or at all).
		 */
		return FAILED;
	}
	object_set_value_by_name(obj[3],"loop","3600"); /* 18000 is about 12y at 1h steps */
	object_set_value_by_name(obj[3],"property","S");

	/* tape recorder */
	if ((*recorder->create)(&obj[4],object_get_first())==FAILED)
	{
		output_fatal("recorder creation failed");
		/*	TROUBLESHOOT
			The <b>tape</b> module test can't create a <b>recorder</b>
			object.  This is probably caused by either
			an internal system error or a version of the tape module
			that doesn't implement recorder object as expected (or at all).
		 */
		return FAILED;
	}
	object_set_value_by_name(obj[4],"property","V,S");
	object_set_value_by_name(obj[4],"interval","0");
	object_set_value_by_name(obj[4],"limit","1000");

	/* tape collector */
	if ((*collector->create)(&obj[5],NULL)==FAILED)
	{
		output_fatal("collector creation failed");
		/*	TROUBLESHOOT
			The <b>tape</b> module test can't create a <b>collector</b>
			object.  This is probably caused by either
			an internal system error or a version of the tape module
			that doesn't implement collector object as expected (or at all).
		 */
		return FAILED;
	}
	object_set_value_by_name(obj[5],"property","count(V.mag),min(V.mag),avg(V.mag),std(V.mag),max(V.mag),min(V.ang),avg(V.ang),std(V.ang),max(V.ang)");
	object_set_value_by_name(obj[5],"interval","0");
	object_set_value_by_name(obj[5],"limit","1000");
	object_set_value_by_name(obj[5],"group","class=node;");

	module_check(network);

	return SUCCESS;
}