diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-24 16:36:27 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-10-24 16:36:27 +0200 |
commit | c2654402790de8ba3e9f413ab1da0b18dd262317 (patch) | |
tree | cb5c6e6dedba744988ce870e5aa4cce7f0dff90e /udev/lib/libudev-monitor.c | |
parent | 3c67f7d2dfd1f6955552b9133107a5eb5bce824b (diff) |
libudev: monitor - cache result of monitor send buffer
Diffstat (limited to 'udev/lib/libudev-monitor.c')
-rw-r--r-- | udev/lib/libudev-monitor.c | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/udev/lib/libudev-monitor.c b/udev/lib/libudev-monitor.c index 9f13917042..f70bdb2d03 100644 --- a/udev/lib/libudev-monitor.c +++ b/udev/lib/libudev-monitor.c @@ -380,43 +380,15 @@ struct udev_device *udev_monitor_receive_device(struct udev_monitor *udev_monito int udev_monitor_send_device(struct udev_monitor *udev_monitor, struct udev_device *udev_device) { - const char *action; - struct udev_list_entry *list_entry; - char buf[4096]; - size_t bufpos; - size_t len; + const char *buf; + ssize_t len; ssize_t count; - action = udev_device_get_action(udev_device); - if (action == NULL) - return -EINVAL; - - bufpos = util_strlcpy(buf, action, sizeof(buf)); - len = util_strlcpy(&buf[bufpos], "@", sizeof(buf)-bufpos); - if (len >= sizeof(buf)-bufpos) + len = udev_device_get_properties_monitor_buf(udev_device, &buf); + if (len < 32) return -1; - bufpos += len; - len = util_strlcpy(&buf[bufpos], udev_device_get_devpath(udev_device), sizeof(buf)-bufpos); - if (len+1 >= sizeof(buf)-bufpos) - return -1; - bufpos += len+1; - udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) { - len = util_strlcpy(&buf[bufpos], udev_list_entry_get_name(list_entry), sizeof(buf)-bufpos); - if (len >= sizeof(buf)-bufpos) - return -1; - bufpos += len; - len = util_strlcpy(&buf[bufpos], "=", sizeof(buf)-bufpos); - if (len >= sizeof(buf)-bufpos) - return -1; - bufpos += len; - len = util_strlcpy(&buf[bufpos], udev_list_entry_get_value(list_entry), sizeof(buf)-bufpos); - if (len+1 >= sizeof(buf)-bufpos) - return -1; - bufpos += len+1; - } - count = sendto(udev_monitor->sock, - &buf, bufpos, 0, + buf, len, 0, (struct sockaddr *)&udev_monitor->sun, udev_monitor->addrlen); info(udev_monitor->udev, "passed %zi bytes to monitor %p, \n", count, udev_monitor); return count; |