mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 15:26:47 +00:00
🔧 校验文件描述符是否存在
This commit is contained in:
parent
b3ad8405a4
commit
d9399944e8
@ -218,7 +218,9 @@ uint64_t sys_close(struct pt_regs *regs)
|
|||||||
// 校验文件描述符范围
|
// 校验文件描述符范围
|
||||||
if (fd_num < 0 || fd_num > PROC_MAX_FD_NUM)
|
if (fd_num < 0 || fd_num > PROC_MAX_FD_NUM)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
// 文件描述符不存在
|
||||||
|
if (current_pcb->fds[fd_num] == NULL)
|
||||||
|
return -EBADF;
|
||||||
struct vfs_file_t *file_ptr = current_pcb->fds[fd_num];
|
struct vfs_file_t *file_ptr = current_pcb->fds[fd_num];
|
||||||
uint64_t ret;
|
uint64_t ret;
|
||||||
// If there is a valid close function
|
// If there is a valid close function
|
||||||
@ -251,6 +253,10 @@ uint64_t sys_read(struct pt_regs *regs)
|
|||||||
if (fd_num < 0 || fd_num > PROC_MAX_FD_NUM)
|
if (fd_num < 0 || fd_num > PROC_MAX_FD_NUM)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
|
// 文件描述符不存在
|
||||||
|
if (current_pcb->fds[fd_num] == NULL)
|
||||||
|
return -EBADF;
|
||||||
|
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user