student-distrib/system_call.c
int32_t syscall_write(uint32_t fd, void* buf, int32_t nbytes){
	//check for invalid input
	if((fd > 7) || (fd < 1))
		return -1;

	pcb_t* pcb = get_pcb(tasks_running);
	file_descriptor_t* fd_array = pcb->fd;

	//error out if fd table is invalid
	if(fd_array == NULL)
		return -1;

	//if file is unopened, return invalid
	if(fd_array[fd].flags == 0)
		return -1;

	//if write is unused, return -1
	if(fd_array[fd].fops_table->write == NULL)
		return -1;

	//if the called write function returns -1, return -1
	/*if((*fd_array[fd].fops_table->write)(&fd_array[fd].inode, &fd_array[fd].file_position, (char*) buf, nbytes) == -1)
		return -1;*/

	return (*fd_array[fd].fops_table->write)(&fd_array[fd].inode, &fd_array[fd].file_position, (char*) buf, nbytes);

}
/* system_write
 * Input: fd - file descriptor id
		  buf - buffer to be read from
		  nbytes - number of bytes to write to file
 * Returns: -1 if cannot be execute
 * Effect: file is written with contents from buf
 */
system_write
Input: fd - file descriptor id
buf - buffer to be read from
nbytes - number of bytes to write to file
Returns: -1 if cannot be execute
Effect: file is written with contents from buf
system_write Input : fd - file descriptor id buf - buffer to be read from nbytes - number of bytes to write to file Returns : - 1 if cannot be execute Effect : file is written with contents from buf
int32_t syscall_write(uint32_t fd, void* buf, int32_t nbytes){
	if((fd > 7) || (fd < 1))
		return -1;
	pcb_t* pcb = get_pcb(tasks_running);
	file_descriptor_t* fd_array = pcb->fd;
	if(fd_array == NULL)
		return -1;
	if(fd_array[fd].flags == 0)
		return -1;
	if(fd_array[fd].fops_table->write == NULL)
		return -1;
	return (*fd_array[fd].fops_table->write)(&fd_array[fd].inode, &fd_array[fd].file_position, (char*) buf, nbytes);
}
int32_t syscall_write ( uint32_t fd , void * buf , int32_t nbytes ) { if ( ( fd > 7 ) || ( fd < 1 ) ) return -1 ; pcb_t * pcb = get_pcb ( tasks_running ) ; file_descriptor_t * fd_array = pcb -> fd ; if ( fd_array == NULL ) return -1 ; if ( fd_array [ fd ] . flags == 0 ) return -1 ; if ( fd_array [ fd ] . fops_table -> write == NULL ) return -1 ; return ( * fd_array [ fd ] . fops_table -> write ) ( & fd_array [ fd ] . inode , & fd_array [ fd ] . file_position , ( char * ) buf , nbytes ) ; }
system_write
 Input: fd - file descriptor id
buf - buffer to be read from
nbytes - number of bytes to write to file
 Returns: -1 if cannot be execute
 Effect: file is written with contents from buf
system_write Input : fd - file descriptor id buf - buffer to be read from nbytes - number of bytes to write to file Returns : - 1 if cannot be execute Effect : file is written with contents from buf
//check for invalid input //error out if fd table is invalid //if file is unopened, return invalid //if write is unused, return -1 //if the called write function returns -1, return -1 /*if((*fd_array[fd].fops_table->write)(&fd_array[fd].inode, &fd_array[fd].file_position, (char*) buf, nbytes) == -1)
		return -1;*/