[systemd-devel] [PATCH] util: fix strict aliasing violations in use of struct inotify_event v5
There is alot of cleanup that will have to happen to turn on -fstrict-aliasing, but I think our code should be correct to the rule. --- src/core/mount.c | 4 ++-- src/core/path.c | 4 ++-- src/journal/sd-journal.c | 4 ++-- src/shared/util.c| 5 ++--- src/shared/util.h| 10 -- src/udev/udevd.c | 4 ++-- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/core/mount.c b/src/core/mount.c index f8731bb..18ee2a0 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -1701,11 +1701,11 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, * internal behaviour of libmount here. */ for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +inotify_event_buffer_t buffer; struct inotify_event *e; ssize_t l; -l = read(fd, buffer, sizeof(buffer)); +l = read(fd, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) break; diff --git a/src/core/path.c b/src/core/path.c index 656ed69..bc34f66 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -157,7 +157,7 @@ void path_spec_unwatch(PathSpec *s) { } int path_spec_fd_event(PathSpec *s, uint32_t revents) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +inotify_event_buffer_t buffer; struct inotify_event *e; ssize_t l; int r = 0; @@ -167,7 +167,7 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) { return -EINVAL; } -l = read(s-inotify_fd, buffer, sizeof(buffer)); +l = read(s-inotify_fd, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return 0; diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index d46dc3c..5f65116 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2188,11 +2188,11 @@ _public_ int sd_journal_process(sd_journal *j) { j-last_process_usec = now(CLOCK_MONOTONIC); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +inotify_event_buffer_t buffer; struct inotify_event *e; ssize_t l; -l = read(j-inotify_fd, buffer, sizeof(buffer)); +l = read(j-inotify_fd, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return got_something ? determine_change(j) : SD_JOURNAL_NOP; diff --git a/src/shared/util.c b/src/shared/util.c index 06b6077..2fbcdab 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -39,7 +39,6 @@ #include linux/tiocl.h #include termios.h #include stdarg.h -#include sys/inotify.h #include sys/poll.h #include ctype.h #include sys/prctl.h @@ -2106,7 +2105,7 @@ int acquire_terminal( assert(notify = 0); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +inotify_event_buffer_t buffer; struct inotify_event *e; ssize_t l; @@ -2129,7 +2128,7 @@ int acquire_terminal( } } -l = read(notify, buffer, sizeof(buffer)); +l = read(notify, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EINTR || errno == EAGAIN) continue; diff --git a/src/shared/util.h b/src/shared/util.h index 1804b8c..e9af32a 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -42,6 +42,7 @@ #include locale.h #include mntent.h #include sys/socket.h +#include sys/inotify.h #if SIZEOF_PID_T == 4 # define PID_FMT % PRIu32 @@ -1047,8 +1048,13 @@ int sethostname_idempotent(const char *s); #define INOTIFY_EVENT_MAX (sizeof(struct inotify_event) + NAME_MAX + 1) #define FOREACH_INOTIFY_EVENT(e, buffer, sz) \ -for ((e) = (struct inotify_event*) (buffer);\ - (uint8_t*) (e) (uint8_t*) (buffer) + (sz); \ +for ((e) = (struct inotify_event*) (buffer.ev);\ + (uint8_t*) (e) (uint8_t*) (buffer.raw) + (sz); \ (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)-len)) +typedef union { +struct inotify_event ev; +uint8_t raw[INOTIFY_EVENT_MAX]; +} inotify_event_buffer_t; + #define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW) diff --git a/src/udev/udevd.c
[systemd-devel] [PATCH 1/2] libudev: fix strict aliasing violation
--- src/libudev/libudev-monitor.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index e8d6b4a..484fefe 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -582,7 +582,10 @@ _public_ struct udev_device *udev_monitor_receive_device(struct udev_monitor *ud struct cmsghdr *cmsg; union sockaddr_union snl; struct ucred *cred; -char buf[8192]; +union { +struct udev_monitor_netlink_header nlh; +char raw[8192]; +} buf; ssize_t buflen; ssize_t bufpos; @@ -642,29 +645,26 @@ retry: if (udev_device == NULL) return NULL; -if (memcmp(buf, libudev, 8) == 0) { -struct udev_monitor_netlink_header *nlh; - +if (memcmp(buf.raw, libudev, 8) == 0) { /* udev message needs proper version magic */ -nlh = (struct udev_monitor_netlink_header *) buf; -if (nlh-magic != htonl(UDEV_MONITOR_MAGIC)) { +if (buf.nlh.magic != htonl(UDEV_MONITOR_MAGIC)) { log_debug(unrecognized message signature (%x != %x), - nlh-magic, htonl(UDEV_MONITOR_MAGIC)); + buf.nlh.magic, htonl(UDEV_MONITOR_MAGIC)); udev_device_unref(udev_device); return NULL; } -if (nlh-properties_off+32 (size_t)buflen) { +if (buf.nlh.properties_off+32 (size_t)buflen) { udev_device_unref(udev_device); return NULL; } -bufpos = nlh-properties_off; +bufpos = buf.nlh.properties_off; /* devices received from udev are always initialized */ udev_device_set_is_initialized(udev_device); } else { /* kernel message with header */ -bufpos = strlen(buf) + 1; +bufpos = strlen(buf.raw) + 1; if ((size_t)bufpos sizeof(a@/d) || bufpos = buflen) { log_debug(invalid message length); udev_device_unref(udev_device); @@ -672,7 +672,7 @@ retry: } /* check message header */ -if (strstr(buf, @/) == NULL) { +if (strstr(buf.raw, @/) == NULL) { log_debug(unrecognized message header); udev_device_unref(udev_device); return NULL; @@ -685,7 +685,7 @@ retry: char *key; size_t keylen; -key = buf[bufpos]; +key = buf.raw[bufpos]; keylen = strlen(key); if (keylen == 0) break; -- 2.1.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH 2/2] udev: fix another strict aliasing issue
--- src/udev/ata_id/ata_id.c | 62 +++- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/udev/ata_id/ata_id.c b/src/udev/ata_id/ata_id.c index 89628c9..fc13819 100644 --- a/src/udev/ata_id/ata_id.c +++ b/src/udev/ata_id/ata_id.c @@ -409,7 +409,11 @@ int main(int argc, char *argv[]) { struct udev *udev; struct hd_driveid id; -uint8_t identify[512]; +union { +uint8_t byte[512]; +uint16_t wyde[256]; +uint64_t octa[64]; +} identify; uint16_t *identify_words; char model[41]; char model_enc[256]; @@ -467,30 +471,30 @@ int main(int argc, char *argv[]) goto exit; } -if (disk_identify(udev, fd, identify, is_packet_device) == 0) { +if (disk_identify(udev, fd, identify.byte, is_packet_device) == 0) { /* * fix up only the fields from the IDENTIFY data that we are going to * use and copy it into the hd_driveid struct for convenience */ -disk_identify_fixup_string(identify, 10, 20); /* serial */ -disk_identify_fixup_string(identify, 23, 8); /* fwrev */ -disk_identify_fixup_string(identify, 27, 40); /* model */ -disk_identify_fixup_uint16(identify, 0); /* configuration */ -disk_identify_fixup_uint16(identify, 75); /* queue depth */ -disk_identify_fixup_uint16(identify, 75); /* SATA capabilities */ -disk_identify_fixup_uint16(identify, 82); /* command set supported */ -disk_identify_fixup_uint16(identify, 83); /* command set supported */ -disk_identify_fixup_uint16(identify, 84); /* command set supported */ -disk_identify_fixup_uint16(identify, 85); /* command set supported */ -disk_identify_fixup_uint16(identify, 86); /* command set supported */ -disk_identify_fixup_uint16(identify, 87); /* command set supported */ -disk_identify_fixup_uint16(identify, 89); /* time required for SECURITY ERASE UNIT */ -disk_identify_fixup_uint16(identify, 90); /* time required for enhanced SECURITY ERASE UNIT */ -disk_identify_fixup_uint16(identify, 91); /* current APM values */ -disk_identify_fixup_uint16(identify, 94); /* current AAM value */ -disk_identify_fixup_uint16(identify, 128); /* device lock function */ -disk_identify_fixup_uint16(identify, 217); /* nominal media rotation rate */ -memcpy(id, identify, sizeof id); +disk_identify_fixup_string(identify.byte, 10, 20); /* serial */ +disk_identify_fixup_string(identify.byte, 23, 8); /* fwrev */ +disk_identify_fixup_string(identify.byte, 27, 40); /* model */ +disk_identify_fixup_uint16(identify.byte, 0); /* configuration */ +disk_identify_fixup_uint16(identify.byte, 75); /* queue depth */ +disk_identify_fixup_uint16(identify.byte, 75); /* SATA capabilities */ +disk_identify_fixup_uint16(identify.byte, 82); /* command set supported */ +disk_identify_fixup_uint16(identify.byte, 83); /* command set supported */ +disk_identify_fixup_uint16(identify.byte, 84); /* command set supported */ +disk_identify_fixup_uint16(identify.byte, 85); /* command set supported */ +disk_identify_fixup_uint16(identify.byte, 86); /* command set supported */ +disk_identify_fixup_uint16(identify.byte, 87); /* command set supported */ +disk_identify_fixup_uint16(identify.byte, 89); /* time required for SECURITY ERASE UNIT */ +disk_identify_fixup_uint16(identify.byte, 90); /* time required for enhanced SECURITY ERASE UNIT */ +disk_identify_fixup_uint16(identify.byte, 91); /* current APM values */ +disk_identify_fixup_uint16(identify.byte, 94); /* current AAM value */ +disk_identify_fixup_uint16(identify.byte, 128); /* device lock function */ +disk_identify_fixup_uint16(identify.byte, 217); /* nominal media rotation rate */ +memcpy(id, identify.byte, sizeof id); } else { /* If this fails, then try HDIO_GET_IDENTITY */ if (ioctl(fd, HDIO_GET_IDENTITY, id) != 0) { @@ -499,7 +503,7 @@ int main(int argc, char *argv[]) goto close; } } -identify_words = (uint16_t *) identify; +identify_words = identify.wyde; memcpy (model,
[systemd-devel] [PATCH] util: fix strict aliasing violations in use of struct inotify_event
There is alot of cleanup that will have to happen to turn on -fstrict-aliasing, but I think our code should be correct to the rule. --- src/journal/sd-journal.c | 9 ++--- src/shared/util.c| 9 ++--- src/udev/udevd.c | 9 ++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index d46dc3c..fb4cd85 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2188,11 +2188,14 @@ _public_ int sd_journal_process(sd_journal *j) { j-last_process_usec = now(CLOCK_MONOTONIC); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +union { +struct inotify_event ev; +uint8_t raw[INOTIFY_EVENT_MAX]; +} buffer; struct inotify_event *e; ssize_t l; -l = read(j-inotify_fd, buffer, sizeof(buffer)); +l = read(j-inotify_fd, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return got_something ? determine_change(j) : SD_JOURNAL_NOP; @@ -2202,7 +2205,7 @@ _public_ int sd_journal_process(sd_journal *j) { got_something = true; -FOREACH_INOTIFY_EVENT(e, buffer, l) +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) process_inotify_event(j, e); } } diff --git a/src/shared/util.c b/src/shared/util.c index 06b6077..13f6f52 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -2106,7 +2106,10 @@ int acquire_terminal( assert(notify = 0); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +union { +struct inotify_event ev; +uint8_t raw[INOTIFY_EVENT_MAX]; +} buffer; struct inotify_event *e; ssize_t l; @@ -2129,7 +2132,7 @@ int acquire_terminal( } } -l = read(notify, buffer, sizeof(buffer)); +l = read(notify, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EINTR || errno == EAGAIN) continue; @@ -2138,7 +2141,7 @@ int acquire_terminal( goto fail; } -FOREACH_INOTIFY_EVENT(e, buffer, l) { +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) { if (e-wd != wd || !(e-mask IN_CLOSE)) { r = -EIO; goto fail; diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 8bec03e..98ddd67 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -816,11 +816,14 @@ static int synthesize_change(struct udev_device *dev) { } static int handle_inotify(struct udev *udev) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +union { +struct inotify_event ev; +uint8_t raw[INOTIFY_EVENT_MAX]; +} buffer; struct inotify_event *e; ssize_t l; -l = read(fd_inotify, buffer, sizeof(buffer)); +l = read(fd_inotify, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return 0; @@ -828,7 +831,7 @@ static int handle_inotify(struct udev *udev) { return log_error_errno(errno, Failed to read inotify fd: %m); } -FOREACH_INOTIFY_EVENT(e, buffer, l) { +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) { struct udev_device *dev; dev = udev_watch_lookup(udev, e-wd); -- 2.1.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] util: fix strict aliasing violations in use of struct inotify_event v2
There is alot of cleanup that will have to happen to turn on -fstrict-aliasing, but I think our code should be correct to the rule. v2: move union def to header file --- src/journal/sd-journal.c | 6 +++--- src/shared/util.c| 6 +++--- src/shared/util.h| 5 + src/udev/udevd.c | 6 +++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index d46dc3c..3a79baf 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2188,11 +2188,11 @@ _public_ int sd_journal_process(sd_journal *j) { j-last_process_usec = now(CLOCK_MONOTONIC); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +union inotify_event_buffer buffer; struct inotify_event *e; ssize_t l; -l = read(j-inotify_fd, buffer, sizeof(buffer)); +l = read(j-inotify_fd, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return got_something ? determine_change(j) : SD_JOURNAL_NOP; @@ -2202,7 +2202,7 @@ _public_ int sd_journal_process(sd_journal *j) { got_something = true; -FOREACH_INOTIFY_EVENT(e, buffer, l) +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) process_inotify_event(j, e); } } diff --git a/src/shared/util.c b/src/shared/util.c index 06b6077..0101531 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -2106,7 +2106,7 @@ int acquire_terminal( assert(notify = 0); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +union inotify_event_buffer buffer; struct inotify_event *e; ssize_t l; @@ -2129,7 +2129,7 @@ int acquire_terminal( } } -l = read(notify, buffer, sizeof(buffer)); +l = read(notify, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EINTR || errno == EAGAIN) continue; @@ -2138,7 +2138,7 @@ int acquire_terminal( goto fail; } -FOREACH_INOTIFY_EVENT(e, buffer, l) { +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) { if (e-wd != wd || !(e-mask IN_CLOSE)) { r = -EIO; goto fail; diff --git a/src/shared/util.h b/src/shared/util.h index 1804b8c..1f38433 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -1051,4 +1051,9 @@ int sethostname_idempotent(const char *s); (uint8_t*) (e) (uint8_t*) (buffer) + (sz); \ (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)-len)) +union inotify_event_buffer { +struct inotify_event ev; +uint8_t raw[INOTIFY_EVENT_MAX]; +}; + #define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW) diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 8bec03e..2627f9a 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -816,11 +816,11 @@ static int synthesize_change(struct udev_device *dev) { } static int handle_inotify(struct udev *udev) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +union inotify_event_buffer buffer; struct inotify_event *e; ssize_t l; -l = read(fd_inotify, buffer, sizeof(buffer)); +l = read(fd_inotify, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return 0; @@ -828,7 +828,7 @@ static int handle_inotify(struct udev *udev) { return log_error_errno(errno, Failed to read inotify fd: %m); } -FOREACH_INOTIFY_EVENT(e, buffer, l) { +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) { struct udev_device *dev; dev = udev_watch_lookup(udev, e-wd); -- 2.1.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] gitignore: add another test
--- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1b5d60f..00a46a5 100644 --- a/.gitignore +++ b/.gitignore @@ -206,6 +206,7 @@ /test-libudev /test-libudev-sym* /test-list +/test-lldp /test-unaligned /test-locale-util /test-local-addresses -- 2.1.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] util: fix strict aliasing violations in use of struct inotify_event v3
There is alot of cleanup that will have to happen to turn on -fstrict-aliasing, but I think our code should be correct to the rule. v2: move union def to header file v3: fix syntax --- src/journal/sd-journal.c | 6 +++--- src/shared/util.c| 7 +++ src/shared/util.h| 6 ++ src/udev/udevd.c | 6 +++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index d46dc3c..83be4c9 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -2188,11 +2188,11 @@ _public_ int sd_journal_process(sd_journal *j) { j-last_process_usec = now(CLOCK_MONOTONIC); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +inotify_event_buffer_t buffer; struct inotify_event *e; ssize_t l; -l = read(j-inotify_fd, buffer, sizeof(buffer)); +l = read(j-inotify_fd, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return got_something ? determine_change(j) : SD_JOURNAL_NOP; @@ -2202,7 +2202,7 @@ _public_ int sd_journal_process(sd_journal *j) { got_something = true; -FOREACH_INOTIFY_EVENT(e, buffer, l) +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) process_inotify_event(j, e); } } diff --git a/src/shared/util.c b/src/shared/util.c index 06b6077..fc83da9 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -39,7 +39,6 @@ #include linux/tiocl.h #include termios.h #include stdarg.h -#include sys/inotify.h #include sys/poll.h #include ctype.h #include sys/prctl.h @@ -2106,7 +2105,7 @@ int acquire_terminal( assert(notify = 0); for (;;) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +inotify_event_buffer_t buffer; struct inotify_event *e; ssize_t l; @@ -2129,7 +2128,7 @@ int acquire_terminal( } } -l = read(notify, buffer, sizeof(buffer)); +l = read(notify, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EINTR || errno == EAGAIN) continue; @@ -2138,7 +2137,7 @@ int acquire_terminal( goto fail; } -FOREACH_INOTIFY_EVENT(e, buffer, l) { +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) { if (e-wd != wd || !(e-mask IN_CLOSE)) { r = -EIO; goto fail; diff --git a/src/shared/util.h b/src/shared/util.h index 1804b8c..b97d8af 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -42,6 +42,7 @@ #include locale.h #include mntent.h #include sys/socket.h +#include sys/inotify.h #if SIZEOF_PID_T == 4 # define PID_FMT % PRIu32 @@ -1051,4 +1052,9 @@ int sethostname_idempotent(const char *s); (uint8_t*) (e) (uint8_t*) (buffer) + (sz); \ (e) = (struct inotify_event*) ((uint8_t*) (e) + sizeof(struct inotify_event) + (e)-len)) +typedef union { +struct inotify_event ev; +uint8_t raw[INOTIFY_EVENT_MAX]; +} inotify_event_buffer_t; + #define laccess(path, mode) faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW) diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 8bec03e..bd13025 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -816,11 +816,11 @@ static int synthesize_change(struct udev_device *dev) { } static int handle_inotify(struct udev *udev) { -uint8_t buffer[INOTIFY_EVENT_MAX] _alignas_(struct inotify_event); +inotify_event_buffer_t buffer; struct inotify_event *e; ssize_t l; -l = read(fd_inotify, buffer, sizeof(buffer)); +l = read(fd_inotify, buffer.raw, sizeof(buffer.raw)); if (l 0) { if (errno == EAGAIN || errno == EINTR) return 0; @@ -828,7 +828,7 @@ static int handle_inotify(struct udev *udev) { return log_error_errno(errno, Failed to read inotify fd: %m); } -FOREACH_INOTIFY_EVENT(e, buffer, l) { +FOREACH_INOTIFY_EVENT(e, buffer.ev, l) { struct udev_device *dev; dev = udev_watch_lookup(udev, e-wd); -- 2.1.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] timedated: support split usr
The current Debian solution to this is really ugly, and I would rather have them use the correct patch even if split usr is dumb. Read: http://rusty.ozlabs.org/?p=236 (Why Everyone Must Oppose The Merging of /usr and /) (I managed to skip the pulseaudio implamentation mess because I had a fancy emu10k1 SoundBlaster Live! 5.1 which does its own hardware mixing.) --- src/timedate/timedated.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index bf567a1..985864a 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -123,9 +123,20 @@ static int context_write_data_timezone(Context *c) { if (!p) return log_oom(); +#ifdef HAVE_SPLIT_USR +r = write_one_line_file_atomic(/etc/timezone, c-zone); +if (r 0) +return r; + + /* /usr/sha... */ +r = copy_file((p + 2), /etc/localtime); +if (r 0) +return r; +#else r = symlink_atomic(p, /etc/localtime); if (r 0) return r; +#endif return 0; } -- 2.1.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] timedated: support split usr v2
The current Debian solution to this is really ugly, and I would rather have them use the correct patch even if split usr is dumb. Read: http://rusty.ozlabs.org/?p=236 (Why Everyone Must Oppose The Merging of /usr and /) (I managed to skip the pulseaudio implamentation mess because I had a fancy emu10k1 SoundBlaster Live! 5.1 which does its own hardware mixing.) v2: forgot to commit my debugging results before submitting --- src/timedate/timedated.c | 13 + 1 file changed, 13 insertions(+) diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index bf567a1..a2fd781 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -30,6 +30,7 @@ #include sd-bus.h #include util.h +#include copy.h #include strv.h #include def.h #include clock-util.h @@ -123,9 +124,21 @@ static int context_write_data_timezone(Context *c) { if (!p) return log_oom(); +#ifdef HAVE_SPLIT_USR +r = write_string_file_atomic(/etc/timezone, c-zone); +if (r 0) +return r; + + /* /usr/sha... */ +r = copy_file((p + 2), /etc/localtime, O_TRUNC, +S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); /*644*/ +if (r 0) +return r; +#else r = symlink_atomic(p, /etc/localtime); if (r 0) return r; +#endif return 0; } -- 2.1.0 ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel