Skip to content
Snippets Groups Projects
Commit 4531bc57 authored by Divyam Khandelwal's avatar Divyam Khandelwal
Browse files

fd_check updated

parent 30f193b5
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ void i8253_init(void){ ...@@ -19,7 +19,7 @@ void i8253_init(void){
void pit_handler(){ void pit_handler(){
//printf("[PIT] Interrupt Test"); //printf("[PIT] Interrupt Test");
scheduler(); //scheduler();
send_eoi(0); send_eoi(0);
//todo //todo
......
...@@ -24,17 +24,19 @@ void control_initilization(void) ...@@ -24,17 +24,19 @@ void control_initilization(void)
control.running_terminal = 0; control.running_terminal = 0;
} }
//checking is fd is valid /* Checks if FD is valid
* Returns -1 for invalid FD
* Returns 0 for valid FD */
int32_t fd_check(int32_t fd) int32_t fd_check(int32_t fd)
{ {
if( fd >= MIN_FILE_NUM && /* First check for valid index */
fd < MAX_FILE_NUM ){ return -1; } if (fd >= MIN_FILE_NUM && fd < MAX_FILE_NUM )
{
// file not present /* Now check if file is present */
if (control.terminal[control.cur_terminal].pcb->fd[fd].flags == 0) if (control.terminal[control.cur_terminal].pcb->fd[fd].flags != 0)
return -1; return 0;
}
else return 0; return -1;
} }
//clearing fd //clearing fd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment