udev_device_get_subsystem
udev_device_get_devlinks
udev_device_get_properties
+udev_device_get_action
+udev_device_get_driver
+udev_device_get_devnum
udev_devices_enumerate
udev_monitor_new_from_socket
udev_monitor_enable_receiving
char *subsystem;
struct list_head link_list;
struct list_head env_list;
+ char *action;
+ char *driver;
+ char *devpath_old;
+ char *physdevpath;
+ int timeout;
+ dev_t devnum;
};
struct udev_device *device_init(struct udev *udev)
return count;
}
+const char *udev_device_get_driver(struct udev_device *udev_device)
+{
+ if (udev_device == NULL)
+ return NULL;
+ return udev_device->driver;
+}
+
+dev_t udev_device_get_devnum(struct udev_device *udev_device)
+{
+ if (udev_device == NULL)
+ return makedev(0, 0);
+ return udev_device->devnum;
+}
+
+const char *udev_device_get_action(struct udev_device *udev_device)
+{
+ if (udev_device == NULL)
+ return NULL;
+ return udev_device->action;
+}
+
int device_set_devpath(struct udev_device *udev_device, const char *devpath)
{
if (asprintf(&udev_device->syspath, "%s%s", udev_get_sys_path(udev_device->udev), devpath) < 0)
return -ENOMEM;
return 0;
}
+
+int device_set_action(struct udev_device *udev_device, const char *action)
+{
+ udev_device->action = strdup(action);
+ if (udev_device->action == NULL)
+ return -ENOMEM;
+ return 0;
+}
+
+int device_set_driver(struct udev_device *udev_device, const char *driver)
+{
+ udev_device->driver = strdup(driver);
+ if (udev_device->driver == NULL)
+ return -ENOMEM;
+ return 0;
+}
+
+const char *device_get_devpath_old(struct udev_device *udev_device)
+{
+ if (udev_device == NULL)
+ return NULL;
+ return udev_device->devpath_old;
+}
+
+int device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old)
+{
+ udev_device->devpath_old = strdup(devpath_old);
+ if (udev_device->devpath_old == NULL)
+ return -ENOMEM;
+ return 0;
+}
+
+const char *device_get_physdevpath(struct udev_device *udev_device)
+{
+ if (udev_device == NULL)
+ return NULL;
+ return udev_device->physdevpath;
+}
+
+int device_set_physdevpath(struct udev_device *udev_device, const char *physdevpath)
+{
+ udev_device->physdevpath = strdup(physdevpath);
+ if (udev_device->physdevpath == NULL)
+ return -ENOMEM;
+ return 0;
+}
+
+int device_get_timeout(struct udev_device *udev_device)
+{
+ if (udev_device == NULL)
+ return -1;
+ return udev_device->timeout;
+}
+
+int device_set_timeout(struct udev_device *udev_device, int timeout)
+{
+ udev_device->timeout = timeout;
+ return 0;
+}
+
+int device_set_devnum(struct udev_device *udev_device, dev_t devnum)
+{
+ udev_device->devnum = devnum;
+ return 0;
+}
free(udev_monitor);
return NULL;
}
+ info(udev, "monitor %p created with '%s'\n", udev_monitor, socket_path);
return udev_monitor;
}
int err;
const int on = 1;
- err = bind(udev_monitor->sock, (struct sockaddr *) &udev_monitor->saddr, udev_monitor->addrlen);
+ err = bind(udev_monitor->sock, (struct sockaddr *)&udev_monitor->saddr, udev_monitor->addrlen);
if (err < 0) {
err(udev_monitor->udev, "bind failed: %s\n", strerror(errno));
return err;
/* enable receiving of the sender credentials */
setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
- info(udev_monitor->udev, "udev_monitor: %p created\n", udev_monitor);
+ info(udev_monitor->udev, "monitor %p listening\n", udev_monitor);
return 0;
}
return;
if (udev_monitor->sock >= 0)
close(udev_monitor->sock);
- info(udev_monitor->udev, "udev_monitor: %p released\n", udev_monitor);
+ info(udev_monitor->udev, "monitor %p released\n", udev_monitor);
free(udev_monitor);
}
extern int device_set_devname(struct udev_device *udev_device, const char *devname);
extern int device_add_devlink(struct udev_device *udev_device, const char *devlink);
extern int device_add_property(struct udev_device *udev_device, const char *property);
+extern int device_set_action(struct udev_device *udev_device, const char *action);
+extern int device_set_driver(struct udev_device *udev_device, const char *driver);
+extern const char *device_get_devpath_old(struct udev_device *udev_device);
+extern int device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old);
+extern const char *device_get_physdevpath(struct udev_device *udev_device);
+extern int device_set_physdevpath(struct udev_device *udev_device, const char *physdevpath);
+extern int device_get_timeout(struct udev_device *udev_device);
+extern int device_set_timeout(struct udev_device *udev_device, int timeout);
+extern int device_set_devnum(struct udev_device *udev_device, dev_t devnum);
/* udev_ctrl - daemon runtime setup */
struct udev_ctrl;
#define _LIBUDEV_H_
#include <stdarg.h>
+#include <sys/stat.h>
/* this will stay as long as the DeviceKit integration of udev is work in progress */
#if !defined _LIBUDEV_COMPILATION && !defined LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
int (*cb)(struct udev_device *udev_device,
const char *key, const char *value, void *data),
void *data);
+extern const char *udev_device_get_driver(struct udev_device *udev_device);
+extern dev_t udev_device_get_devnum(struct udev_device *udev_device);
+extern const char *udev_device_get_action(struct udev_device *udev_device);
extern int udev_devices_enumerate(struct udev *udev, const char *subsystem,
int (*cb)(struct udev *udev,