summaryrefslogtreecommitdiff
path: root/pkg/rootless
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-11-06 15:27:44 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-11-06 15:27:46 +0100
commit0a8dcd7112cdddadebc0af4795e77e3db69bbf26 (patch)
tree7feafc59a66fca5e6c0fbff9b932e0e8f1ef6aa6 /pkg/rootless
parenta114e9059a660ffab9f61f49d826b1809abd77b8 (diff)
downloadpodman-0a8dcd7112cdddadebc0af4795e77e3db69bbf26.tar.gz
podman-0a8dcd7112cdddadebc0af4795e77e3db69bbf26.tar.bz2
podman-0a8dcd7112cdddadebc0af4795e77e3db69bbf26.zip
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>
Diffstat (limited to 'pkg/rootless')
-rw-r--r--pkg/rootless/rootless_linux.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/rootless/rootless_linux.c b/pkg/rootless/rootless_linux.c
index a29ea0ce1..9604de638 100644
--- a/pkg/rootless/rootless_linux.c
+++ b/pkg/rootless/rootless_linux.c
@@ -27,9 +27,13 @@ int renameat2 (int olddirfd, const char *oldpath, int newdirfd, const char *newp
# ifdef SYS_renameat2
return (int) syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
# else
- /* no way to implement it atomically. */
- errno = ENOSYS;
- return -1;
+ /* This might be an issue if another process is trying to read the file while it is empty. */
+ int fd = open (newpath, O_EXCL|O_CREAT, 0700);
+ if (fd < 0)
+ return fd;
+ close (fd);
+ /* We are sure we created the file, let's overwrite it. */
+ return rename (oldpath, newpath);
# endif
}
#endif