From bdccf41685f01c66b23f1dbb98aeea79f25d1a77 Mon Sep 17 00:00:00 2001 From: William Durand Date: Fri, 1 Apr 2022 11:55:32 +0200 Subject: [PATCH] kernel: sys: k_write should accept fd < 3 (#619) --- src/kernel/sys/k_write.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/kernel/sys/k_write.c b/src/kernel/sys/k_write.c index e051ddb43..57dc281b9 100644 --- a/src/kernel/sys/k_write.c +++ b/src/kernel/sys/k_write.c @@ -11,6 +11,11 @@ ssize_t k_write(int fd, const void* buf, size_t count) { +#ifndef ENABLE_USERLAND_DEBUG + // This would conflict with the userland message being written. + SYS_DEBUG("fd=%d buf=%p count=%d", fd, buf, count); +#endif + if (fd == STDOUT || fd == STDERR) { for (size_t i = 0; i < count; i++) { arch_putchar(((const char*)buf)[i]); @@ -19,16 +24,6 @@ ssize_t k_write(int fd, const void* buf, size_t count) return count; } - if (fd < 3) { - SYS_DEBUG("invalid file descriptor fd=%d", fd); - return -EPERM; - } - -#ifndef ENABLE_USERLAND_DEBUG - // This would conflict with the userland message being written. - SYS_DEBUG("fd=%d buf=%p count=%d", fd, buf, count); -#endif - descriptor_t* desc = get_descriptor(fd); if (desc == NULL) {