summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-09-09 14:06:20 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-09-09 14:06:20 +0200
commitc4f5f942d7dd904e53374c10de319feb41968561 (patch)
tree19dafcf1564469b81743c3745e3f4905d8845181
parent9d7e1b3fdd3c2bd064f33a29ea5241fdefb718ee (diff)
add a bunch of private device properties to udev_device
-rw-r--r--udev/lib/exported_symbols3
-rw-r--r--udev/lib/libudev-device.c92
-rw-r--r--udev/lib/libudev-monitor.c7
-rw-r--r--udev/lib/libudev-private.h9
-rw-r--r--udev/lib/libudev.h4
5 files changed, 112 insertions, 3 deletions
diff --git a/udev/lib/exported_symbols b/udev/lib/exported_symbols
index fa12633377..7b42b28f9f 100644
--- a/udev/lib/exported_symbols
+++ b/udev/lib/exported_symbols
@@ -17,6 +17,9 @@ udev_device_get_devname
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
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c
index 43ed2f3dbf..bec0d69af3 100644
--- a/udev/lib/libudev-device.c
+++ b/udev/lib/libudev-device.c
@@ -41,6 +41,12 @@ struct udev_device {
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)
@@ -333,6 +339,27 @@ int udev_device_get_properties(struct udev_device *udev_device,
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)
@@ -370,3 +397,68 @@ int device_add_property(struct udev_device *udev_device, const char *property)
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;
+}
diff --git a/udev/lib/libudev-monitor.c b/udev/lib/libudev-monitor.c
index 2cba7caba0..5f63d2d401 100644
--- a/udev/lib/libudev-monitor.c
+++ b/udev/lib/libudev-monitor.c
@@ -88,6 +88,7 @@ struct udev_monitor *udev_monitor_new_from_socket(struct udev *udev, const char
free(udev_monitor);
return NULL;
}
+ info(udev, "monitor %p created with '%s'\n", udev_monitor, socket_path);
return udev_monitor;
}
@@ -96,7 +97,7 @@ int udev_monitor_enable_receiving(struct udev_monitor *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;
@@ -104,7 +105,7 @@ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor)
/* 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;
}
@@ -142,7 +143,7 @@ void udev_monitor_unref(struct udev_monitor *udev_monitor)
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);
}
diff --git a/udev/lib/libudev-private.h b/udev/lib/libudev-private.h
index b03c813c2f..d8bf981bb5 100644
--- a/udev/lib/libudev-private.h
+++ b/udev/lib/libudev-private.h
@@ -60,6 +60,15 @@ extern int device_set_subsystem(struct udev_device *udev_device, const char *sub
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;
diff --git a/udev/lib/libudev.h b/udev/lib/libudev.h
index a2a06b58e9..eafd578a55 100644
--- a/udev/lib/libudev.h
+++ b/udev/lib/libudev.h
@@ -21,6 +21,7 @@
#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
@@ -57,6 +58,9 @@ extern int udev_device_get_properties(struct udev_device *udev_device,
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,