diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 8275d51..20e66fc 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -461,10 +461,9 @@ syscall_mmap (int fd, void *addr) /* Check and ensure that there is enough space in the user virtual memory to hold the entire file. */ for (off_t ofs = 0; ofs < file_size; ofs += PGSIZE) - { if (page_get (thread_current (), addr + ofs) != NULL) return MMAP_FAILURE; - } + /* Map the file data into the user virtual memory starting from addr. */ for (off_t ofs = 0; ofs < file_size; ofs += PGSIZE) @@ -473,7 +472,7 @@ syscall_mmap (int fd, void *addr) off_t zero_bytes = PGSIZE - read_bytes; if (page_insert_file (file, ofs, addr + ofs, read_bytes, zero_bytes, true, - PAGE_FILE) == NULL) + PAGE_MMAP) == NULL) return MMAP_FAILURE; } @@ -482,7 +481,6 @@ syscall_mmap (int fd, void *addr) if (mmap == NULL) return MMAP_FAILURE; - return mmap->mapping; }