blob: 942e301a4c035f491c6b0ffef47b8e1572312678 [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#include <stdio.h>
Rich Felker0b240cc2011-03-29 08:24:28 -04002#include <errno.h>
Rich Felkerdd5f50d2014-05-29 21:01:32 -04003#include <fcntl.h>
Rich Felker0b44a032011-02-12 00:22:29 -05004#include "syscall.h"
5
6int remove(const char *path)
7{
Rich Felkerdd5f50d2014-05-29 21:01:32 -04008#ifdef SYS_unlink
9 int r = __syscall(SYS_unlink, path);
10#else
11 int r = __syscall(SYS_unlinkat, AT_FDCWD, path, 0);
12#endif
13#ifdef SYS_rmdir
14 if (r==-EISDIR) r = __syscall(SYS_rmdir, path);
15#else
16 if (r==-EISDIR) r = __syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
17#endif
18 return __syscall_ret(r);
Rich Felker0b44a032011-02-12 00:22:29 -050019}