1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-11-01 00:51:08 +03:00

libudev: add userdata pointer

This commit is contained in:
Kay Sievers 2008-09-24 21:39:29 -07:00
parent 03198b9303
commit c8e32461cc
4 changed files with 30 additions and 2 deletions

2
TODO
View File

@ -2,6 +2,8 @@
o enumerate() - add buses and drivers
o increase ressize buffer
o add DVB variables to kernel, and drop shell script rule
o add watershed extra
o lazy init of selinux
o replace list.h with ccan list.h which is gpl-v2-or-later version
o get all distros to agree on a default set of rules

View File

@ -5,6 +5,8 @@ udev_log
udev_set_log_fn
udev_get_log_priority
udev_set_log_priority
udev_get_userdata
udev_set_userdata
udev_get_sys_path
udev_get_dev_path
udev_device_new_from_syspath

View File

@ -37,6 +37,7 @@ struct udev {
void (*log_fn)(struct udev *udev,
int priority, const char *file, int line, const char *fn,
const char *format, va_list args);
void *userdata;
char *sys_path;
char *dev_path;
char *rules_path;
@ -89,6 +90,20 @@ static void selinux_init(struct udev *udev)
#endif
}
void *udev_get_userdata(struct udev *udev)
{
if (udev == NULL)
return NULL;
return udev->userdata;
}
void udev_set_userdata(struct udev *udev, void *userdata)
{
if (udev == NULL)
return;
udev->userdata = userdata;
}
static void selinux_exit(struct udev *udev)
{
#ifdef USE_SELINUX

View File

@ -29,6 +29,10 @@
#endif
struct udev;
struct udev_device;
struct udev_monitor;
/* library context */
extern struct udev *udev_new(void);
extern struct udev *udev_ref(struct udev *udev);
extern void udev_unref(struct udev *udev);
@ -40,11 +44,15 @@ extern int udev_get_log_priority(struct udev *udev);
extern void udev_set_log_priority(struct udev *udev, int priority);
extern const char *udev_get_sys_path(struct udev *udev);
extern const char *udev_get_dev_path(struct udev *udev);
extern void *udev_get_userdata(struct udev *udev);
extern void udev_set_userdata(struct udev *udev, void *userdata);
/* selinux glue */
extern void udev_selinux_resetfscreatecon(struct udev *udev);
extern void udev_selinux_setfscreatecon(struct udev *udev, const char *file, unsigned int mode);
extern void udev_selinux_lsetfilecon(struct udev *udev, const char *file, unsigned int mode);
struct udev_device;
/* sys devices */
extern struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath);
extern struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum);
extern struct udev_device *udev_device_get_parent(struct udev_device *udev_device);
@ -70,11 +78,12 @@ extern const char *udev_device_get_action(struct udev_device *udev_device);
extern unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device);
extern const char *udev_device_get_attr_value(struct udev_device *udev_device, const char *attr);
/* sys enumeration */
extern int udev_enumerate_devices(struct udev *udev, const char *subsystem,
int (*cb)(struct udev_device *udev_device, void *data),
void *data);
struct udev_monitor;
/* udev and kernel device events */
extern struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char *socket_path);
extern struct udev_monitor *udev_monitor_new_from_netlink(struct udev *udev);
extern int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor);