X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffilesys%2Ffilesys.c;h=87c20047418362ddb9ca22103afb2adce50298e6;hb=8c943ff5ffb0121878d1866e56905b9e8be5d95c;hp=2cc07217aa19dddb75d8f188bcb77e7a579d8db5;hpb=4199abedf1dbf20ebd5abe9cebca55d40e9103f0;p=pintos-anon diff --git a/src/filesys/filesys.c b/src/filesys/filesys.c index 2cc0721..87c2004 100644 --- a/src/filesys/filesys.c +++ b/src/filesys/filesys.c @@ -49,7 +49,8 @@ do_format (void) /* Write out the free map now that we have space reserved for it. */ - file_open (&free_map_file, FREE_MAP_SECTOR); + if (!file_open (&free_map_file, FREE_MAP_SECTOR)) + panic ("can't open free map file"); bitmap_write (&free_map, &free_map_file); bitmap_destroy (&free_map); file_close (&free_map_file); @@ -74,8 +75,10 @@ filesys_init (bool format) if (format) do_format (); - file_open (&free_map_file, FREE_MAP_SECTOR); - file_open (&root_dir_file, ROOT_DIR_SECTOR); + if (!file_open (&free_map_file, FREE_MAP_SECTOR)) + panic ("can't open free map file"); + if (!file_open (&root_dir_file, ROOT_DIR_SECTOR)) + panic ("can't open root dir file"); } bool @@ -88,7 +91,8 @@ filesys_create (const char *name, off_t initial_size) bool success = false; /* Read the root directory. */ - dir_init (&dir, NUM_DIR_ENTRIES); + if (!dir_init (&dir, NUM_DIR_ENTRIES)) + return false; dir_read (&dir, &root_dir_file); if (dir_lookup (&dir, name, NULL)) goto exit1; @@ -134,7 +138,8 @@ filesys_open (const char *name, struct file *file) disk_sector_no hdr_sector; bool success = false; - dir_init (&dir, NUM_DIR_ENTRIES); + if (!dir_init (&dir, NUM_DIR_ENTRIES)) + return false; dir_read (&dir, &root_dir_file); if (dir_lookup (&dir, name, &hdr_sector)) success = file_open (file, hdr_sector); @@ -153,7 +158,8 @@ filesys_remove (const char *name) bool success = false; /* Read the root directory. */ - dir_init (&dir, NUM_DIR_ENTRIES); + if (!dir_init (&dir, NUM_DIR_ENTRIES)) + return false; dir_read (&dir, &root_dir_file); if (!dir_lookup (&dir, name, &hdr_sector)) goto exit1;