Udev (JNA API)
Description: declaration: package: com.sun.jna.platform.linux, interface: Udev

Package com.sun.jna.platform.linux

# Interface Udev

All Superinterfaces:
  `Library`

public interface Udev extends Library
libudev.h provides APIs to introspect and enumerate devices on the local system. Udev objects are opaque and must not be accessed by the caller via different means than functions provided by libudev.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static class`
  `Udev.UdevContext`
  All functions require a libudev context to operate.
  `static class`
  `Udev.UdevDevice`
  To introspect a local device on a system, a udev device object can be created via `Udev.UdevContext.deviceNewFromSyspath(String)` and friends.
  `static class`
  `Udev.UdevEnumerate`
  To enumerate local devices on the system, an enumeration object can be created via `Udev.UdevContext.enumerateNew()`.
  `static class`
  `Udev.UdevListEntry`
  Whenever libudev returns a list of objects, the `udev_list_entry` API should be used to iterate, access and modify those lists.

  ## Nested classes/interfaces inherited from interface com.sun.jna.Library

  `Library.Handler`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Udev`
  `INSTANCE`

  ### Fields inherited from interface com.sun.jna.Library

  `OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_SYMBOL_PROVIDER, OPTION_TYPE_MAPPER`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `udev_device_get_devnode(Udev.UdevDevice udev_device)`
  Gets the devnode of a udev device
  `String`
  `udev_device_get_devtype(Udev.UdevDevice udev_device)`
  Gets the devtype of a udev device
  `Udev.UdevDevice`
  `udev_device_get_parent(Udev.UdevDevice udev_device)`
  Gets the parent of a udev device
  `Udev.UdevDevice`
  `udev_device_get_parent_with_subsystem_devtype(Udev.UdevDevice udev_device, String subsystem, String devtype)`
  Gets the parent of a udev device matching a subsystem and devtype
  `String`
  `udev_device_get_property_value(Udev.UdevDevice udev_device, String key)`
  Retrieves a device property from a udev device.
  `String`
  `udev_device_get_subsystem(Udev.UdevDevice udev_device)`
  Gets the subsystem of a udev device
  `String`
  `udev_device_get_sysattr_value(Udev.UdevDevice udev_device, String sysattr)`
  Retrieves a device attributesfrom a udev device.
  `String`
  `udev_device_get_sysname(Udev.UdevDevice udev_device)`
  Gets the sysname of a udev device
  `String`
  `udev_device_get_syspath(Udev.UdevDevice udev_device)`
  Gets the syspath of a udev device
  `Udev.UdevDevice`
  `udev_device_new_from_syspath(Udev.UdevContext udev, String syspath)`
  Allocates a new udev device object and returns a pointer to it.
  `Udev.UdevDevice`
  `udev_device_ref(Udev.UdevDevice udev_device)`
  Acquire further references to a udev device object.
  `Udev.UdevDevice`
  `udev_device_unref(Udev.UdevDevice udev_device)`
  Drop a reference to a udev device object.
  `int`
  `udev_enumerate_add_match_subsystem(Udev.UdevEnumerate udev_enumerate, String subsystem)`
  Modify filters of a udev enumerate object to match a subsystem.
  `Udev.UdevListEntry`
  `udev_enumerate_get_list_entry(Udev.UdevEnumerate udev_enumerate)`
  Get the first list entry from a udev enumerate object.
  `Udev.UdevEnumerate`
  `udev_enumerate_new(Udev.UdevContext udev)`
  Create a udev enumerate object.
  `Udev.UdevEnumerate`
  `udev_enumerate_ref(Udev.UdevEnumerate udev_enumerate)`
  Acquire further references to a udev enumerate object.
  `int`
  `udev_enumerate_scan_devices(Udev.UdevEnumerate udev_enumerate)`
  Query a udev enumerate object.
  `Udev.UdevEnumerate`
  `udev_enumerate_unref(Udev.UdevEnumerate udev_enumerate)`
  Drop a reference to a udev enumerate object.
  `String`
  `udev_list_entry_get_name(Udev.UdevListEntry list_entry)`
  Get the name of the udev list entry
  `Udev.UdevListEntry`
  `udev_list_entry_get_next(Udev.UdevListEntry list_entry)`
  Gets the next entry in the enumeration.
  `Udev.UdevContext`
  `udev_new()`
  Allocates a new udev context object and returns a pointer to it.
  `Udev.UdevContext`
  `udev_ref(Udev.UdevContext udev)`
  Acquire further references to a udev context object.
  `Udev.UdevContext`
  `udev_unref(Udev.UdevContext udev)`
  Drop a reference to a udev context object.

- ## Field Details

  - ### INSTANCE

    static final Udev INSTANCE

- ## Method Details

  - ### udev_new

    Udev.UdevContext udev_new()
    Allocates a new udev context object and returns a pointer to it. This object is opaque and must not be accessed by the caller via different means than functions provided by libudev. Initially, the reference count of the context is 1.
    Returns:
      On success, returns a pointer to the allocated udev context. On failure, NULL is returned.

  - ### udev_ref

    Udev.UdevContext udev_ref(Udev.UdevContext udev)
    Acquire further references to a udev context object.
    Parameters:
      `udev` - A udev context object.
    Returns:
      the argument that was passed, unmodified.

  - ### udev_unref

    Udev.UdevContext udev_unref(Udev.UdevContext udev)
    Drop a reference to a udev context object. Once the reference count hits 0, the context object is destroyed and freed.
    Parameters:
      `udev` - A udev context object.
    Returns:
      always returns NULL.

  - ### udev_device_new_from_syspath

    Udev.UdevDevice udev_device_new_from_syspath(Udev.UdevContext udev, String syspath)
    Allocates a new udev device object and returns a pointer to it. This object is opaque and must not be accessed by the caller via different means than functions provided by libudev. Initially, the reference count of the device is 1.

    Creates the device object based on information found in `/sys`, annotated with properties from the udev-internal device database. A syspath is any subdirectory of `/sys`, with the restriction that a subdirectory of `/sys/devices` (or a symlink to one) represents a real device and as such must contain a uevent file.

    Parameters:
      `udev` - A udev context object.
      `syspath` - The path of the device in `/sys`.
    Returns:
      a pointer to the allocated udev device. On failure, NULL is returned, and `errno` is set appropriately.

  - ### udev_enumerate_new

    Udev.UdevEnumerate udev_enumerate_new(Udev.UdevContext udev)
    Create a udev enumerate object. Initially, the reference count of the enumerate object is 1.
    Parameters:
      `udev` - A udev context object.
    Returns:
      On success, returns a pointer to the allocated udev monitor. On failure, NULL is returned.

  - ### udev_enumerate_ref

    Udev.UdevEnumerate udev_enumerate_ref(Udev.UdevEnumerate udev_enumerate)
    Acquire further references to a udev enumerate object.
    Parameters:
      `udev_enumerate` - A udev enumerate object.
    Returns:
      the argument that was passed, unmodified.

  - ### udev_enumerate_unref

    Udev.UdevEnumerate udev_enumerate_unref(Udev.UdevEnumerate udev_enumerate)
    Drop a reference to a udev enumerate object. Once the reference count hits 0, the enumerate object is destroyed and freed.
    Parameters:
      `udev_enumerate` - A udev enumerate object.
    Returns:
      always returns NULL.

  - ### udev_enumerate_add_match_subsystem

    int udev_enumerate_add_match_subsystem(Udev.UdevEnumerate udev_enumerate, String subsystem)
    Modify filters of a udev enumerate object to match a subsystem.
    Parameters:
      `udev_enumerate` - The udev enumerate object to modify.
      `subsystem` - The subsystem to match
    Returns:
      an integer greater than, or equal to, 0 on success.

  - ### udev_enumerate_scan_devices

    int udev_enumerate_scan_devices(Udev.UdevEnumerate udev_enumerate)
    Query a udev enumerate object. Scans `/sys` for all devices which match the given filters. No matches will return all currently available devices.
    Parameters:
      `udev_enumerate` - The udev enumerate object, with optional filters.
    Returns:
      an integer greater than, or equal to, 0 on success.

  - ### udev_enumerate_get_list_entry

    Udev.UdevListEntry udev_enumerate_get_list_entry(Udev.UdevEnumerate udev_enumerate)
    Get the first list entry from a udev enumerate object.
    Parameters:
      `udev_enumerate` - The udev enumerate object.
    Returns:
      On success, returns a pointer to the first entry in the list of found devices. If the list is empty, or on failure, NULL is returned.

  - ### udev_list_entry_get_next

    Udev.UdevListEntry udev_list_entry_get_next(Udev.UdevListEntry list_entry)
    Gets the next entry in the enumeration.
    Parameters:
      `list_entry` - the current list entry
    Returns:
      On success, returns a pointer to the next list entry. If no such entry can be found, or on failure, NULL is returned.

  - ### udev_list_entry_get_name

    String udev_list_entry_get_name(Udev.UdevListEntry list_entry)
    Get the name of the udev list entry
    Parameters:
      `list_entry` - A udev list entry
    Returns:
      a pointer to a constant string representing the requested value. The string is bound to the lifetime of the list entry itself. On failure, NULL is returned.

  - ### udev_device_ref

    Udev.UdevDevice udev_device_ref(Udev.UdevDevice udev_device)
    Acquire further references to a udev device object.
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      the argument that was passed, unmodified.

  - ### udev_device_unref

    Udev.UdevDevice udev_device_unref(Udev.UdevDevice udev_device)
    Drop a reference to a udev device object. Once the reference count hits 0, the device object is destroyed and freed.
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      always returns NULL.

  - ### udev_device_get_parent

    Udev.UdevDevice udev_device_get_parent(Udev.UdevDevice udev_device)
    Gets the parent of a udev device
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      a pointer to the parent device. No additional reference to this device is acquired, but the child device owns a reference to such a parent device. On failure, NULL is returned.

  - ### udev_device_get_parent_with_subsystem_devtype

    Udev.UdevDevice udev_device_get_parent_with_subsystem_devtype(Udev.UdevDevice udev_device, String subsystem, String devtype)
    Gets the parent of a udev device matching a subsystem and devtype
    Parameters:
      `udev_device` - A udev device object.
      `subsystem` - The subsystem to match
      `devtype` - The device type to match
    Returns:
      a pointer to the parent device. No additional reference to this device is acquired, but the child device owns a reference to such a parent device. On failure, NULL is returned.

  - ### udev_device_get_syspath

    String udev_device_get_syspath(Udev.UdevDevice udev_device)
    Gets the syspath of a udev device
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      a pointer to a constant string that describes the syspath. The lifetime of this string is bound to the device it was requested on. On failure, may return NULL.

  - ### udev_device_get_sysname

    String udev_device_get_sysname(Udev.UdevDevice udev_device)
    Gets the sysname of a udev device
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      a pointer to a constant string that describes the sysname. The lifetime of this string is bound to the device it was requested on. On failure, may return NULL.

  - ### udev_device_get_devnode

    String udev_device_get_devnode(Udev.UdevDevice udev_device)
    Gets the devnode of a udev device
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      a pointer to a constant string that describes the devnode. The lifetime of this string is bound to the device it was requested on. On failure, may return NULL.

  - ### udev_device_get_devtype

    String udev_device_get_devtype(Udev.UdevDevice udev_device)
    Gets the devtype of a udev device
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      a pointer to a constant string that describes the devtype. The lifetime of this string is bound to the device it was requested on. On failure, may return NULL.

  - ### udev_device_get_subsystem

    String udev_device_get_subsystem(Udev.UdevDevice udev_device)
    Gets the subsystem of a udev device
    Parameters:
      `udev_device` - A udev device object.
    Returns:
      a pointer to a constant string that describes the subsystem. The lifetime of this string is bound to the device it was requested on. On failure, may return NULL.

  - ### udev_device_get_sysattr_value

    String udev_device_get_sysattr_value(Udev.UdevDevice udev_device, String sysattr)
    Retrieves a device attributesfrom a udev device.
    Parameters:
      `udev_device` - A udev device object.
      `sysattr` - The attribute to retrieve.
    Returns:
      a pointer to a constant string of the requested value. On error, NULL is returned. Attributes that may contain NUL bytes should not be retrieved with udev_device_get_sysattr_value(); instead, read them directly from the files within the device's syspath.

  - ### udev_device_get_property_value

    String udev_device_get_property_value(Udev.UdevDevice udev_device, String key)
    Retrieves a device property from a udev device.
    Parameters:
      `udev_device` - A udev device object.
      `key` - The property to retrieve.
    Returns:
      a pointer to a constant string of the requested value. On error, NULL is returned.