diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-19 18:40:23 +0100 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2014-12-20 10:58:19 -0500 |
commit | 1ebbd909119e41fe62ad680bad6199e0971e3402 (patch) | |
tree | b11f2f25c9cc584ebbca417853fe8b4a54516fde /src | |
parent | fcaebcecdb8428295bc9096f8f838304b588b56d (diff) |
util: when creating temporary filename for atomic creation of files, add an extra "#" to the name
That way, we have a simple, somewhat reliable way to detect such
temporary files, by simply checking if they start with ".#".
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/util.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index bd16abc8db..6790844536 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -1603,18 +1603,18 @@ int tempfn_xxxxxx(const char *p, char **ret) { * /foo/bar/waldo * * Into this: - * /foo/bar/.waldoXXXXXX + * /foo/bar/.#waldoXXXXXX */ fn = basename(p); if (!filename_is_valid(fn)) return -EINVAL; - t = new(char, strlen(p) + 1 + 6 + 1); + t = new(char, strlen(p) + 2 + 6 + 1); if (!t) return -ENOMEM; - strcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), "."), fn), "XXXXXX"); + strcpy(stpcpy(stpcpy(mempcpy(t, p, fn - p), ".#"), fn), "XXXXXX"); *ret = path_kill_slashes(t); return 0; |