mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
Merge pull request #9928 from yuwata/libudev-cleanups
libudev: coding style updates
This commit is contained in:
commit
32397af3d4
2
TODO
2
TODO
@ -447,8 +447,6 @@ Features:
|
|||||||
|
|
||||||
* hostnamectl: show root image uuid
|
* hostnamectl: show root image uuid
|
||||||
|
|
||||||
* sysfs set api in libudev is not const
|
|
||||||
|
|
||||||
* Find a solution for SMACK capabilities stuff:
|
* Find a solution for SMACK capabilities stuff:
|
||||||
http://lists.freedesktop.org/archives/systemd-devel/2014-December/026188.html
|
http://lists.freedesktop.org/archives/systemd-devel/2014-December/026188.html
|
||||||
|
|
||||||
|
@ -951,3 +951,39 @@ int mount_option_mangle(
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dev_is_devtmpfs(void) {
|
||||||
|
_cleanup_fclose_ FILE *proc_self_mountinfo = NULL;
|
||||||
|
char line[LINE_MAX], *e;
|
||||||
|
int mount_id, r;
|
||||||
|
|
||||||
|
r = path_get_mnt_id("/dev", &mount_id);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
|
||||||
|
if (!proc_self_mountinfo)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
(void) __fsetlocking(proc_self_mountinfo, FSETLOCKING_BYCALLER);
|
||||||
|
|
||||||
|
FOREACH_LINE(line, proc_self_mountinfo, return -errno) {
|
||||||
|
int mid;
|
||||||
|
|
||||||
|
if (sscanf(line, "%i", &mid) != 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mid != mount_id)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
e = strstr(line, " - ");
|
||||||
|
if (!e)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* accept any name that starts with the currently expected type */
|
||||||
|
if (startswith(e + 3, "devtmpfs"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -54,3 +54,5 @@ int mount_option_mangle(
|
|||||||
unsigned long mount_flags,
|
unsigned long mount_flags,
|
||||||
unsigned long *ret_mount_flags,
|
unsigned long *ret_mount_flags,
|
||||||
char **ret_remaining_options);
|
char **ret_remaining_options);
|
||||||
|
|
||||||
|
int dev_is_devtmpfs(void);
|
||||||
|
@ -1822,7 +1822,7 @@ static void device_remove_sysattr_value(sd_device *device, const char *_key) {
|
|||||||
|
|
||||||
/* set the attribute and save it in the cache. If a NULL value is passed the
|
/* set the attribute and save it in the cache. If a NULL value is passed the
|
||||||
* attribute is cleared from the cache */
|
* attribute is cleared from the cache */
|
||||||
_public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, char *_value) {
|
_public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, const char *_value) {
|
||||||
_cleanup_close_ int fd = -1;
|
_cleanup_close_ int fd = -1;
|
||||||
_cleanup_free_ char *value = NULL;
|
_cleanup_free_ char *value = NULL;
|
||||||
const char *syspath;
|
const char *syspath;
|
||||||
|
@ -18,7 +18,7 @@ struct udev_device {
|
|||||||
sd_device *device;
|
sd_device *device;
|
||||||
|
|
||||||
/* legacy */
|
/* legacy */
|
||||||
int refcount;
|
unsigned n_ref;
|
||||||
|
|
||||||
struct udev_device *parent;
|
struct udev_device *parent;
|
||||||
bool parent_set;
|
bool parent_set;
|
||||||
@ -36,4 +36,4 @@ struct udev_device {
|
|||||||
bool sysattrs_read;
|
bool sysattrs_read;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct udev_device *udev_device_new(struct udev *udev);
|
struct udev_device *udev_device_new(struct udev *udev, sd_device *device);
|
||||||
|
@ -200,79 +200,59 @@ int udev_device_rename(struct udev_device *udev_device, const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct udev_device *udev_device_shallow_clone(struct udev_device *old_device) {
|
struct udev_device *udev_device_shallow_clone(struct udev_device *old_device) {
|
||||||
struct udev_device *device;
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(old_device);
|
assert(old_device);
|
||||||
|
|
||||||
device = udev_device_new(old_device->udev);
|
r = device_shallow_clone(old_device->device, &device);
|
||||||
if (!device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = device_shallow_clone(old_device->device, &device->device);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
udev_device_unref(device);
|
|
||||||
errno = -r;
|
errno = -r;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return device;
|
return udev_device_new(old_device->udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct udev_device *udev_device_clone_with_db(struct udev_device *udev_device_old) {
|
struct udev_device *udev_device_clone_with_db(struct udev_device *udev_device_old) {
|
||||||
struct udev_device *udev_device;
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(udev_device_old);
|
assert(udev_device_old);
|
||||||
|
|
||||||
udev_device = udev_device_new(udev_device_old->udev);
|
r = device_clone_with_db(udev_device_old->device, &device);
|
||||||
if (!udev_device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = device_clone_with_db(udev_device_old->device, &udev_device->device);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
udev_device_unref(udev_device);
|
|
||||||
errno = -r;
|
errno = -r;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return udev_device;
|
return udev_device_new(udev_device_old->udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen) {
|
struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen) {
|
||||||
struct udev_device *device;
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
device = udev_device_new(udev);
|
r = device_new_from_nulstr(&device, (uint8_t*)nulstr, buflen);
|
||||||
if (!device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = device_new_from_nulstr(&device->device, (uint8_t*)nulstr, buflen);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
udev_device_unref(device);
|
|
||||||
errno = -r;
|
errno = -r;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return device;
|
return udev_device_new(udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct udev_device *udev_device_new_from_synthetic_event(struct udev *udev, const char *syspath, const char *action) {
|
struct udev_device *udev_device_new_from_synthetic_event(struct udev *udev, const char *syspath, const char *action) {
|
||||||
struct udev_device *device;
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
device = udev_device_new(udev);
|
r = device_new_from_synthetic_event(&device, syspath, action);
|
||||||
if (!device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = device_new_from_synthetic_event(&device->device, syspath, action);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
udev_device_unref(device);
|
|
||||||
errno = -r;
|
errno = -r;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return device;
|
return udev_device_new(udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
int udev_device_copy_properties(struct udev_device *udev_device_dst, struct udev_device *udev_device_src) {
|
int udev_device_copy_properties(struct udev_device *udev_device_dst, struct udev_device *udev_device_src) {
|
||||||
|
@ -45,8 +45,7 @@
|
|||||||
*
|
*
|
||||||
* Returns: the kernel event sequence number, or 0 if there is no sequence number available.
|
* Returns: the kernel event sequence number, or 0 if there is no sequence number available.
|
||||||
**/
|
**/
|
||||||
_public_ unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device)
|
_public_ unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *seqnum;
|
const char *seqnum;
|
||||||
unsigned long long ret;
|
unsigned long long ret;
|
||||||
int r;
|
int r;
|
||||||
@ -78,8 +77,7 @@ _public_ unsigned long long int udev_device_get_seqnum(struct udev_device *udev_
|
|||||||
*
|
*
|
||||||
* Returns: the dev_t number.
|
* Returns: the dev_t number.
|
||||||
**/
|
**/
|
||||||
_public_ dev_t udev_device_get_devnum(struct udev_device *udev_device)
|
_public_ dev_t udev_device_get_devnum(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
dev_t devnum;
|
dev_t devnum;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -102,8 +100,7 @@ _public_ dev_t udev_device_get_devnum(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the driver name string, or #NULL if there is no driver attached.
|
* Returns: the driver name string, or #NULL if there is no driver attached.
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_driver(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_driver(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *driver;
|
const char *driver;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -126,8 +123,7 @@ _public_ const char *udev_device_get_driver(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the devtype name of the udev device, or #NULL if it cannot be determined
|
* Returns: the devtype name of the udev device, or #NULL if it cannot be determined
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_devtype(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_devtype(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *devtype;
|
const char *devtype;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -151,8 +147,7 @@ _public_ const char *udev_device_get_devtype(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the subsystem name of the udev device, or #NULL if it cannot be determined
|
* Returns: the subsystem name of the udev device, or #NULL if it cannot be determined
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_subsystem(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_subsystem(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *subsystem;
|
const char *subsystem;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -177,8 +172,7 @@ _public_ const char *udev_device_get_subsystem(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the property string, or #NULL if there is no such property.
|
* Returns: the property string, or #NULL if there is no such property.
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key)
|
_public_ const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key) {
|
||||||
{
|
|
||||||
const char *value = NULL;
|
const char *value = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -193,16 +187,23 @@ _public_ const char *udev_device_get_property_value(struct udev_device *udev_dev
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct udev_device *udev_device_new(struct udev *udev) {
|
struct udev_device *udev_device_new(struct udev *udev, sd_device *device) {
|
||||||
struct udev_device *udev_device;
|
struct udev_device *udev_device;
|
||||||
|
|
||||||
udev_device = new0(struct udev_device, 1);
|
assert(device);
|
||||||
|
|
||||||
|
udev_device = new(struct udev_device, 1);
|
||||||
if (!udev_device) {
|
if (!udev_device) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
udev_device->refcount = 1;
|
|
||||||
udev_device->udev = udev;
|
*udev_device = (struct udev_device) {
|
||||||
|
.n_ref = 1,
|
||||||
|
.udev = udev,
|
||||||
|
.device = sd_device_ref(device),
|
||||||
|
};
|
||||||
|
|
||||||
udev_list_init(udev, &udev_device->properties, true);
|
udev_list_init(udev, &udev_device->properties, true);
|
||||||
udev_list_init(udev, &udev_device->tags, true);
|
udev_list_init(udev, &udev_device->tags, true);
|
||||||
udev_list_init(udev, &udev_device->sysattrs, true);
|
udev_list_init(udev, &udev_device->sysattrs, true);
|
||||||
@ -226,21 +227,16 @@ struct udev_device *udev_device_new(struct udev *udev) {
|
|||||||
* Returns: a new udev device, or #NULL, if it does not exist
|
* Returns: a new udev device, or #NULL, if it does not exist
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath) {
|
_public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath) {
|
||||||
struct udev_device *udev_device;
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
udev_device = udev_device_new(udev);
|
r = sd_device_new_from_syspath(&device, syspath);
|
||||||
if (!udev_device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = sd_device_new_from_syspath(&udev_device->device, syspath);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = -r;
|
errno = -r;
|
||||||
udev_device_unref(udev_device);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return udev_device;
|
return udev_device_new(udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -259,23 +255,17 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con
|
|||||||
*
|
*
|
||||||
* Returns: a new udev device, or #NULL, if it does not exist
|
* Returns: a new udev device, or #NULL, if it does not exist
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum)
|
_public_ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum) {
|
||||||
{
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
struct udev_device *udev_device;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
udev_device = udev_device_new(udev);
|
r = sd_device_new_from_devnum(&device, type, devnum);
|
||||||
if (!udev_device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = sd_device_new_from_devnum(&udev_device->device, type, devnum);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = -r;
|
errno = -r;
|
||||||
udev_device_unref(udev_device);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return udev_device;
|
return udev_device_new(udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -296,23 +286,17 @@ _public_ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char
|
|||||||
*
|
*
|
||||||
* Returns: a new udev device, or #NULL, if it does not exist
|
* Returns: a new udev device, or #NULL, if it does not exist
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id)
|
_public_ struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id) {
|
||||||
{
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
struct udev_device *udev_device;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
udev_device = udev_device_new(udev);
|
r = sd_device_new_from_device_id(&device, id);
|
||||||
if (!udev_device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = sd_device_new_from_device_id(&udev_device->device, id);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = -r;
|
errno = -r;
|
||||||
udev_device_unref(udev_device);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return udev_device;
|
return udev_device_new(udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -330,23 +314,17 @@ _public_ struct udev_device *udev_device_new_from_device_id(struct udev *udev, c
|
|||||||
*
|
*
|
||||||
* Returns: a new udev device, or #NULL, if it does not exist
|
* Returns: a new udev device, or #NULL, if it does not exist
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname)
|
_public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname) {
|
||||||
{
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
struct udev_device *udev_device;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
udev_device = udev_device_new(udev);
|
r = sd_device_new_from_subsystem_sysname(&device, subsystem, sysname);
|
||||||
if (!udev_device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = sd_device_new_from_subsystem_sysname(&udev_device->device, subsystem, sysname);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = -r;
|
errno = -r;
|
||||||
udev_device_unref(udev_device);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return udev_device;
|
return udev_device_new(udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -363,47 +341,32 @@ _public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev
|
|||||||
*
|
*
|
||||||
* Returns: a new udev device, or #NULL, if it does not exist
|
* Returns: a new udev device, or #NULL, if it does not exist
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_new_from_environment(struct udev *udev)
|
_public_ struct udev_device *udev_device_new_from_environment(struct udev *udev) {
|
||||||
{
|
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||||
struct udev_device *udev_device;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
udev_device = udev_device_new(udev);
|
r = device_new_from_strv(&device, environ);
|
||||||
if (!udev_device)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = device_new_from_strv(&udev_device->device, environ);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = -r;
|
errno = -r;
|
||||||
udev_device_unref(udev_device);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return udev_device;
|
return udev_device_new(udev, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct udev_device *device_new_from_parent(struct udev_device *child)
|
static struct udev_device *device_new_from_parent(struct udev_device *child) {
|
||||||
{
|
sd_device *parent;
|
||||||
struct udev_device *parent;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert_return_errno(child, NULL, EINVAL);
|
assert_return_errno(child, NULL, EINVAL);
|
||||||
|
|
||||||
parent = udev_device_new(child->udev);
|
r = sd_device_get_parent(child->device, &parent);
|
||||||
if (!parent)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
r = sd_device_get_parent(child->device, &parent->device);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = -r;
|
errno = -r;
|
||||||
udev_device_unref(parent);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the parent is unref'ed with the child, so take a ref from libudev as well */
|
return udev_device_new(child->udev, parent);
|
||||||
sd_device_ref(parent->device);
|
|
||||||
|
|
||||||
return parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -424,8 +387,7 @@ static struct udev_device *device_new_from_parent(struct udev_device *child)
|
|||||||
*
|
*
|
||||||
* Returns: a new udev device, or #NULL, if it no parent exist.
|
* Returns: a new udev device, or #NULL, if it no parent exist.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_get_parent(struct udev_device *udev_device)
|
_public_ struct udev_device *udev_device_get_parent(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
assert_return_errno(udev_device, NULL, EINVAL);
|
assert_return_errno(udev_device, NULL, EINVAL);
|
||||||
|
|
||||||
if (!udev_device->parent_set) {
|
if (!udev_device->parent_set) {
|
||||||
@ -458,8 +420,7 @@ _public_ struct udev_device *udev_device_get_parent(struct udev_device *udev_dev
|
|||||||
*
|
*
|
||||||
* Returns: a new udev device, or #NULL if no matching parent exists.
|
* Returns: a new udev device, or #NULL if no matching parent exists.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype)
|
_public_ struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype) {
|
||||||
{
|
|
||||||
sd_device *parent;
|
sd_device *parent;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -494,13 +455,26 @@ _public_ struct udev_device *udev_device_get_parent_with_subsystem_devtype(struc
|
|||||||
*
|
*
|
||||||
* Returns: the udev library context
|
* Returns: the udev library context
|
||||||
**/
|
**/
|
||||||
_public_ struct udev *udev_device_get_udev(struct udev_device *udev_device)
|
_public_ struct udev *udev_device_get_udev(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
assert_return_errno(udev_device, NULL, EINVAL);
|
assert_return_errno(udev_device, NULL, EINVAL);
|
||||||
|
|
||||||
return udev_device->udev;
|
return udev_device->udev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct udev_device *udev_device_free(struct udev_device *udev_device) {
|
||||||
|
assert(udev_device);
|
||||||
|
|
||||||
|
sd_device_unref(udev_device->device);
|
||||||
|
udev_device_unref(udev_device->parent);
|
||||||
|
|
||||||
|
udev_list_cleanup(&udev_device->properties);
|
||||||
|
udev_list_cleanup(&udev_device->sysattrs);
|
||||||
|
udev_list_cleanup(&udev_device->tags);
|
||||||
|
udev_list_cleanup(&udev_device->devlinks);
|
||||||
|
|
||||||
|
return mfree(udev_device);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_device_ref:
|
* udev_device_ref:
|
||||||
* @udev_device: udev device
|
* @udev_device: udev device
|
||||||
@ -509,13 +483,6 @@ _public_ struct udev *udev_device_get_udev(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the passed udev device
|
* Returns: the passed udev device
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_ref(struct udev_device *udev_device)
|
|
||||||
{
|
|
||||||
if (udev_device)
|
|
||||||
udev_device->refcount++;
|
|
||||||
|
|
||||||
return udev_device;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_device_unref:
|
* udev_device_unref:
|
||||||
@ -526,22 +493,7 @@ _public_ struct udev_device *udev_device_ref(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: #NULL
|
* Returns: #NULL
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_device *udev_device_unref(struct udev_device *udev_device)
|
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(struct udev_device, udev_device, udev_device_free);
|
||||||
{
|
|
||||||
if (udev_device && (-- udev_device->refcount) == 0) {
|
|
||||||
sd_device_unref(udev_device->device);
|
|
||||||
udev_device_unref(udev_device->parent);
|
|
||||||
|
|
||||||
udev_list_cleanup(&udev_device->properties);
|
|
||||||
udev_list_cleanup(&udev_device->sysattrs);
|
|
||||||
udev_list_cleanup(&udev_device->tags);
|
|
||||||
udev_list_cleanup(&udev_device->devlinks);
|
|
||||||
|
|
||||||
free(udev_device);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_device_get_devpath:
|
* udev_device_get_devpath:
|
||||||
@ -552,8 +504,7 @@ _public_ struct udev_device *udev_device_unref(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the devpath of the udev device
|
* Returns: the devpath of the udev device
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_devpath(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_devpath(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *devpath;
|
const char *devpath;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -577,8 +528,7 @@ _public_ const char *udev_device_get_devpath(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the sys path of the udev device
|
* Returns: the sys path of the udev device
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_syspath(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_syspath(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *syspath;
|
const char *syspath;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -601,8 +551,7 @@ _public_ const char *udev_device_get_syspath(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the name string of the device
|
* Returns: the name string of the device
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_sysname(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_sysname(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *sysname;
|
const char *sysname;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -625,8 +574,7 @@ _public_ const char *udev_device_get_sysname(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the trailing number string of the device name
|
* Returns: the trailing number string of the device name
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_sysnum(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_sysnum(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *sysnum;
|
const char *sysnum;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -650,8 +598,7 @@ _public_ const char *udev_device_get_sysnum(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the device node file name of the udev device, or #NULL if no device node exists
|
* Returns: the device node file name of the udev device, or #NULL if no device node exists
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_devnode(struct udev_device *udev_device)
|
_public_ const char *udev_device_get_devnode(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
const char *devnode;
|
const char *devnode;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -679,8 +626,7 @@ _public_ const char *udev_device_get_devnode(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the first entry of the device node link list
|
* Returns: the first entry of the device node link list
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device)
|
_public_ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
assert_return_errno(udev_device, NULL, EINVAL);
|
assert_return_errno(udev_device, NULL, EINVAL);
|
||||||
|
|
||||||
if (device_get_devlinks_generation(udev_device->device) != udev_device->devlinks_generation ||
|
if (device_get_devlinks_generation(udev_device->device) != udev_device->devlinks_generation ||
|
||||||
@ -711,8 +657,7 @@ _public_ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev
|
|||||||
*
|
*
|
||||||
* Returns: the first entry of the property list
|
* Returns: the first entry of the property list
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device)
|
_public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
assert_return_errno(udev_device, NULL, EINVAL);
|
assert_return_errno(udev_device, NULL, EINVAL);
|
||||||
|
|
||||||
if (device_get_properties_generation(udev_device->device) != udev_device->properties_generation ||
|
if (device_get_properties_generation(udev_device->device) != udev_device->properties_generation ||
|
||||||
@ -768,8 +713,7 @@ _public_ const char *udev_device_get_action(struct udev_device *udev_device) {
|
|||||||
*
|
*
|
||||||
* Returns: the number of microseconds since the device was first seen.
|
* Returns: the number of microseconds since the device was first seen.
|
||||||
**/
|
**/
|
||||||
_public_ unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device)
|
_public_ unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
usec_t ts;
|
usec_t ts;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -777,7 +721,7 @@ _public_ unsigned long long int udev_device_get_usec_since_initialized(struct ud
|
|||||||
|
|
||||||
r = sd_device_get_usec_since_initialized(udev_device->device, &ts);
|
r = sd_device_get_usec_since_initialized(udev_device->device, &ts);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = EINVAL;
|
errno = -r;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,8 +738,7 @@ _public_ unsigned long long int udev_device_get_usec_since_initialized(struct ud
|
|||||||
*
|
*
|
||||||
* Returns: the content of a sys attribute file, or #NULL if there is no sys attribute value.
|
* Returns: the content of a sys attribute file, or #NULL if there is no sys attribute value.
|
||||||
**/
|
**/
|
||||||
_public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr)
|
_public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr) {
|
||||||
{
|
|
||||||
const char *value;
|
const char *value;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -820,8 +763,7 @@ _public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_devi
|
|||||||
*
|
*
|
||||||
* Returns: Negative error code on failure or 0 on success.
|
* Returns: Negative error code on failure or 0 on success.
|
||||||
**/
|
**/
|
||||||
_public_ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value)
|
_public_ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, const char *value) {
|
||||||
{
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert_return(udev_device, -EINVAL);
|
assert_return(udev_device, -EINVAL);
|
||||||
@ -843,8 +785,7 @@ _public_ int udev_device_set_sysattr_value(struct udev_device *udev_device, cons
|
|||||||
*
|
*
|
||||||
* Returns: the first entry of the property list
|
* Returns: the first entry of the property list
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device)
|
_public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
assert_return_errno(udev_device, NULL, EINVAL);
|
assert_return_errno(udev_device, NULL, EINVAL);
|
||||||
|
|
||||||
if (!udev_device->sysattrs_read) {
|
if (!udev_device->sysattrs_read) {
|
||||||
@ -874,8 +815,7 @@ _public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_
|
|||||||
*
|
*
|
||||||
* Returns: 1 if the device is set up. 0 otherwise.
|
* Returns: 1 if the device is set up. 0 otherwise.
|
||||||
**/
|
**/
|
||||||
_public_ int udev_device_get_is_initialized(struct udev_device *udev_device)
|
_public_ int udev_device_get_is_initialized(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
int r, initialized;
|
int r, initialized;
|
||||||
|
|
||||||
assert_return(udev_device, -EINVAL);
|
assert_return(udev_device, -EINVAL);
|
||||||
@ -883,7 +823,6 @@ _public_ int udev_device_get_is_initialized(struct udev_device *udev_device)
|
|||||||
r = sd_device_get_is_initialized(udev_device->device, &initialized);
|
r = sd_device_get_is_initialized(udev_device->device, &initialized);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
errno = -r;
|
errno = -r;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,8 +840,7 @@ _public_ int udev_device_get_is_initialized(struct udev_device *udev_device)
|
|||||||
*
|
*
|
||||||
* Returns: the first entry of the tag list
|
* Returns: the first entry of the tag list
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device)
|
_public_ struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_device *udev_device) {
|
||||||
{
|
|
||||||
assert_return_errno(udev_device, NULL, EINVAL);
|
assert_return_errno(udev_device, NULL, EINVAL);
|
||||||
|
|
||||||
if (device_get_tags_generation(udev_device->device) != udev_device->tags_generation ||
|
if (device_get_tags_generation(udev_device->device) != udev_device->tags_generation ||
|
||||||
@ -930,9 +868,8 @@ _public_ struct udev_list_entry *udev_device_get_tags_list_entry(struct udev_dev
|
|||||||
*
|
*
|
||||||
* Returns: 1 if the tag is found. 0 otherwise.
|
* Returns: 1 if the tag is found. 0 otherwise.
|
||||||
**/
|
**/
|
||||||
_public_ int udev_device_has_tag(struct udev_device *udev_device, const char *tag)
|
_public_ int udev_device_has_tag(struct udev_device *udev_device, const char *tag) {
|
||||||
{
|
|
||||||
assert_return(udev_device, 0);
|
assert_return(udev_device, 0);
|
||||||
|
|
||||||
return sd_device_has_tag(udev_device->device, tag);
|
return sd_device_has_tag(udev_device->device, tag) > 0;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
struct udev_enumerate {
|
struct udev_enumerate {
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
int refcount;
|
unsigned n_ref;
|
||||||
struct udev_list devices_list;
|
struct udev_list devices_list;
|
||||||
bool devices_uptodate:1;
|
bool devices_uptodate:1;
|
||||||
|
|
||||||
@ -49,33 +49,45 @@ struct udev_enumerate {
|
|||||||
* Returns: an enumeration context.
|
* Returns: an enumeration context.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev) {
|
_public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev) {
|
||||||
_cleanup_free_ struct udev_enumerate *udev_enumerate = NULL;
|
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
|
||||||
|
struct udev_enumerate *udev_enumerate;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
udev_enumerate = new0(struct udev_enumerate, 1);
|
r = sd_device_enumerator_new(&e);
|
||||||
|
if (r < 0) {
|
||||||
|
errno = -r;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = sd_device_enumerator_allow_uninitialized(e);
|
||||||
|
if (r < 0) {
|
||||||
|
errno = -r;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
udev_enumerate = new(struct udev_enumerate, 1);
|
||||||
if (!udev_enumerate) {
|
if (!udev_enumerate) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sd_device_enumerator_new(&udev_enumerate->enumerator);
|
*udev_enumerate = (struct udev_enumerate) {
|
||||||
if (r < 0) {
|
.udev = udev,
|
||||||
errno = -r;
|
.n_ref = 1,
|
||||||
return NULL;
|
.enumerator = TAKE_PTR(e),
|
||||||
}
|
};
|
||||||
|
|
||||||
r = sd_device_enumerator_allow_uninitialized(udev_enumerate->enumerator);
|
|
||||||
if (r < 0) {
|
|
||||||
errno = -r;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
udev_enumerate->refcount = 1;
|
|
||||||
udev_enumerate->udev = udev;
|
|
||||||
|
|
||||||
udev_list_init(udev, &udev_enumerate->devices_list, false);
|
udev_list_init(udev, &udev_enumerate->devices_list, false);
|
||||||
|
|
||||||
return TAKE_PTR(udev_enumerate);
|
return udev_enumerate;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct udev_enumerate *udev_enumerate_free(struct udev_enumerate *udev_enumerate) {
|
||||||
|
assert(udev_enumerate);
|
||||||
|
|
||||||
|
udev_list_cleanup(&udev_enumerate->devices_list);
|
||||||
|
sd_device_enumerator_unref(udev_enumerate->enumerator);
|
||||||
|
return mfree(udev_enumerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,12 +98,6 @@ _public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev) {
|
|||||||
*
|
*
|
||||||
* Returns: the passed enumeration context
|
* Returns: the passed enumeration context
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate) {
|
|
||||||
if (udev_enumerate)
|
|
||||||
udev_enumerate->refcount++;
|
|
||||||
|
|
||||||
return udev_enumerate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_enumerate_unref:
|
* udev_enumerate_unref:
|
||||||
@ -102,15 +108,7 @@ _public_ struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_e
|
|||||||
*
|
*
|
||||||
* Returns: #NULL
|
* Returns: #NULL
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate) {
|
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(struct udev_enumerate, udev_enumerate, udev_enumerate_free);
|
||||||
if (udev_enumerate && (-- udev_enumerate->refcount) == 0) {
|
|
||||||
udev_list_cleanup(&udev_enumerate->devices_list);
|
|
||||||
sd_device_enumerator_unref(udev_enumerate->enumerator);
|
|
||||||
free(udev_enumerate);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_enumerate_get_udev:
|
* udev_enumerate_get_udev:
|
||||||
|
@ -19,17 +19,14 @@
|
|||||||
* Opaque object representing the hardware database.
|
* Opaque object representing the hardware database.
|
||||||
*/
|
*/
|
||||||
struct udev_hwdb {
|
struct udev_hwdb {
|
||||||
struct udev *udev;
|
unsigned n_ref;
|
||||||
int refcount;
|
|
||||||
|
|
||||||
sd_hwdb *hwdb;
|
sd_hwdb *hwdb;
|
||||||
|
|
||||||
struct udev_list properties_list;
|
struct udev_list properties_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_hwdb_new:
|
* udev_hwdb_new:
|
||||||
* @udev: udev library context
|
* @udev: udev library context (unused)
|
||||||
*
|
*
|
||||||
* Create a hardware database context to query properties for devices.
|
* Create a hardware database context to query properties for devices.
|
||||||
*
|
*
|
||||||
@ -46,20 +43,30 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwdb = new0(struct udev_hwdb, 1);
|
hwdb = new(struct udev_hwdb, 1);
|
||||||
if (!hwdb) {
|
if (!hwdb) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hwdb->refcount = 1;
|
*hwdb = (struct udev_hwdb) {
|
||||||
hwdb->hwdb = TAKE_PTR(hwdb_internal);
|
.n_ref = 1,
|
||||||
|
.hwdb = TAKE_PTR(hwdb_internal),
|
||||||
|
};
|
||||||
|
|
||||||
udev_list_init(udev, &hwdb->properties_list, true);
|
udev_list_init(udev, &hwdb->properties_list, true);
|
||||||
|
|
||||||
return hwdb;
|
return hwdb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct udev_hwdb *udev_hwdb_free(struct udev_hwdb *hwdb) {
|
||||||
|
assert(hwdb);
|
||||||
|
|
||||||
|
sd_hwdb_unref(hwdb->hwdb);
|
||||||
|
udev_list_cleanup(&hwdb->properties_list);
|
||||||
|
return mfree(hwdb);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_hwdb_ref:
|
* udev_hwdb_ref:
|
||||||
* @hwdb: context
|
* @hwdb: context
|
||||||
@ -68,12 +75,6 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
|
|||||||
*
|
*
|
||||||
* Returns: the passed enumeration context
|
* Returns: the passed enumeration context
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb) {
|
|
||||||
if (!hwdb)
|
|
||||||
return NULL;
|
|
||||||
hwdb->refcount++;
|
|
||||||
return hwdb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_hwdb_unref:
|
* udev_hwdb_unref:
|
||||||
@ -84,16 +85,7 @@ _public_ struct udev_hwdb *udev_hwdb_ref(struct udev_hwdb *hwdb) {
|
|||||||
*
|
*
|
||||||
* Returns: #NULL
|
* Returns: #NULL
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_hwdb *udev_hwdb_unref(struct udev_hwdb *hwdb) {
|
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(struct udev_hwdb, udev_hwdb, udev_hwdb_free);
|
||||||
if (!hwdb)
|
|
||||||
return NULL;
|
|
||||||
hwdb->refcount--;
|
|
||||||
if (hwdb->refcount > 0)
|
|
||||||
return NULL;
|
|
||||||
sd_hwdb_unref(hwdb->hwdb);
|
|
||||||
udev_list_cleanup(&hwdb->properties_list);
|
|
||||||
return mfree(hwdb);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_hwdb_get_properties_list_entry:
|
* udev_hwdb_get_properties_list_entry:
|
||||||
@ -112,10 +104,8 @@ _public_ struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev
|
|||||||
const char *key, *value;
|
const char *key, *value;
|
||||||
struct udev_list_entry *e;
|
struct udev_list_entry *e;
|
||||||
|
|
||||||
if (!hwdb || !modalias) {
|
assert_return_errno(hwdb, NULL, EINVAL);
|
||||||
errno = EINVAL;
|
assert_return_errno(modalias, NULL, EINVAL);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
udev_list_cleanup(&hwdb->properties_list);
|
udev_list_cleanup(&hwdb->properties_list);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -16,9 +16,6 @@
|
|||||||
#define READ_END 0
|
#define READ_END 0
|
||||||
#define WRITE_END 1
|
#define WRITE_END 1
|
||||||
|
|
||||||
/* libudev.c */
|
|
||||||
int udev_get_rules_path(struct udev *udev, char **path[], usec_t *ts_usec[]);
|
|
||||||
|
|
||||||
/* libudev-device.c */
|
/* libudev-device.c */
|
||||||
struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen);
|
struct udev_device *udev_device_new_from_nulstr(struct udev *udev, char *nulstr, ssize_t buflen);
|
||||||
struct udev_device *udev_device_new_from_synthetic_event(struct udev *udev, const char *syspath, const char *action);
|
struct udev_device *udev_device_new_from_synthetic_event(struct udev *udev, const char *syspath, const char *action);
|
||||||
@ -40,7 +37,6 @@ void udev_device_set_is_initialized(struct udev_device *udev_device);
|
|||||||
int udev_device_add_tag(struct udev_device *udev_device, const char *tag);
|
int udev_device_add_tag(struct udev_device *udev_device, const char *tag);
|
||||||
void udev_device_remove_tag(struct udev_device *udev_device, const char *tag);
|
void udev_device_remove_tag(struct udev_device *udev_device, const char *tag);
|
||||||
void udev_device_cleanup_tags_list(struct udev_device *udev_device);
|
void udev_device_cleanup_tags_list(struct udev_device *udev_device);
|
||||||
usec_t udev_device_get_usec_initialized(struct udev_device *udev_device);
|
|
||||||
void udev_device_ensure_usec_initialized(struct udev_device *udev_device, struct udev_device *old_device);
|
void udev_device_ensure_usec_initialized(struct udev_device *udev_device, struct udev_device *old_device);
|
||||||
int udev_device_get_devlink_priority(struct udev_device *udev_device);
|
int udev_device_get_devlink_priority(struct udev_device *udev_device);
|
||||||
int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio);
|
int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio);
|
||||||
@ -48,11 +44,8 @@ int udev_device_get_watch_handle(struct udev_device *udev_device);
|
|||||||
int udev_device_set_watch_handle(struct udev_device *udev_device, int handle);
|
int udev_device_set_watch_handle(struct udev_device *udev_device, int handle);
|
||||||
int udev_device_get_ifindex(struct udev_device *udev_device);
|
int udev_device_get_ifindex(struct udev_device *udev_device);
|
||||||
void udev_device_set_info_loaded(struct udev_device *device);
|
void udev_device_set_info_loaded(struct udev_device *device);
|
||||||
bool udev_device_get_db_persist(struct udev_device *udev_device);
|
|
||||||
void udev_device_set_db_persist(struct udev_device *udev_device);
|
void udev_device_set_db_persist(struct udev_device *udev_device);
|
||||||
void udev_device_read_db(struct udev_device *udev_device);
|
void udev_device_read_db(struct udev_device *udev_device);
|
||||||
|
|
||||||
/* libudev-device-private.c */
|
|
||||||
int udev_device_update_db(struct udev_device *udev_device);
|
int udev_device_update_db(struct udev_device *udev_device);
|
||||||
int udev_device_delete_db(struct udev_device *udev_device);
|
int udev_device_delete_db(struct udev_device *udev_device);
|
||||||
int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old, bool add);
|
int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old, bool add);
|
||||||
@ -101,19 +94,6 @@ void udev_list_entry_set_num(struct udev_list_entry *list_entry, int num);
|
|||||||
entry != NULL; \
|
entry != NULL; \
|
||||||
entry = tmp, tmp = udev_list_entry_get_next(tmp))
|
entry = tmp, tmp = udev_list_entry_get_next(tmp))
|
||||||
|
|
||||||
/* libudev-queue.c */
|
|
||||||
unsigned long long int udev_get_kernel_seqnum(struct udev *udev);
|
|
||||||
int udev_queue_read_seqnum(FILE *queue_file, unsigned long long int *seqnum);
|
|
||||||
ssize_t udev_queue_read_devpath(FILE *queue_file, char *devpath, size_t size);
|
|
||||||
ssize_t udev_queue_skip_devpath(FILE *queue_file);
|
|
||||||
|
|
||||||
/* libudev-queue-private.c */
|
|
||||||
struct udev_queue_export *udev_queue_export_new(struct udev *udev);
|
|
||||||
struct udev_queue_export *udev_queue_export_unref(struct udev_queue_export *udev_queue_export);
|
|
||||||
void udev_queue_export_cleanup(struct udev_queue_export *udev_queue_export);
|
|
||||||
int udev_queue_export_device_queued(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device);
|
|
||||||
int udev_queue_export_device_finished(struct udev_queue_export *udev_queue_export, struct udev_device *udev_device);
|
|
||||||
|
|
||||||
/* libudev-util.c */
|
/* libudev-util.c */
|
||||||
#define UTIL_PATH_SIZE 1024
|
#define UTIL_PATH_SIZE 1024
|
||||||
#define UTIL_NAME_SIZE 512
|
#define UTIL_NAME_SIZE 512
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
struct udev_queue {
|
struct udev_queue {
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
int refcount;
|
unsigned n_ref;
|
||||||
int fd;
|
int fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,22 +41,31 @@ struct udev_queue {
|
|||||||
*
|
*
|
||||||
* Returns: the udev queue context, or #NULL on error.
|
* Returns: the udev queue context, or #NULL on error.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_queue *udev_queue_new(struct udev *udev)
|
_public_ struct udev_queue *udev_queue_new(struct udev *udev) {
|
||||||
{
|
|
||||||
struct udev_queue *udev_queue;
|
struct udev_queue *udev_queue;
|
||||||
|
|
||||||
udev_queue = new0(struct udev_queue, 1);
|
udev_queue = new(struct udev_queue, 1);
|
||||||
if (udev_queue == NULL) {
|
if (udev_queue == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
udev_queue->refcount = 1;
|
*udev_queue = (struct udev_queue) {
|
||||||
udev_queue->udev = udev;
|
.udev = udev,
|
||||||
udev_queue->fd = -1;
|
.n_ref = 1,
|
||||||
|
.fd = -1,
|
||||||
|
};
|
||||||
|
|
||||||
return udev_queue;
|
return udev_queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct udev_queue *udev_queue_free(struct udev_queue *udev_queue) {
|
||||||
|
assert(udev_queue);
|
||||||
|
|
||||||
|
safe_close(udev_queue->fd);
|
||||||
|
return mfree(udev_queue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_queue_ref:
|
* udev_queue_ref:
|
||||||
* @udev_queue: udev queue context
|
* @udev_queue: udev queue context
|
||||||
@ -65,14 +74,6 @@ _public_ struct udev_queue *udev_queue_new(struct udev *udev)
|
|||||||
*
|
*
|
||||||
* Returns: the same udev queue context.
|
* Returns: the same udev queue context.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue)
|
|
||||||
{
|
|
||||||
if (udev_queue == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
udev_queue->refcount++;
|
|
||||||
return udev_queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_queue_unref:
|
* udev_queue_unref:
|
||||||
@ -83,19 +84,7 @@ _public_ struct udev_queue *udev_queue_ref(struct udev_queue *udev_queue)
|
|||||||
*
|
*
|
||||||
* Returns: #NULL
|
* Returns: #NULL
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue)
|
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(struct udev_queue, udev_queue, udev_queue_free);
|
||||||
{
|
|
||||||
if (udev_queue == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
udev_queue->refcount--;
|
|
||||||
if (udev_queue->refcount > 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
safe_close(udev_queue->fd);
|
|
||||||
|
|
||||||
return mfree(udev_queue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_queue_get_udev:
|
* udev_queue_get_udev:
|
||||||
@ -105,12 +94,9 @@ _public_ struct udev_queue *udev_queue_unref(struct udev_queue *udev_queue)
|
|||||||
*
|
*
|
||||||
* Returns: the udev library context.
|
* Returns: the udev library context.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev *udev_queue_get_udev(struct udev_queue *udev_queue)
|
_public_ struct udev *udev_queue_get_udev(struct udev_queue *udev_queue) {
|
||||||
{
|
assert_return_errno(udev_queue, NULL, EINVAL);
|
||||||
if (udev_queue == NULL) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return udev_queue->udev;
|
return udev_queue->udev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +108,7 @@ _public_ struct udev *udev_queue_get_udev(struct udev_queue *udev_queue)
|
|||||||
*
|
*
|
||||||
* Returns: 0.
|
* Returns: 0.
|
||||||
**/
|
**/
|
||||||
_public_ unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue)
|
_public_ unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *udev_queue) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +120,7 @@ _public_ unsigned long long int udev_queue_get_kernel_seqnum(struct udev_queue *
|
|||||||
*
|
*
|
||||||
* Returns: 0.
|
* Returns: 0.
|
||||||
**/
|
**/
|
||||||
_public_ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue)
|
_public_ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *udev_queue) {
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,8 +132,7 @@ _public_ unsigned long long int udev_queue_get_udev_seqnum(struct udev_queue *ud
|
|||||||
*
|
*
|
||||||
* Returns: a flag indicating if udev is active.
|
* Returns: a flag indicating if udev is active.
|
||||||
**/
|
**/
|
||||||
_public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue)
|
_public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue) {
|
||||||
{
|
|
||||||
return access("/run/udev/control", F_OK) >= 0;
|
return access("/run/udev/control", F_OK) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,8 +144,7 @@ _public_ int udev_queue_get_udev_is_active(struct udev_queue *udev_queue)
|
|||||||
*
|
*
|
||||||
* Returns: a flag indicating if udev is currently handling events.
|
* Returns: a flag indicating if udev is currently handling events.
|
||||||
**/
|
**/
|
||||||
_public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue)
|
_public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue) {
|
||||||
{
|
|
||||||
return access("/run/udev/queue", F_OK) < 0;
|
return access("/run/udev/queue", F_OK) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,8 +160,7 @@ _public_ int udev_queue_get_queue_is_empty(struct udev_queue *udev_queue)
|
|||||||
* Returns: a flag indicating if udev is currently handling events.
|
* Returns: a flag indicating if udev is currently handling events.
|
||||||
**/
|
**/
|
||||||
_public_ int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue,
|
_public_ int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_queue,
|
||||||
unsigned long long int start, unsigned long long int end)
|
unsigned long long int start, unsigned long long int end) {
|
||||||
{
|
|
||||||
return udev_queue_get_queue_is_empty(udev_queue);
|
return udev_queue_get_queue_is_empty(udev_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +174,7 @@ _public_ int udev_queue_get_seqnum_sequence_is_finished(struct udev_queue *udev_
|
|||||||
*
|
*
|
||||||
* Returns: a flag indicating if udev is currently handling events.
|
* Returns: a flag indicating if udev is currently handling events.
|
||||||
**/
|
**/
|
||||||
_public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum)
|
_public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, unsigned long long int seqnum) {
|
||||||
{
|
|
||||||
return udev_queue_get_queue_is_empty(udev_queue);
|
return udev_queue_get_queue_is_empty(udev_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,8 +186,7 @@ _public_ int udev_queue_get_seqnum_is_finished(struct udev_queue *udev_queue, un
|
|||||||
*
|
*
|
||||||
* Returns: NULL.
|
* Returns: NULL.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue)
|
_public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_queue *udev_queue) {
|
||||||
{
|
|
||||||
errno = ENODATA;
|
errno = ENODATA;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -219,8 +198,9 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu
|
|||||||
* Returns: a file descriptor to watch for a queue to become empty.
|
* Returns: a file descriptor to watch for a queue to become empty.
|
||||||
*/
|
*/
|
||||||
_public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
|
_public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
|
||||||
int fd;
|
_cleanup_close_ int fd = -1;
|
||||||
int r;
|
|
||||||
|
assert_return(udev_queue, -EINVAL);
|
||||||
|
|
||||||
if (udev_queue->fd >= 0)
|
if (udev_queue->fd >= 0)
|
||||||
return udev_queue->fd;
|
return udev_queue->fd;
|
||||||
@ -229,15 +209,11 @@ _public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
r = inotify_add_watch(fd, "/run/udev" , IN_DELETE);
|
if (inotify_add_watch(fd, "/run/udev" , IN_DELETE) < 0)
|
||||||
if (r < 0) {
|
return -errno;
|
||||||
r = -errno;
|
|
||||||
close(fd);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
udev_queue->fd = fd;
|
udev_queue->fd = TAKE_FD(fd);
|
||||||
return fd;
|
return udev_queue->fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,7 +225,7 @@ _public_ int udev_queue_get_fd(struct udev_queue *udev_queue) {
|
|||||||
_public_ int udev_queue_flush(struct udev_queue *udev_queue) {
|
_public_ int udev_queue_flush(struct udev_queue *udev_queue) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(udev_queue);
|
assert_return(udev_queue, -EINVAL);
|
||||||
|
|
||||||
if (udev_queue->fd < 0)
|
if (udev_queue->fd < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -18,9 +18,6 @@
|
|||||||
/**
|
/**
|
||||||
* SECTION:libudev
|
* SECTION:libudev
|
||||||
* @short_description: libudev context
|
* @short_description: libudev context
|
||||||
*
|
|
||||||
* The context contains the default values read from the udev config file,
|
|
||||||
* and is passed to all library operations.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,10 +26,7 @@
|
|||||||
* Opaque object representing the library context.
|
* Opaque object representing the library context.
|
||||||
*/
|
*/
|
||||||
struct udev {
|
struct udev {
|
||||||
int refcount;
|
unsigned n_ref;
|
||||||
void (*log_fn)(struct udev *udev,
|
|
||||||
int priority, const char *file, int line, const char *fn,
|
|
||||||
const char *format, va_list args);
|
|
||||||
void *userdata;
|
void *userdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,8 +40,8 @@ struct udev {
|
|||||||
* Returns: stored userdata
|
* Returns: stored userdata
|
||||||
**/
|
**/
|
||||||
_public_ void *udev_get_userdata(struct udev *udev) {
|
_public_ void *udev_get_userdata(struct udev *udev) {
|
||||||
if (udev == NULL)
|
assert_return(udev, NULL);
|
||||||
return NULL;
|
|
||||||
return udev->userdata;
|
return udev->userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,8 +53,9 @@ _public_ void *udev_get_userdata(struct udev *udev) {
|
|||||||
* Store custom @userdata in the library context.
|
* Store custom @userdata in the library context.
|
||||||
**/
|
**/
|
||||||
_public_ void udev_set_userdata(struct udev *udev, void *userdata) {
|
_public_ void udev_set_userdata(struct udev *udev, void *userdata) {
|
||||||
if (udev == NULL)
|
if (!udev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
udev->userdata = userdata;
|
udev->userdata = userdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,12 +72,15 @@ _public_ void udev_set_userdata(struct udev *udev, void *userdata) {
|
|||||||
_public_ struct udev *udev_new(void) {
|
_public_ struct udev *udev_new(void) {
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
|
|
||||||
udev = new0(struct udev, 1);
|
udev = new(struct udev, 1);
|
||||||
if (!udev) {
|
if (!udev) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
udev->refcount = 1;
|
|
||||||
|
*udev = (struct udev) {
|
||||||
|
.n_ref = 1,
|
||||||
|
};
|
||||||
|
|
||||||
return udev;
|
return udev;
|
||||||
}
|
}
|
||||||
@ -95,12 +93,7 @@ _public_ struct udev *udev_new(void) {
|
|||||||
*
|
*
|
||||||
* Returns: the passed udev library context
|
* Returns: the passed udev library context
|
||||||
**/
|
**/
|
||||||
_public_ struct udev *udev_ref(struct udev *udev) {
|
DEFINE_PUBLIC_TRIVIAL_REF_FUNC(struct udev, udev);
|
||||||
if (udev == NULL)
|
|
||||||
return NULL;
|
|
||||||
udev->refcount++;
|
|
||||||
return udev;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* udev_unref:
|
* udev_unref:
|
||||||
@ -112,11 +105,17 @@ _public_ struct udev *udev_ref(struct udev *udev) {
|
|||||||
* Returns: the passed udev library context if it has still an active reference, or #NULL otherwise.
|
* Returns: the passed udev library context if it has still an active reference, or #NULL otherwise.
|
||||||
**/
|
**/
|
||||||
_public_ struct udev *udev_unref(struct udev *udev) {
|
_public_ struct udev *udev_unref(struct udev *udev) {
|
||||||
if (udev == NULL)
|
if (!udev)
|
||||||
return NULL;
|
return NULL;
|
||||||
udev->refcount--;
|
|
||||||
if (udev->refcount > 0)
|
assert(udev->n_ref > 0);
|
||||||
|
udev->n_ref--;
|
||||||
|
if (udev->n_ref > 0)
|
||||||
|
/* This is different from our convetion, but let's keep backward
|
||||||
|
* compatibility. So, do not use DEFINE_PUBLIC_TRIVIAL_UNREF_FUNC()
|
||||||
|
* macro to define this function. */
|
||||||
return udev;
|
return udev;
|
||||||
|
|
||||||
return mfree(udev);
|
return mfree(udev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,10 +127,11 @@ _public_ struct udev *udev_unref(struct udev *udev) {
|
|||||||
* This function is deprecated.
|
* This function is deprecated.
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
_public_ void udev_set_log_fn(struct udev *udev,
|
_public_ void udev_set_log_fn(
|
||||||
void (*log_fn)(struct udev *udev,
|
struct udev *udev,
|
||||||
int priority, const char *file, int line, const char *fn,
|
void (*log_fn)(struct udev *udev,
|
||||||
const char *format, va_list args)) {
|
int priority, const char *file, int line, const char *fn,
|
||||||
|
const char *format, va_list args)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ const char *udev_device_get_action(struct udev_device *udev_device);
|
|||||||
unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
|
unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
|
||||||
unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device);
|
unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device);
|
||||||
const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
|
const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr);
|
||||||
int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value);
|
int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, const char *value);
|
||||||
int udev_device_has_tag(struct udev_device *udev_device, const char *tag);
|
int udev_device_has_tag(struct udev_device *udev_device, const char *tag);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -68,7 +68,7 @@ int sd_device_has_tag(sd_device *device, const char *tag);
|
|||||||
int sd_device_get_property_value(sd_device *device, const char *key, const char **value);
|
int sd_device_get_property_value(sd_device *device, const char *key, const char **value);
|
||||||
int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value);
|
int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value);
|
||||||
|
|
||||||
int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, char *value);
|
int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, const char *value);
|
||||||
|
|
||||||
/* device enumerator */
|
/* device enumerator */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user