Task: add an alloc_fd() function
This commit is contained in:
parent
c77e752a82
commit
3eb1bff2e9
@ -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);
|
||||
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user