Command line usage and setup

Sometime it is useful to be able to have some arguments passed at runtime to the kernel, in order to configure it dynamically. For this, STOS have a basic commandline support. In this part we will see how to pass arguments to a module.

In order to have access to command line arguments for a module, you need to register the argument inside your module definition. All we need to use is the module_param macro, and add a dependancy to M_COMMANDLINE.

#include <kernel/klog.h>
#include <kernel/module.h>
#include <kernel/stos.h>

static char *option;

static void __init_once init(void)
	if (option) {
		klog("my argument is %s\n", option);
	} else {
		klog("I had no argument passed to me\n");

module_param(option_name, &option);

After that, we need to pass :


to the kernel commandline. For the moment, we just need to edit the commandline file in the build directory to add an option.

In order to have more information about the commandline support of stos, you can see the implementation of it inside kernel/modules/commandline. There is also a talk done by Paul Hervot about it