rename.c 786 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * rename() for uClibc
  3. *
  4. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <stdio.h>
  10. #include <unistd.h>
  11. #if defined __NR_renameat && !defined __NR_rename
  12. # include <fcntl.h>
  13. int rename(const char *oldpath, const char *newpath)
  14. {
  15. return renameat(AT_FDCWD, oldpath, AT_FDCWD, newpath);
  16. }
  17. #elif defined __NR_renameat2
  18. # include <fcntl.h>
  19. int rename(const char *oldpath, const char *newpath)
  20. {
  21. _syscall5(int, renameat2, int, olddfd, const char *, oldpath,
  22. int, newdfd, const char *, newpath, int, flags)
  23. return renameat2(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0);
  24. }
  25. #else
  26. _syscall2(int, rename, const char *, oldpath, const char *, newpath)
  27. #endif