## udev_enumerate

udev_enumerate — lookup and sort sys devices

## Synopsis

    struct              udev_enumerate;
    struct udev_enumerate * udev_enumerate_ref              (struct udev_enumerate *udev_enumerate);
    void                udev_enumerate_unref                (struct udev_enumerate *udev_enumerate);
    struct udev *       udev_enumerate_get_udev             (struct udev_enumerate *udev_enumerate);
    struct udev_enumerate * udev_enumerate_new              (struct udev *udev);
    int                 udev_enumerate_add_match_subsystem  (struct udev_enumerate *udev_enumerate,
                                                             const char *subsystem);
    int                 udev_enumerate_add_nomatch_subsystem
                                                            (struct udev_enumerate *udev_enumerate,
                                                             const char *subsystem);
    int                 udev_enumerate_add_match_sysattr    (struct udev_enumerate *udev_enumerate,
                                                             const char *sysattr,
                                                             const char *value);
    int                 udev_enumerate_add_nomatch_sysattr  (struct udev_enumerate *udev_enumerate,
                                                             const char *sysattr,
                                                             const char *value);
    int                 udev_enumerate_add_match_property   (struct udev_enumerate *udev_enumerate,
                                                             const char *property,
                                                             const char *value);
    int                 udev_enumerate_add_match_sysname    (struct udev_enumerate *udev_enumerate,
                                                             const char *sysname);
    int                 udev_enumerate_add_syspath          (struct udev_enumerate *udev_enumerate,
                                                             const char *syspath);
    int                 udev_enumerate_scan_devices         (struct udev_enumerate *udev_enumerate);
    int                 udev_enumerate_scan_subsystems      (struct udev_enumerate *udev_enumerate);
    struct udev_list_entry * udev_enumerate_get_list_entry  (struct udev_enumerate *udev_enumerate);

## Description

Lookup devices in the sys filesystem, filter devices by properties, and return a sorted list of devices.

## Details

### struct udev_enumerate

    struct udev_enumerate;

Opaque object representing one device lookup/sort context.

### udev_enumerate_ref ()

    struct udev_enumerate * udev_enumerate_ref              (struct udev_enumerate *udev_enumerate);

Take a reference of a enumeration context.

`udev_enumerate` : | context
Returns : | the passed enumeration context

### udev_enumerate_unref ()

    void                udev_enumerate_unref                (struct udev_enumerate *udev_enumerate);

Drop a reference of an enumeration context. If the refcount reaches zero, all resources of the enumeration context will be released.

`udev_enumerate` : | context

### udev_enumerate_get_udev ()

    struct udev *       udev_enumerate_get_udev             (struct udev_enumerate *udev_enumerate);

`udev_enumerate` : | context
Returns : | the udev library context.

### udev_enumerate_new ()

    struct udev_enumerate * udev_enumerate_new              (struct udev *udev);

`udev` : | udev library context
Returns : | an enumeration context

### udev_enumerate_add_match_subsystem ()

    int                 udev_enumerate_add_match_subsystem  (struct udev_enumerate *udev_enumerate,
                                                             const char *subsystem);

`udev_enumerate` : | context
`subsystem` : | filter for a subsystem of the device to include in the list
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_add_nomatch_subsystem ()

    int                 udev_enumerate_add_nomatch_subsystem
                                                            (struct udev_enumerate *udev_enumerate,
                                                             const char *subsystem);

`udev_enumerate` : | context
`subsystem` : | filter for a subsystem of the device to exclude from the list
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_add_match_sysattr ()

    int                 udev_enumerate_add_match_sysattr    (struct udev_enumerate *udev_enumerate,
                                                             const char *sysattr,
                                                             const char *value);

`udev_enumerate` : | context
`sysattr` : | filter for a sys attribute at the device to include in the list
`value` : | optional value of the sys attribute
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_add_nomatch_sysattr ()

    int                 udev_enumerate_add_nomatch_sysattr  (struct udev_enumerate *udev_enumerate,
                                                             const char *sysattr,
                                                             const char *value);

`udev_enumerate` : | context
`sysattr` : | filter for a sys attribute at the device to exclude from the list
`value` : | optional value of the sys attribute
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_add_match_property ()

    int                 udev_enumerate_add_match_property   (struct udev_enumerate *udev_enumerate,
                                                             const char *property,
                                                             const char *value);

`udev_enumerate` : | context
`property` : | filter for a property of the device to include in the list
`value` : | value of the property
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_add_match_sysname ()

    int                 udev_enumerate_add_match_sysname    (struct udev_enumerate *udev_enumerate,
                                                             const char *sysname);

`udev_enumerate` : | context
`sysname` : | filter for the name of the device to include in the list
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_add_syspath ()

    int                 udev_enumerate_add_syspath          (struct udev_enumerate *udev_enumerate,
                                                             const char *syspath);

Add a device to the list of devices, to retrieve it back sorted in dependency order.

`udev_enumerate` : | context
`syspath` : | path of a device
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_scan_devices ()

    int                 udev_enumerate_scan_devices         (struct udev_enumerate *udev_enumerate);

`udev_enumerate` : | udev enumeration context
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_scan_subsystems ()

    int                 udev_enumerate_scan_subsystems      (struct udev_enumerate *udev_enumerate);

`udev_enumerate` : | udev enumeration context
Returns : | 0 on success, otherwise a negative error value.

### udev_enumerate_get_list_entry ()

    struct udev_list_entry * udev_enumerate_get_list_entry  (struct udev_enumerate *udev_enumerate);

`udev_enumerate` : | context
Returns : | the first entry of the sorted list of device paths.