mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 23:21:22 +03:00
fs-util: replace symlink_atomic() by symlinkat_atomic()
This commit is contained in:
parent
cc43328c7f
commit
da9dd029a2
@ -432,7 +432,7 @@ int symlink_idempotent(const char *from, const char *to, bool make_relative) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int symlink_atomic_full(const char *from, const char *to, bool make_relative) {
|
||||
int symlinkat_atomic_full(const char *from, int atfd, const char *to, bool make_relative) {
|
||||
_cleanup_free_ char *relpath = NULL, *t = NULL;
|
||||
int r;
|
||||
|
||||
@ -451,12 +451,13 @@ int symlink_atomic_full(const char *from, const char *to, bool make_relative) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (symlink(from, t) < 0)
|
||||
if (symlinkat(from, atfd, t) < 0)
|
||||
return -errno;
|
||||
|
||||
if (rename(t, to) < 0) {
|
||||
unlink_noerrno(t);
|
||||
return -errno;
|
||||
r = RET_NERRNO(renameat(atfd, t, atfd, to));
|
||||
if (r < 0) {
|
||||
(void) unlinkat(atfd, t, 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -58,9 +58,9 @@ static inline int touch(const char *path) {
|
||||
|
||||
int symlink_idempotent(const char *from, const char *to, bool make_relative);
|
||||
|
||||
int symlink_atomic_full(const char *from, const char *to, bool make_relative);
|
||||
int symlinkat_atomic_full(const char *from, int atfd, const char *to, bool make_relative);
|
||||
static inline int symlink_atomic(const char *from, const char *to) {
|
||||
return symlink_atomic_full(from, to, false);
|
||||
return symlinkat_atomic_full(from, AT_FDCWD, to, false);
|
||||
}
|
||||
int mknod_atomic(const char *path, mode_t mode, dev_t dev);
|
||||
int mkfifo_atomic(const char *path, mode_t mode);
|
||||
|
@ -71,7 +71,7 @@ int symlink_atomic_full_label(const char *from, const char *to, bool make_relati
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = symlink_atomic_full(from, to, make_relative);
|
||||
r = symlinkat_atomic_full(from, AT_FDCWD, to, make_relative);
|
||||
mac_selinux_create_file_clear();
|
||||
|
||||
if (r < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user