mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
add ipc pipe (#28)
This commit is contained in:
@ -1142,4 +1142,23 @@ void process_exit_thread(struct process_control_block *pcb)
|
||||
{
|
||||
}
|
||||
|
||||
// #pragma GCC pop_options
|
||||
/**
|
||||
* @brief 申请可用的文件句柄
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int process_fd_alloc(struct vfs_file_t *file)
|
||||
{
|
||||
int fd_num = -1;
|
||||
struct vfs_file_t **f = current_pcb->fds;
|
||||
|
||||
for (int i = 0; i < PROC_MAX_FD_NUM; ++i) {
|
||||
/* 找到指针数组中的空位 */
|
||||
if (f[i] == NULL) {
|
||||
fd_num = i;
|
||||
f[i] = file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return fd_num;
|
||||
}
|
@ -213,3 +213,4 @@ extern struct mm_struct initial_mm;
|
||||
extern struct thread_struct initial_thread;
|
||||
extern union proc_union initial_proc_union;
|
||||
extern struct process_control_block *initial_proc[MAX_CPU_NUM];
|
||||
int process_fd_alloc(struct vfs_file_t *file);
|
||||
|
Reference in New Issue
Block a user