Skip to content

Commit

Permalink
rootless: provide workaround for missing renameat2
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
giuseppe committed Nov 6, 2019
1 parent a114e90 commit 0a8dcd7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/rootless/rootless_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0a8dcd7

Please sign in to comment.