module Device:sig..end
type t
Device.t corresponds to a system device.type descr = Device.t using
Device.create.
| |
Syspath of |
A device path in
/sys, including the mount point.
Example: |
|
| |
Subsystem_sysname of |
A given subsystem, and a given sys name.
Example: |
|
| |
Device_id of |
A device id, which is a special string in one of the following four forms:
|
|
| |
Environment |
The process environment.
This only works reliably if the current process is called from an udev
rule, and is usually used for tools executed from |
|
val create : Libudev.Context.t -> descr -> tDevice.t from a Device.descr.val context : t -> Libudev.Context.tContext.t to which the device is bound.val syspath : t -> stringsysfs including the sysfs
mount point, as a unicode string.val sysname : t -> stringsysfs as unicode string.val sysnum : t -> string optionsysname as unicode string, if any.
Note: the number is returned as a unicode string to preserve the exact
format of the number, especially any leading zeros.
val devpath : t -> string
Unlike Device.syspath, this path does not contain the sysfs mount
point. However, the path is absolute and starts with a slash "/".
: t -> string listval has_tag : t -> string -> boolval subsystem : t -> stringval driver : t -> string optionval devtype : t -> string optionval devnode : t -> string option
This path always points to the actual device node associated with this device,
and never to any symbolic links to this device node. See Device.devlinks to
get a list of symbolic links to this device node.
val devlinks : t -> string listDevice.devnode
of this device. The paths are unicode strings.
UDev can create symlinks to the original device node (see
Device.devnode) inside the device directory. This is often used to
assign a constant, fixed device node to devices like removeable media,
which technically do not have a constant device node, or to map a single
device into multiple device hierarchies. This function provides access to
all such symbolic links, which were created by UDev for this device.
val is_initialized : t -> boolA device is initialized if udev has already handled this device and has set up device node permissions and context, or renamed a network device.
Such a distinction is meaningful only for devices with a device node, or
for network devices. For all other devices, the function returns true.
Using uninitialized devices is not recommended.
val usec_since_initialized : t -> Stdint.Uint64.t
This is only implemented on devices which need to store properties in the
udev database. For all other devices, Uint64.zero is returned.
val parent : t -> t optionval find_parent : t ->
?devtype:string -> subsystem:string -> t optionsubsystem and optionally with
the given devtype, if any.
subsystem contains the name of the subsystem, in which to search for the
parent. devtype optionally holds the expected device type of the parent.
type action = Monitor.t.
| |
Add |
| |
Remove |
| |
Change |
| |
Online |
| |
Offline |
| |
Other of |
val string_of_action : action -> string
val action : t -> action optionNone if the device was not received
from a Monitor.tval seqnum : t -> Stdint.Uint64.tUint64.zero if this device has no
sequence number, i.e. was not received from a Monitor.tval properties : t -> (string * string) list(key, value) list.val property : t -> string -> string optionval int_property : t -> string -> int option
val bool_property : t -> string -> bool optionval sysattrs : t -> (string * string) list(key, value) list.
System attributes are basically normal files inside the device
directory. These files contain all sorts of information about the device,
which may not be reflected by properties. These attributes are commonly
used for matching in udev rules, and can be printed using udevadm info
--attribute-walk.
val sysattr : t -> string -> string optionval int_sysattr : t -> string -> int option
val bool_sysattr : t -> string -> bool option
val set_sysattr : t -> string -> string -> unit