Modules agent description


Purpose

The modules agent (ag_modules) is used to access '/etc/modules.conf' file. It is part of YaST2 SCR, the system configuration repository, used to access configuration data on the target system. The general SCR API allows Read() and Write() access to get and change data. The modules agent implements an abstract view onto the modules.conf file.

Implementation

The agent reads the file into its own structures in the initialization time. If the file is modified externally than the file is re-read and all the structures change, except those that have been already set-up by the agent.

WARNING! The whole syntax of '/etc/modules.conf' (modules.conf(5)) is NOT covered by current implementation of the agent. There are just four directives that are accepted (all other will be ignored): alias, post-install, pre-install and options.

Note: The complete development documentation is available in the autodocs/ directory.

Interface for modules-agent

The interface is implemented as a SCR agent with the usual Read(), Write() and Dir() interface. The path prefix used is A list of possible sub-paths can be retrieved with which currently results in sublist of the list: These strings (which are called directives in the following text) can be rolled out into the paths. For all these directives Dir() can be used as well, thus results in the list with all alias names, and similarly for other directives.

"alias" directive

Path
.modules.alias
Read
Read(.modules.alias, <alias_name>)
         -> string
return value is <real_name> or "null" or "off"
Write
Write(.modules.alias, <real_name> | "null" | "off", <alias_name>)
         -> boolean
Example
Read(.modules.alias, "eth0")
        -> "de4x5"
Write(.modules.alias, "off", "eth0")
	-> true
writes "alias eth0 off" to 'modules.conf', possibly replacing an already existing entry for "alias eth0"

"options" directive

Path
.modules.options
.modules.options.<option>
Read
Read(.modules.options, <module>)
	-> map
Read(.modules.options.<option>, <module>)
	-> string
Write
Write(.modules.options, <map>, <module>)
	-> boolean
Write(.modules.options.<option>, <value>, <module>)
	-> boolean
Example
Read(.modules.options, "mpu401")
	-> $["io" : "0x0330", "irq" : "9"])
Read(.modules.options.io, "mpu401")
	-> "0x330"
Write(.modules.options, $["io" : "0x0330", "irq" : "9"], "mpu401")
	-> true
Write(.modules.options.io, "0x0330", "mpu401")
	-> true

Note: The map elements while writing options must be pairs string : string!

"pre-install" directive

Path
.modules.pre-install
Read
Read(.modules.pre-install, <module>)
	-> string
Write
Write(.modules.pre-install, <string>, <module>)
	-> boolean
Example
Read(.modules.pre-install, "ad1816")
	-> "modprobe -k opl3"
Write(.modules.pre-install, "modprobe -k opl3", "ad1816")
	-> true

"post-install" directive

Path
.modules.post-install
Read
Read(.modules.post-install, <module>)
	-> string
Write
Write(.modules.post-install, <string>, <module>)
	-> boolean
Example
Read(.modules.post-install, "ad1816")
	-> "modprobe -k mpu401"
Write(.modules.post-install, "modprobe -k mpu401", "ad1816")
	-> true

Comments

There also exist possibility to read/write comment that belongs to some directive. The comment that belongs to a directive is always assumed to be a comment BEFORE the directive (and while reading on the same line just after the directive, but during writing this comment goes in front of the directive).
Path
.modules.<directive>.comment
Read
Read(.modules.<directive>.comment, <name>)
	-> string
Write
Write(.modules.<directive>.comment, <comment sring>, <name>)
	-> boolean
Example
Read(.modules.alias.comment, "eth0")
	-> "# YaST2: Network card\n"
Write(.modules.alias.comment, "# YaST2: Network card\n", "eth0")
	-> true

Deleting

It might be useful to delete some '/etc/modules.conf' entry (directive) from the file. Therefore this operation was included into the agent implementation (any path of length 2 and parameter nil to Write()).

Note: It is not possible to delete only one option, only whole 'options' entry!

Example
Write(.modules.alias, nil, "eth0")
	-> true
This example shows, how to delete alias eth0 <something>. Note that comment attached to the directive is deleted as well (comment as defined above).

Final saving

The final saving of the '/etc/modules.conf' file is done
Write(.modules, nil)
The final saving also triggers a
/sbin/depmod -a -F /boot/System.map-`uname -r` `uname -r`
in the installed system to re-initialize the modprobe/insmod database.

Restrictions, limits and future enhancements

The options with aliases are conflicting with options with modules. The Modules Agent doesn't solve this conflicts, so you should better avoid usage of options with aliases.

Not all directives are supported. See the TODO.txt file for the current status of support and also for the list of possible future enhancements.

Complete Read paths table

The complete Write() paths table is similar to this except for the paths to which YCPList is returned.
PathTypeResult
.modulesYCPList list with all available directives (currently sublist of ["alias", "pre-install", "post-install", "options"]
.modules.aliasYCPList list with all "alias" directives
.modules.pre-installYCPList list with all "pre-install" directives
.modules.post-installYCPList list with all "post-install" directives
.modules.optionsYCPList list with all "options" directives
.modules.options.<option>YCPString one particular option
.modules.<directive>.commentYCPString string (with hashes ('#') and new-lines ('\n') that belongs to the directive

Complete Dir paths table

The return type of the Dir() is always YCPList.
PathResult
.modules list with all available directives (currently sublist of ["alias", "pre-install", "post-install", "options"]
.modules.alias list with all "alias" directives
.modules.pre-install list with all "pre-install" directives
.modules.post-install list with all "post-install" directives
.modules.options list with all "options" directives

Michal Svec <msvec@suse.cz>
Daniel Vesely <dan@suse.cz>