libposix: POSIX_rmdir
This commit is contained in:
parent
b57585fdf4
commit
a15c1111b8
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017-2018 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2017-2019 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
|
@ -324,6 +324,7 @@ extern int POSIX_pipe(int *errnop, int fildes[2]);
|
|||
extern int POSIX_umask(int *errnop, int mask);
|
||||
extern int POSIX_fcntl(int *errnop, int fd, PosixFDCmds cmd, uintptr_t arg);
|
||||
extern long POSIX_sysconf(int *errnop, PosixSysConfNames name);
|
||||
extern int POSIX_rmdir(int *errnop, const char *name);
|
||||
|
||||
extern int POSIX_sigaddset(int *errnop, PosixSignalMask *set, int signo);
|
||||
extern int POSIX_sigdelset(int *errnop, PosixSignalMask *set, int signo);
|
||||
|
|
|
@ -543,6 +543,35 @@ POSIX_unlink(int *errnop, const char *name)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
POSIX_rmdir(int *errnop, const char *name)
|
||||
{
|
||||
Dir *db;
|
||||
long ret;
|
||||
if(name == nil || name[0] == 0){
|
||||
*errnop = __libposix_get_errno(PosixENOENT);
|
||||
return -1;
|
||||
}
|
||||
ret = sys_remove(name);
|
||||
switch(ret){
|
||||
case 0:
|
||||
return 0;
|
||||
case ~0:
|
||||
db = nil;
|
||||
if((db=dirstat(name))!=nil && (db->qid.type&QTDIR)){
|
||||
*errnop = __libposix_translate_errstr((uintptr_t)POSIX_rmdir);
|
||||
} else {
|
||||
*errnop = __libposix_get_errno(PosixENOTDIR);
|
||||
}
|
||||
free(db);
|
||||
break;
|
||||
default:
|
||||
*errnop = ret;
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
POSIX_fstat(int *errnop, int file, void *pstat)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue