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:
committed by
Luca Boccassi
parent
23860b4975
commit
444af9538f
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user