and occasionally provoked student questions.
- Add option to disable buffer cache.
- - Get rid of "dump" commands--they're not really useful.
-
- Sample solution.
- Need a better way to measure performance improvement of buffer
if (e->in_use)
printf ("%s\n", e->name);
}
-
-/* Dumps the contents of D, including its files' names and their
- contents, to the system console. */
-void
-dir_dump (const struct dir *d)
-{
- struct dir_entry *e;
-
- for (e = d->entries; e < d->entries + d->entry_cnt; e++)
- if (e->in_use)
- {
- printf ("Contents of %s:\n", e->name);
- fsutil_print (e->name);
- printf ("\n");
- }
-}
bool dir_add (struct dir *, const char *name, disk_sector_t);
bool dir_remove (struct dir *, const char *name);
void dir_list (const struct dir *);
-void dir_dump (const struct dir *);
#endif /* filesys/directory.h */
return true;
}
-/* Dumps the filesystem state to the system console,
- including the free map, the list of files, and file contents.
- Returns true if successful, false on failure,
- which occurs only if an internal memory allocation fails. */
-bool
-filesys_dump (void)
-{
- struct bitmap *free_map;
- struct dir *dir;
-
- printf ("Free map:\n");
- free_map = bitmap_create (disk_size (filesys_disk));
- if (free_map == NULL)
- return false;
- bitmap_read (free_map, free_map_file);
- bitmap_dump (free_map);
- bitmap_destroy (free_map);
- printf ("\n");
-
- dir = dir_create (NUM_DIR_ENTRIES);
- if (dir == NULL)
- return false;
- dir_read (dir, root_dir_file);
- dir_dump (dir);
- dir_destroy (dir);
-
- return true;
-}
-
static void must_succeed_function (int, bool) NO_INLINE;
#define MUST_SUCCEED(EXPR) must_succeed_function (__LINE__, EXPR)
struct file *filesys_open (const char *name);
bool filesys_remove (const char *name);
bool filesys_list (void);
-bool filesys_dump (void);
void filesys_self_test (void);
/* List all files in the filesystem to the system console? */
bool fsutil_list_files;
-/* Dump full contents of filesystem to the system console? */
-bool fsutil_dump_filesys;
-
/* Copies from the "scratch" disk, hdc or hd1:0,
to a file named FILENAME in the filesystem.
The file will be SIZE bytes in length. */
if (fsutil_list_files)
filesys_list ();
-
- if (fsutil_dump_filesys)
- filesys_dump ();
}
/* Prints the contents of file FILENAME to the system console as
extern char *fsutil_print_file;
extern char *fsutil_remove_file;
extern bool fsutil_list_files;
-extern bool fsutil_dump_filesys;
void fsutil_run (void);
void fsutil_print (const char *filename);
fsutil_remove_file = argv[++i];
else if (!strcmp (argv[i], "-ls"))
fsutil_list_files = true;
- else if (!strcmp (argv[i], "-D"))
- fsutil_dump_filesys = true;
#endif
else if (!strcmp (argv[i], "-u"))
{
" -p FILENAME Print the contents of FILENAME\n"
" -r FILENAME Delete FILENAME\n"
" -ls List the files in the filesystem\n"
- " -D Dump complete filesystem contents\n"
#endif
" -q Power off after doing requested actions.\n"
" -u Print this help message and power off.\n"