The hardware abstraction layer facility, described in
hal(7), uses an XML-based file format to merge arbitrary
properties onto device objects. The way device information files works is
that once all physical properties are merged onto a device object, it is
tried against the set of installed device information files. Device
information files are used for both merging facts and policy settings for
devices.
Each device information file has a number of match directives that
are tested against the properties of the device object. The directives have
the form:
<match key="property" [string|int|bool|..]="value">
If all the match directives pass, then the device information can
include the following property directives in the form:
<[merge|append|prepend] key="property" type="[string|int|bool|..]">
These directives are used to merge new properties or append to
existing properties on the device object. Any previously property stemming
from device detection can be overridden by a device information file.
The match, merge, append, and prepend
directives require that the key attribute be either a property name on the
device object in question or a path to a property on another device object.
The path to a property is expressed either through direct specification of
the UDI, such as /org/freedesktop/Hal/devices/computer:foo.bar
or through indirect references such as "@info.parent:baz",
meaning that the device object specified by the UDI in the string
property "info.parent" should be used to query the property
"baz". It is also possible to use multiple indirections.
For example, for a volume on a USB memory stick, the indirection
"@block.storage_device:@storage.physical_device:usb.vendor_id"
references the "usb.vendor_id" property on the device
object representing the USB interface.
When the property to match has been determined, the following
attributes can be used within the "match" tag:
string
Match a string property. For example, <match key=
"foo.bar" string="baz"> matches only if
"foo.bar" is a string property assuming the value
"baz".
int
Match an integer property
uint64
Match property with the 64-bit unsigned type
bool
Match a boolean property
double
Match a property of type double
exists
Used as <match key="foo.bar"
exists="true">. This attribute can be used with "true"
and "false", respectively to match when a property exists or does
not exist.
empty
This attribute can only be used on string properties with
"true" and "false". The semantics for "true" is
to match only when the string is non-empty.
is_absolute_path
Matches only when a string property represents an
absolute path (the path does not have to exist). This attribute can be can be
used with "true" or "false".
is_ascii
Matches only when a string property contains ASCII
characters. This attribute can be used with "true" or
"false".
compare_lt
This attribute can be used with int,
uint64, double and string properties to compare with a
constant. It matches when the given property is less than the given constant
using the default ordering.
compare_le
Similar to compare_lt, but matches when the given
property is less than or equal than the given constant using the default
ordering.
compare_gt
Similar to compare_lt, but matches when the given
property is greater than the given constant using the default ordering.
Similar to compare_lt, but matches when the given
property is greater than or equal than the given constant using the default
ordering.
This attribute can only be used with string and
strlist (string list). For a string key, this matches when the property
contains the given (sub)string. For a string list, this matches if the given
string matches a item in the list.
contains_ncase
Similar to contains, but the property and the
given key are converted to lowercase before it is checked.
The merge, append, and prepend directives all
require the attribute type which specifies what is to be merged. The
following values are supported:
string
The value is copied to the property. For example,
<merge key="foo bar" type="string">
baz</merege> merges the value "baz" into the property
"foo.bar".
strlist
For merge, the value is copied to the property and
the current property is overwritten. For append and prepend, the
value is appended or prepended to the list as a new item.
bool
This attribute can merge the values "true" or
"false"
int
Merges an integer
uint64
Merges an unsigned 64-bit integer
double
Merges a double precision floating point number
copy_property
Copies the value of a given property; supports paths with
direct and indirect UDI's. For example, <merge key="foo.bar"
type="copy_property">@info.parent:baz.bat</merge> merges
the value of the property "baz.bat" on the device object with the
UDI from the property "info.parent" into the property
"foo.bar" on the device object being processed.
The remove directive requires only a key and can be used
with all keys. For strlist, there is also a special syntax to remove
a item from the string list. For example, to remove item "bla"
from property "foo.bar", use the following syntax:
<remove key="foo.bar" type="strlist">bla</merge>
Device Information files are stored in the following standard
hierarchy with the following default top level directories
information, policy and preprobe:
information
Device information files to merge device information.
10freedesktop
Device information files included with the hal
tarball.
20thirdparty
Device information files from the device manufacturer and
installed from media accompanying the hardware.
30user
Device information for specific devices.
policy
Device information files to merge policy properties.
10osvendor
Device information files included with the hal tarball
and supplied by the operating system vendor for policy rules.
20thirdparty
Policy rules from the device manufacturer and installed
from media accompanying the hardware.
30user
Policy rules for specific devices.
preprobe
Device information files to merge information before
probe devices.
10osvendor
Device information files included with the hal
tarball and supplied by the operating system vendor.
20thirdparty
Device information files from the device manufacturer and
installed from media accompanying the hardware.
30user
Device information for specific devices.
All device information files are matched for every hal
device object.