asst3-Virtual Memory Translation/kern/syscall/file_syscalls.c
int
sys_close(int fd)
{
	struct filetable *ft;
	struct openfile *file;

	ft = curproc->p_filetable;

	/* check if the file's in range before calling placeat */
	if (!filetable_okfd(ft, fd)) {
		return EBADF;
	}

	/* place null in the filetable and get the file previously there */
	filetable_placeat(ft, NULL, fd, &file);

	if (file == NULL) {
		/* oops, it wasn't open, that's an error */
		return EBADF;
	}

	/* drop the reference */
	openfile_decref(file);
	return 0;
}
/*
 * close() - remove from the file table.
 */
remove from the file table.
remove from the file table .
int
sys_close(int fd)
{
	struct filetable *ft;
	struct openfile *file;
	ft = curproc->p_filetable;
	if (!filetable_okfd(ft, fd)) {
		return EBADF;
	}
	filetable_placeat(ft, NULL, fd, &file);
	if (file == NULL) {
		return EBADF;
	}
	openfile_decref(file);
	return 0;
}
int sys_close ( int fd ) { struct filetable * ft ; struct openfile * file ; ft = curproc -> p_filetable ; if ( ! filetable_okfd ( ft , fd ) ) { return EBADF ; } filetable_placeat ( ft , NULL , fd , & file ) ; if ( file == NULL ) { return EBADF ; } openfile_decref ( file ) ; return 0 ; }
close() - remove from the file table.
close () - remove from the file table .
/* check if the file's in range before calling placeat */ /* place null in the filetable and get the file previously there */ /* oops, it wasn't open, that's an error */ /* drop the reference */