diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-12-16 11:29:52 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-12-17 18:26:15 +0100 |
commit | 5d1e57b820381700f50d5d1a0c1d6df0dc8b244a (patch) | |
tree | 475585c481abdf9f0a670b56a53503b7b3969455 /src/test | |
parent | memfd-util: introduce memfd_new_full() helper (diff) | |
download | systemd-5d1e57b820381700f50d5d1a0c1d6df0dc8b244a.tar.xz systemd-5d1e57b820381700f50d5d1a0c1d6df0dc8b244a.zip |
serialize: add explicit calls for finishing serialization
These new calls will do three things:
1. in case of FILE* stuff: flush any pending bytes onto the fd, just in
case
2. seal the backing memfd
3. seek back to the beginning.
Note that this adds sealing to serialization: once we serialized fully,
we'll seal the thing off for further modifications, before we pass the
fd over to the target process. This should add a bit of robustness, and
maybe finds a bug or two one day, if we accidentally write to a
serialization that is complete.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-fd-util.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/test/test-fd-util.c b/src/test/test-fd-util.c index a0d0bc731a..2ebc776f47 100644 --- a/src/test/test-fd-util.c +++ b/src/test/test-fd-util.c @@ -127,6 +127,8 @@ TEST(open_serialization_fd) { assert_se(fd >= 0); assert_se(write(fd, "test\n", 5) == 5); + + assert_se(finish_serialization_fd(fd) >= 0); } TEST(open_serialization_file) { @@ -138,6 +140,8 @@ TEST(open_serialization_file) { assert_se(f); assert_se(fwrite("test\n", 1, 5, f) == 5); + + assert_se(finish_serialization_file(f) >= 0); } TEST(fd_move_above_stdio) { |