summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-09-14 20:02:52 +0200
committerLennart Poettering <lennart@poettering.net>2012-09-14 20:02:52 +0200
commit424a19f8a2061c6b058283228734010b2fa24db4 (patch)
tree56b06b85c96832a319657006c660625d304c1df8 /src/shared/util.c
parent608da9e9b56be83ac394ea7a19cbdacab94f6642 (diff)
timedate: assorted improvements
- Make writing/reading of /etc/timezone dependendent of HAVE_SYSV_COMPAT - Introduce symlink_atomic() after all, and use it - Use relative symlink for /etc/localtime
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c58
1 files changed, 6 insertions, 52 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 6a40cf1d80..add3fdce53 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4644,49 +4644,9 @@ int copy_file(const char *from, const char *to) {
return 0;
}
-int symlink_or_copy(const char *from, const char *to) {
- char *pf = NULL, *pt = NULL;
- struct stat a, b;
- int r;
-
- assert(from);
- assert(to);
-
- if (path_get_parent(from, &pf) < 0 ||
- path_get_parent(to, &pt) < 0) {
- r = -ENOMEM;
- goto finish;
- }
-
- if (stat(pf, &a) < 0 ||
- stat(pt, &b) < 0) {
- r = -errno;
- goto finish;
- }
-
- if (a.st_dev != b.st_dev) {
- free(pf);
- free(pt);
-
- return copy_file(from, to);
- }
-
- if (symlink(from, to) < 0) {
- r = -errno;
- goto finish;
- }
-
- r = 0;
-
-finish:
- free(pf);
- free(pt);
-
- return r;
-}
-
-int symlink_or_copy_atomic(const char *from, const char *to) {
- char *t, *x;
+int symlink_atomic(const char *from, const char *to) {
+ char *x;
+ _cleanup_free_ char *t;
const char *fn;
size_t k;
unsigned long long ull;
@@ -4714,22 +4674,16 @@ int symlink_or_copy_atomic(const char *from, const char *to) {
*x = 0;
- r = symlink_or_copy(from, t);
- if (r < 0) {
- unlink(t);
- free(t);
- return r;
- }
+ if (symlink(from, t) < 0)
+ return -errno;
if (rename(t, to) < 0) {
r = -errno;
unlink(t);
- free(t);
return r;
}
- free(t);
- return r;
+ return 0;
}
bool display_is_local(const char *display) {