diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-03-23 12:33:41 +0100 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-03-23 22:48:00 +0000 |
commit | b839101aacb38131f0f4313b1b76316e663e58e9 (patch) | |
tree | 0bd0c0442cddfb1dc8adcad384f269224c37f98c /src/portable | |
parent | 05bda20f073947b77423faca68ef360df5bfa464 (diff) | |
download | systemd-b839101aacb38131f0f4313b1b76316e663e58e9.tar.gz |
fileio: add new helper fdopen_independent()
This is a combination of fdopen() and fd_reopen(). i.e. it first reopens
the fd, and then converts that into a FILE*.
We do this at various places already manually. let's move this into a
helper call of its own.
Diffstat (limited to 'src/portable')
-rw-r--r-- | src/portable/portable.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/portable/portable.c b/src/portable/portable.c index 23102e51dd..664c873ca7 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -594,7 +594,6 @@ static int extract_image_and_extensions( _cleanup_(portable_metadata_unrefp) PortableMetadata *extension_release_meta = NULL; _cleanup_hashmap_free_ Hashmap *extra_unit_files = NULL; _cleanup_strv_free_ char **extension_release = NULL; - _cleanup_close_ int extension_release_fd = -EBADF; _cleanup_fclose_ FILE *f = NULL; const char *e; @@ -610,11 +609,7 @@ static int extract_image_and_extensions( continue; /* We need to keep the fd valid, to return the PortableMetadata to the caller. */ - extension_release_fd = fd_reopen(extension_release_meta->fd, O_CLOEXEC|O_RDONLY); - if (extension_release_fd < 0) - return extension_release_fd; - - r = take_fdopen_unlocked(&extension_release_fd, "r", &f); + r = fdopen_independent(extension_release_meta->fd, "re", &f); if (r < 0) return r; |