LdmModalias

LdmModalias — Modalias matching

Functions

LdmModalias * ldm_modalias_new ()
const gchar * ldm_modalias_get_driver ()
const gchar * ldm_modalias_get_match ()
const gchar * ldm_modalias_get_package ()
gboolean ldm_modalias_matches ()
gboolean ldm_modalias_matches_device ()

Properties

char * driver Read / Write / Construct Only
char * match Read / Write / Construct Only
char * package Read / Write / Construct Only

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── LdmModalias

Description

An LdmModalias is a mapping from an fnmatch style modalias match to the required package name and kernel module.

This is used in hardware detection to determine which package provides the required kernel modules for any given hardware. At the most simple level, we attempt to match the “match” field, which is an fnmatch style string, to each device's “modalias” field, which is an explicit string set by the kernel.

This allows for automatic hardware detection and association with each LdmPlugin.

The primary use of LdmModalias is by the LdmModaliasPlugin implementation, which adds a new modalias for every line in a file to allow hardware matching.

For example, if we're trying to match an NVIDIA GPU which has the following modalias:

pci:v000010DEd00001C60sv00001558sd000065A4bc03sc00i00

as set by the kernel, we might have a “match” line that looks like:

pci:v000010DEd00001C60sv*sd*bc03sc*i*

Then all that is left is a simple comparison to check if the driver can be supported by the given match. Once we verify a match, we also know from the “driver” and “package” fields what the end user would need to have installed on their system for the “driver” to be activated. This helps immensely in detecting support for drivers.

Functions

ldm_modalias_new ()

LdmModalias *
ldm_modalias_new (const gchar *match,
                  const gchar *driver,
                  const char *package);

Parameters

match

fnmatch style string to match hardware

 

driver

Name of the driver for this modalias match

 

package

Name of the package or bundle for this modalias match

 

Returns

A newly initialised LdmModalias.

[transfer full]


ldm_modalias_get_driver ()

const gchar *
ldm_modalias_get_driver (LdmModalias *modalias);

This function will return the driver name (i.e "wl") associated with this particular modalias match.

Returns

The driver name.

[transfer none]


ldm_modalias_get_match ()

const gchar *
ldm_modalias_get_match (LdmModalias *modalias);

This function will return the fnmatch-style match line used to check if this LdmModalias matches a given hardware device on the system.

Returns

The match line.

[transfer none]


ldm_modalias_get_package ()

const gchar *
ldm_modalias_get_package (LdmModalias *modalias);

This function will return the name of the package or bundle that contains the corresponding driver required to enable hardware support.

Returns

The package or bundle name.

[transfer none]


ldm_modalias_matches ()

gboolean
ldm_modalias_matches (LdmModalias *modalias,
                      const gchar *match_string);

If the given match_string matches our own fnmatch style match, this function will return true, indicating compatibility.

Parameters

match_string

Device modalias to test against

 

Returns

True if the match_string is indeed a match


ldm_modalias_matches_device ()

gboolean
ldm_modalias_matches_device (LdmModalias *modalias,
                             LdmDevice *match_device);

This is a simple wrapper around ldm_modalias_matches, and will simply pass the device's “modalias” for testing.

Parameters

match_device

An LdmDevice to test against

 

Returns

True if the match_device is indeed a match

Property Details

The “driver” property

  “driver”                   char *

The associated kernel driver

Owner: LdmModalias

Flags: Read / Write / Construct Only

Default value: NULL


The “match” property

  “match”                    char *

The fnmatch style string that would create a match

Owner: LdmModalias

Flags: Read / Write / Construct Only

Default value: NULL


The “package” property

  “package”                  char *

The package or bundle containing this driver match

Owner: LdmModalias

Flags: Read / Write / Construct Only

Default value: NULL

See Also

LdmDevice, LdmModaliasPlugin