From: Ben Pfaff Date: Tue, 31 Aug 2004 22:01:10 +0000 (+0000) Subject: Add dir_list(), dir_dump(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fe3c2a0f3ba65c470d726e99d54e8337eb4e0da;p=pintos-anon Add dir_list(), dir_dump(). --- diff --git a/src/filesys/directory.c b/src/filesys/directory.c index 43f87f0..93a505b 100644 --- a/src/filesys/directory.c +++ b/src/filesys/directory.c @@ -1,5 +1,6 @@ #include "directory.h" #include "file.h" +#include "fsutil.h" #include "lib.h" #include "malloc.h" @@ -116,5 +117,26 @@ dir_remove (struct dir *d, const char *name) return false; } -void dir_list (const struct dir *); -void dir_print (const struct dir *); +void +dir_list (const struct dir *d) +{ + struct dir_entry *e; + + for (e = d->entries; e < d->entries + d->entry_cnt; e++) + if (e->in_use) + printk ("%s\n", e->name); +} + +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) + { + printk ("Contents of %s:\n", e->name); + fsutil_print (e->name); + printk ("\n"); + } +} diff --git a/src/filesys/directory.h b/src/filesys/directory.h index fe7f333..aa07ad1 100644 --- a/src/filesys/directory.h +++ b/src/filesys/directory.h @@ -9,6 +9,12 @@ This is the traditional UNIX maximum. */ #define FILENAME_LEN_MAX 14 +struct dir + { + size_t entry_cnt; + struct dir_entry *entries; + }; + struct dir_entry { bool in_use; @@ -16,12 +22,6 @@ struct dir_entry disk_sector_no filehdr_sector; }; -struct dir - { - size_t entry_cnt; - struct dir_entry *entries; - }; - struct file; bool dir_init (struct dir *, size_t entry_cnt); void dir_destroy (struct dir *); @@ -31,6 +31,6 @@ bool dir_lookup (const struct dir *, const char *name, disk_sector_no *); bool dir_add (struct dir *, const char *name, disk_sector_no); bool dir_remove (struct dir *, const char *name); void dir_list (const struct dir *); -void dir_print (const struct dir *); +void dir_dump (const struct dir *); #endif /* directory.h */