Skip to content

Commit bdccf41

Browse files
authored
kernel: sys: k_write should accept fd < 3 (#619)
1 parent d724050 commit bdccf41

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/kernel/sys/k_write.c

+5-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
ssize_t k_write(int fd, const void* buf, size_t count)
1313
{
14+
#ifndef ENABLE_USERLAND_DEBUG
15+
// This would conflict with the userland message being written.
16+
SYS_DEBUG("fd=%d buf=%p count=%d", fd, buf, count);
17+
#endif
18+
1419
if (fd == STDOUT || fd == STDERR) {
1520
for (size_t i = 0; i < count; i++) {
1621
arch_putchar(((const char*)buf)[i]);
@@ -19,16 +24,6 @@ ssize_t k_write(int fd, const void* buf, size_t count)
1924
return count;
2025
}
2126

22-
if (fd < 3) {
23-
SYS_DEBUG("invalid file descriptor fd=%d", fd);
24-
return -EPERM;
25-
}
26-
27-
#ifndef ENABLE_USERLAND_DEBUG
28-
// This would conflict with the userland message being written.
29-
SYS_DEBUG("fd=%d buf=%p count=%d", fd, buf, count);
30-
#endif
31-
3227
descriptor_t* desc = get_descriptor(fd);
3328

3429
if (desc == NULL) {

0 commit comments

Comments
 (0)