]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-journal: when enumerating, continue even after an inaccessible field
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 17 Jul 2020 19:00:12 +0000 (21:00 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 21 Jul 2020 15:42:11 +0000 (17:42 +0200)
commit76cbafcdd4451c27c058c4c8ada454caf0eb3ddc
tree774a8ffe33755a6cd78f3f2bbe0dc1a4d82ff0e2
parent7f16ef9fba3ba16c66452ca1d96c6c68cc8ebe3e
sd-journal: when enumerating, continue even after an inaccessible field

SD_JOURNAL_FOREACH_DATA() and SD_JOURNAL_FOREACH_UNIQUE() would immediately
terminate when a field couldn't be accessed. This can happen for example when a
field is compressed with an unavailable compression format. But it's likely
that this is the wrong thing to do: the caller for example might want to
iterate over the fields but isn't interested in all of them. coredumpctl is
like this: it uses SD_JOURNAL_FOREACH_DATA() but only uses a subset of the
fields.

Add two new functions sd_journal_enumerate_good_data() and
sd_journal_enumerate_good_unique() that retry sd_journal_enumerate_data() and
sd_journal_enumerate_unique() if the return value is something that applies to
a single field: ENOBUS, E2BIG, EOPNOTSUPP.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856037.

An alternative would be to make the macros themselves smarter instead of adding
new symbols, and do the looping internally in the macro. I don't like that
approach for two reasons. First, it would embed the logic in the macro, so
recompilation would be required if we decide to update the logic. With the
current version of the patch, recompilation is required to use the new symbols,
but after that, library upgrades are enough. So the current approach is safer
in case further updates are needed. Second, our headers use primitive C, and it
is hard to do the macros without using newer features.
src/journal/journal-internal.h
src/journal/sd-journal.c
src/libsystemd/libsystemd.sym
src/systemd/sd-journal.h