remove.c 415 B

12345678910111213141516171819
  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <fcntl.h>
  4. #include "syscall.h"
  5. int remove(const char *path)
  6. {
  7. #ifdef SYS_unlink
  8. int r = __syscall(SYS_unlink, path);
  9. #else
  10. int r = __syscall(SYS_unlinkat, AT_FDCWD, path, 0);
  11. #endif
  12. #ifdef SYS_rmdir
  13. if (r==-EISDIR) r = __syscall(SYS_rmdir, path);
  14. #else
  15. if (r==-EISDIR) r = __syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
  16. #endif
  17. return __syscall_ret(r);
  18. }