SHA256
1
0
forked from pool/systemd
systemd/1026-udevd-inotify-modernizations.patch
Robert Milasan 3595bbe8f8 Accepting request 236618 from home:rmilasan:branches:Base:System
- Add upstream patches
  1025-udev-exclude-device-mapper-from-block-device-ownersh.patch
  1026-udevd-inotify-modernizations.patch
  1027-udev-synthesize-change-events-for-partitions-when-to.patch
  1028-udev-link-config-fix-mem-leak.patch
  1029-udev-try-first-re-reading-the-partition-table.patch
  1030-udev-guard-REREADP-logic-with-open-O_ECXL.patch
  1031-udev-make-sure-we-always-get-change-for-the-disk.patch
  1032-udev-guard-REREADPT-by-exclusive-lock-instead-of-O_E.patch 

- Add upstream patches
  1025-udev-exclude-device-mapper-from-block-device-ownersh.patch
  1026-udevd-inotify-modernizations.patch
  1027-udev-synthesize-change-events-for-partitions-when-to.patch
  1028-udev-link-config-fix-mem-leak.patch
  1029-udev-try-first-re-reading-the-partition-table.patch
  1030-udev-guard-REREADP-logic-with-open-O_ECXL.patch
  1031-udev-make-sure-we-always-get-change-for-the-disk.patch
  1032-udev-guard-REREADPT-by-exclusive-lock-instead-of-O_E.patch

OBS-URL: https://build.opensuse.org/request/show/236618
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=662
2014-06-09 08:41:53 +00:00

86 lines
3.3 KiB
Diff

From edd32000c806e4527c5f376d138f7bff07724c26 Mon Sep 17 00:00:00 2001
From: Kay Sievers <kay@vrfy.org>
Date: Wed, 4 Jun 2014 11:05:45 +0200
Subject: [PATCH] udevd: inotify - modernizations
Signed-off-by: Robert Milasan <rmilasan@suse.com>
---
src/udev/udevd.c | 45 ++++++++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 23 deletions(-)
Index: systemd-210/src/udev/udevd.c
===================================================================
--- systemd-210.orig/src/udev/udevd.c
+++ systemd-210/src/udev/udevd.c
@@ -736,20 +736,30 @@ out:
return udev_ctrl_connection_unref(ctrl_conn);
}
+static void synthesize_change(struct udev_device *dev) {
+ char filename[UTIL_PATH_SIZE];
+
+ log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev));
+ strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
+ write_string_file(filename, "change");
+}
+
/* read inotify messages */
static int handle_inotify(struct udev *udev)
{
int nbytes, pos;
char *buf;
struct inotify_event *ev;
+ int r;
- if ((ioctl(fd_inotify, FIONREAD, &nbytes) < 0) || (nbytes <= 0))
- return 0;
+ r = ioctl(fd_inotify, FIONREAD, &nbytes);
+ if (r < 0 || nbytes <= 0)
+ return -errno;
buf = malloc(nbytes);
- if (buf == NULL) {
+ if (!buf) {
log_error("error getting buffer for inotify");
- return -1;
+ return -ENOMEM;
}
nbytes = read(fd_inotify, buf, nbytes);
@@ -759,27 +769,16 @@ static int handle_inotify(struct udev *u
ev = (struct inotify_event *)(buf + pos);
dev = udev_watch_lookup(udev, ev->wd);
- if (dev != NULL) {
- log_debug("inotify event: %x for %s", ev->mask, udev_device_get_devnode(dev));
- if (ev->mask & IN_CLOSE_WRITE) {
- char filename[UTIL_PATH_SIZE];
- int fd;
-
- log_debug("device %s closed, synthesising 'change'", udev_device_get_devnode(dev));
- strscpyl(filename, sizeof(filename), udev_device_get_syspath(dev), "/uevent", NULL);
- fd = open(filename, O_WRONLY|O_CLOEXEC);
- if (fd >= 0) {
- if (write(fd, "change", 6) < 0)
- log_debug("error writing uevent: %m");
- close(fd);
- }
- }
- if (ev->mask & IN_IGNORED)
- udev_watch_end(udev, dev);
+ if (!dev)
+ continue;
- udev_device_unref(dev);
- }
+ log_debug("inotify event: %x for %s", ev->mask, udev_device_get_devnode(dev));
+ if (ev->mask & IN_CLOSE_WRITE)
+ synthesize_change(dev);
+ else if (ev->mask & IN_IGNORED)
+ udev_watch_end(udev, dev);
+ udev_device_unref(dev);
}
free(buf);