udev: libudev Reference Manual

## udev udev — libudev context |

## Functions

struct udev * | udev_ref ()
struct udev * | udev_unref ()
struct udev * | udev_new ()
void | udev_set_log_fn ()
int | udev_get_log_priority ()
void | udev_set_log_priority ()
void * | udev_get_userdata ()
void | udev_set_userdata ()

## Types and Values

struct | udev

## Description

The context contains the default values read from the udev config file, and is passed to all library operations.

## Functions

### udev_ref ()

    struct udev *
    udev_ref (struct udev *udev);

Take a reference of the udev library context.

#### Parameters

udev | udev library context |

#### Returns

the passed udev library context

### udev_unref ()

    struct udev *
    udev_unref (struct udev *udev);

Drop a reference of the udev library context. If the refcount reaches zero, the resources of the context will be released.

#### Parameters

udev | udev library context |

#### Returns

the passed udev library context if it has still an active reference, or NULL otherwise.

### udev_new ()

    struct udev *
    udev_new (void);

Create udev library context. This reads the udev configuration file, and fills in the default values.

The initial refcount is 1, and needs to be decremented to release the resources of the udev library context.

#### Returns

a new udev library context

### udev_set_log_fn ()

    void
    udev_set_log_fn (struct udev *udev,
                     void (*log_fn) (struct udev *udev, int priority, const char *file, int line, const char *fn, const char *format, va_list args));

This function is deprecated.

#### Parameters

udev | udev library context |
log_fn | function to be called for log messages |

### udev_get_log_priority ()

    int
    udev_get_log_priority (struct udev *udev);

This function is deprecated.

#### Parameters

udev | udev library context |

### udev_set_log_priority ()

    void
    udev_set_log_priority (struct udev *udev,
                           int priority);

This function is deprecated.

#### Parameters

udev | udev library context |
priority | the new log priority |

### udev_get_userdata ()

    void *
    udev_get_userdata (struct udev *udev);

Retrieve stored data pointer from library context. This might be useful to access from callbacks.

#### Parameters

udev | udev library context |

#### Returns

stored userdata

### udev_set_userdata ()

    void
    udev_set_userdata (struct udev *udev,
                       void *userdata);

Store custom `userdata` in the library context.

#### Parameters

udev | udev library context |
userdata | data pointer |

## Types and Values

### struct udev

    struct udev;

Opaque object representing the library context.