We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
renameat2
RENAME_EXCHANGE
renameat
std/os
swapDir
Solution: Fallback to current implementation iff MUSL or non-Linux.
#include <fcntl.h> #include <stdio.h> #include <sys/syscall.h> #include <unistd.h> /* MUSL Fallback */ #ifndef RENAME_EXCHANGE #define RENAME_EXCHANGE 2 #endif int main(int argc, char** argv) { /* MUSL Fallback */ if (syscall(SYS_renameat2, AT_FDCWD, argv[1], AT_FDCWD, argv[2], RENAME_EXCHANGE)) { perror(NULL); return 1; } else { return 0; } }
$ mkdir old $ mkdir new $ gcc -o moveit moveit.c $ ./moveit "old" "new"
You can use strace ./moveit "old" "new" or similar to see differences with rename API.
strace ./moveit "old" "new"
rename
/cc @timotheecour
The text was updated successfully, but these errors were encountered:
No branches or pull requests
renameat2
withRENAME_EXCHANGE
for Atomic IO.renameat2
is the same asrenameat
but allows additional arguments.RENAME_EXCHANGE
is a constant int flag forrenameat2
to atomically exchange an old path with a new path.std/os
only.swapDir
?.Cons
renameat2
andRENAME_EXCHANGE
is Linux only, but thats easy to detect in Nim.renameat2
norRENAME_EXCHANGE
, but thats easy to detect in Nim.Solution: Fallback to current implementation iff MUSL or non-Linux.
Links
Sample
You can use
strace ./moveit "old" "new"
or similar to see differences withrename
API./cc @timotheecour
The text was updated successfully, but these errors were encountered: