/* Create the initial bitmap and reserve sectors for the
free map and root directory file headers. */
- bitmap_init (&free_map, disk_size (disk));
+ if (!bitmap_init (&free_map, disk_size (disk)))
+ panic ("bitmap creation failed");
bitmap_mark (&free_map, FREE_MAP_SECTOR);
bitmap_mark (&free_map, ROOT_DIR_SECTOR);
goto exit1;
/* Allocate a block for the file header. */
- bitmap_init (&free_map, disk_size (disk));
+ if (!bitmap_init (&free_map, disk_size (disk)))
+ goto exit1;
bitmapio_read (&free_map, &free_map_file);
hdr_sector = bitmap_find_and_set (&free_map);
if (hdr_sector == BITMAP_ERROR)
dir_init (&dir, NUM_DIR_ENTRIES);
dir_read (&dir, &root_dir_file);
if (!dir_lookup (&dir, name, &hdr_sector))
- goto exit;
+ goto exit1;
/* Read the file header. */
- filehdr_read (&filehdr, hdr_sector);
+ if (!filehdr_read (&filehdr, hdr_sector))
+ goto exit1;
/* Allocate a block for the file header. */
- bitmap_init (&free_map, disk_size (disk));
+ if (!bitmap_init (&free_map, disk_size (disk)))
+ goto exit2;
bitmapio_read (&free_map, &free_map_file);
/* Deallocate. */
success = true;
/* Clean up. */
- filehdr_destroy (&filehdr);
bitmap_destroy (&free_map);
- exit:
+ exit2:
+ filehdr_destroy (&filehdr);
+ exit1:
dir_destroy (&dir);
return success;