/* Filesystem.
- For the purposes of the "user processes" assignment (project
- 2), please treat all the code in the filesys directory as a
- black box. No changes should be needed. For that project, a
- single lock external to the filesystem code suffices.
+ For the purposes of the "user processes" and "virtual memory"
+ assignments (projects 2 and 3), please treat all the code in
+ the filesys directory as a black box. No changes should be
+ needed. For those projects, a single lock external to the
+ filesystem code suffices.
The filesystem consists of a set of files. Each file has a
header called an `index node' or `inode', represented by
PANIC ("can't open root dir file");
}
+/* Shuts down the filesystem module, writing any unwritten data
+ to disk.
+ Currently there's nothing to do. You'll need to add code here
+ when you implement write-behind caching. */
+void
+filesys_done (void)
+{
+}
+
/* Creates a file named NAME with the given INITIAL_SIZE.
Returns true if successful, false otherwise.
Fails if a file named NAME already exists,
if (free_map == NULL)
goto done;
bitmap_read (free_map, free_map_file);
- inode_sector = bitmap_find_and_set (free_map);
+ inode_sector = bitmap_scan_and_flip (free_map, 0, 1, false);
if (inode_sector == BITMAP_ERROR)
goto done;
/* Opens a file named NAME and initializes FILE for usage with
the file_*() functions declared in file.h.
- Returns true if successful, false on failure.
+ Returns the new file if successful or a null pointer
+ otherwise.
Fails if no file named NAME exists,
or if an internal memory allocation fails. */
struct file *
if (!dir_lookup (dir, name, &inode_sector))
goto done;
- /* Open the inode and delete it it. */
+ /* Open the inode and delete it. */
inode = inode_open (inode_sector);
if (inode == NULL)
goto done;