tmpfile-util: introduce new CLEANUP_TMPFILE_AT() API

This should allow us to get rid of a bunch of "fail:" labels, because we
can clean up tmpfiles relative to some atfd this way.

This only ports over a small number of potential users, but there's more
work to be done.
This commit is contained in:
Lennart Poettering
2025-09-17 19:51:13 +01:00
committed by Luca Boccassi
parent 23860b4975
commit 444af9538f
5 changed files with 55 additions and 44 deletions
+14
View File
@@ -436,3 +436,17 @@ int mkdtemp_open(const char *template, int flags, char **ret) {
return fd;
}
void cleanup_tmpfile_data_done(struct cleanup_tmpfile_data *d) {
assert(d);
if (!d->dir_fd ||
*d->dir_fd < 0 ||
!d->filename ||
!*d->filename)
return;
(void) unlinkat(*d->dir_fd, *d->filename, 0);
d->dir_fd = NULL;
d->filename = NULL;
}