X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffilesys%2Ffilesys.c;h=440fc57eeada117c19007e480f69f25848ddad61;hb=11b4e401699d50e674932edca8694d6e6f87566f;hp=8bd39e80ff52ef82eaf1056117448373daf8b7fa;hpb=993c1d9f4452e2edd851f3175dfdf317f18bdb9f;p=pintos-anon diff --git a/src/filesys/filesys.c b/src/filesys/filesys.c index 8bd39e8..440fc57 100644 --- a/src/filesys/filesys.c +++ b/src/filesys/filesys.c @@ -131,6 +131,15 @@ filesys_init (bool format) 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, @@ -157,7 +166,7 @@ filesys_create (const char *name, off_t initial_size) 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; @@ -188,7 +197,8 @@ filesys_create (const char *name, off_t initial_size) /* 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 * @@ -232,7 +242,7 @@ filesys_remove (const char *name) 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;