util: when creating temporary file names, allow including extra id string in it

This adds a "char *extra" parameter to tempfn_xxxxxx(), tempfn_random(),
tempfn_ranomd_child(). If non-NULL this string is included in the middle
of the newly created file name. This is useful for being able to
distuingish the kind of temporary file when we see one.

This also adds tests for the three call.

For now, we don't make use of this at all, but port all users over.
This commit is contained in:
Lennart Poettering
2015-06-15 19:28:55 +02:00
parent a4c8a59951
commit 14bcf25c8b
15 changed files with 83 additions and 37 deletions
+1 -1
View File
@@ -396,7 +396,7 @@ int copy_file_atomic(const char *from, const char *to, mode_t mode, bool replace
assert(from);
assert(to);
r = tempfn_random(to, &t);
r = tempfn_random(to, NULL, &t);
if (r < 0)
return r;