Task: add an alloc_fd() function

This commit is contained in:
apio 2022-10-15 10:45:12 +02:00
parent c77e752a82
commit 3eb1bff2e9
2 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,8 @@ struct Task
Descriptor files[TASK_MAX_FDS];
AddressSpace address_space;
int alloc_fd();
};
void set_context_from_task(Task& task, Context* ctx);

View File

@ -26,4 +26,17 @@ void task_restore_floating(Task& task)
bool Task::is_user_task()
{
return user_task;
}
int Task::alloc_fd()
{
int fd;
for (fd = 0; fd < TASK_MAX_FDS; fd++)
{
if (!files[fd].is_open()) break;
}
if (fd == TASK_MAX_FDS) { return -1; }
return fd;
}