Developing swud modules

You can customize the software update process by developing your own swud modules.

Developing custom swud modules requires implementing the SWU module API defined in swud/swu_module.h and compiling the module as a dynamically linked library (DLL). After the module has been loaded and initialized, it can start interacting with the swu-core library through its core API.

Implementing a swud module

Every swud module is required to implement the SWU_MODULE_INITIALIZE() function from the swu_module API. The swud service calls this function when loading a module. This function should only initialize the module, start any needed threads, and then return as quickly as possible so it doesn't block swud.

The initialization function has a generic function signature, accepting an argc-argv argument list. However, these arguments aren't meant to be parsed with getopt(), primarily because the mount command (which swud supports) doesn't allow optarg arguments. The recommended approach for parsing arguments is to use comma-separated key-value pairs after the -o option, like this:

mount -T swud -o a=value,b=value,c=value

In this example, the argument list, as parsed by swud, would be passed into SWU_MODULE_INITIALIZE() like this:

argc = 3
argv[0] = "a=value"
argv[1] = "b=value"
argv[2] = "c=value"
argv[3] = NULL

Implementing SWU_MODULE_SHUTDOWN() is optional. Any implementation of this function must be signal handler-safe because it will be called from a signal handler in swud. This means all calls made by the shutdown function must also be signal handler-safe. The intended use for this function is to do any cleanup that must be done before swud exits, such as saving files or any other tasks needed to ensure information persistence.