mirror of https://github.com/containers/podman.git
rootless: provide workaround for missing renameat2
on RHEL 7.7 renameat2 is not implemented for s390x, provide a workaround. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1768519 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
a114e9059a
commit
0a8dcd7112
|
@ -27,9 +27,13 @@ int renameat2 (int olddirfd, const char *oldpath, int newdirfd, const char *newp
|
||||||
# ifdef SYS_renameat2
|
# ifdef SYS_renameat2
|
||||||
return (int) syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
|
return (int) syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
|
||||||
# else
|
# else
|
||||||
/* no way to implement it atomically. */
|
/* This might be an issue if another process is trying to read the file while it is empty. */
|
||||||
errno = ENOSYS;
|
int fd = open (newpath, O_EXCL|O_CREAT, 0700);
|
||||||
return -1;
|
if (fd < 0)
|
||||||
|
return fd;
|
||||||
|
close (fd);
|
||||||
|
/* We are sure we created the file, let's overwrite it. */
|
||||||
|
return rename (oldpath, newpath);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue