sys_open(): actually return EMFILE if the process has used all of its file slots

This commit is contained in:
apio 2022-10-11 17:03:16 +02:00
parent 6c51477197
commit 2a755fcd93

View File

@ -19,12 +19,12 @@ void sys_write(Context* context, const char* addr, size_t size)
void sys_open(Context* context, const char* filename, int flags)
{
Task* current_task = Scheduler::current_task();
int fd = -1;
int fd;
for (fd = 0; fd < TASK_MAX_FDS; fd++)
{
if (!current_task->files[fd].is_open()) break;
}
if (fd == -1)
if (fd == TASK_MAX_FDS)
{
STDIO_FAIL(open, EMFILE);
context->rax = -EMFILE;