X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fstdio%2Fremove.c;h=942e301a4c035f491c6b0ffef47b8e1572312678;hb=0847902ab99065a48f9bd3729b6e676288dfd69e;hp=fc12f7c10578d2f2f05bb2e7a6753dbe626e2ed7;hpb=0b240ccf523b9af23dd1efa78274f397fcc90cdd;p=musl diff --git a/src/stdio/remove.c b/src/stdio/remove.c index fc12f7c1..942e301a 100644 --- a/src/stdio/remove.c +++ b/src/stdio/remove.c @@ -1,9 +1,19 @@ #include #include +#include #include "syscall.h" int remove(const char *path) { - return (syscall(SYS_unlink, path) && errno == EISDIR) - ? syscall(SYS_rmdir, path) : 0; +#ifdef SYS_unlink + int r = __syscall(SYS_unlink, path); +#else + int r = __syscall(SYS_unlinkat, AT_FDCWD, path, 0); +#endif +#ifdef SYS_rmdir + if (r==-EISDIR) r = __syscall(SYS_rmdir, path); +#else + if (r==-EISDIR) r = __syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); +#endif + return __syscall_ret(r); }