Skip to content

Instantly share code, notes, and snippets.

@alban
Created March 10, 2015 11:21
Show Gist options
  • Save alban/8aac83d4acb2cc9e022a to your computer and use it in GitHub Desktop.
Save alban/8aac83d4acb2cc9e022a to your computer and use it in GitHub Desktop.
rename.c
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <unistd.h>
#include <sys/syscall.h> /* For SYS_xxx definitions */
#include <stdio.h>
#include <fcntl.h> /* Definition of AT_* constants */
#include <stdio.h>
int main()
{
//renameat2(AT_FDCWD, "/tmp/aaa", AT_FDCWD, "/tmp/bbb", 1);
#define RENAME_NOREPLACE (1 << 0)
#define __NR_renameat2 316
return syscall(__NR_renameat2, AT_FDCWD, "/home/alban/debian-tree/var/lib/machines/a", AT_FDCWD, "/home/alban/debian-tree/var/lib/machines/b", RENAME_NOREPLACE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment