userspace/libc: implement close() & dirfd()

Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
EnderIce2 2025-01-27 23:58:54 +02:00
parent c2412fe710
commit 48067d8f58
No known key found for this signature in database
GPG Key ID: 2EE20AF089811A5A
4 changed files with 14 additions and 4 deletions

View File

@ -60,7 +60,7 @@ extern "C"
int alphasort(const struct dirent **, const struct dirent **); int alphasort(const struct dirent **, const struct dirent **);
int closedir(DIR *dirp); int closedir(DIR *dirp);
int dirfd(DIR *); int dirfd(DIR *dirp);
DIR *fdopendir(int); DIR *fdopendir(int);
DIR *opendir(const char *); DIR *opendir(const char *);
ssize_t posix_getdents(int, void *, size_t, int); ssize_t posix_getdents(int, void *, size_t, int);

View File

@ -65,7 +65,7 @@ extern "C"
int chdir(const char *); int chdir(const char *);
int chroot(const char *); int chroot(const char *);
int chown(const char *, uid_t, gid_t); int chown(const char *, uid_t, gid_t);
int close(int); int close(int fildes);
size_t confstr(int, char *, size_t); size_t confstr(int, char *, size_t);
char *crypt(const char *, const char *); char *crypt(const char *, const char *);
char *ctermid(char *); char *ctermid(char *);

View File

@ -45,7 +45,12 @@ export int closedir(DIR *dirp)
return 0; return 0;
} }
export int dirfd(DIR *); export int dirfd(DIR *dirp)
{
printf("dirfd() is unimplemented\n");
return __check_errno(-ENOSYS, -1);
}
export DIR *fdopendir(int); export DIR *fdopendir(int);
export DIR *opendir(const char *); export DIR *opendir(const char *);
export ssize_t posix_getdents(int, void *, size_t, int); export ssize_t posix_getdents(int, void *, size_t, int);

View File

@ -40,7 +40,12 @@ export int brk(void *);
export int chdir(const char *); export int chdir(const char *);
export int chroot(const char *); export int chroot(const char *);
export int chown(const char *, uid_t, gid_t); export int chown(const char *, uid_t, gid_t);
export int close(int);
export int close(int fildes)
{
return __check_errno(call_close(fildes), -1);
}
export size_t confstr(int, char *, size_t); export size_t confstr(int, char *, size_t);
export char *crypt(const char *, const char *); export char *crypt(const char *, const char *);
export char *ctermid(char *); export char *ctermid(char *);