X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=src%2Ffilesys%2Fdirectory.h;h=930acf986df4b1a647cb8d7cbd01c522d1b2b786;hp=aa07ad1b25586e5f1aa4f3c43a00b99241d4ed0f;hb=a03618133f7df0954802a470a4bee7674f7aed45;hpb=9fe3c2a0f3ba65c470d726e99d54e8337eb4e0da diff --git a/src/filesys/directory.h b/src/filesys/directory.h index aa07ad1..930acf9 100644 --- a/src/filesys/directory.h +++ b/src/filesys/directory.h @@ -1,36 +1,30 @@ -#ifndef HEADER_DIRECTORY_H -#define HEADER_DIRECTORY_H 1 +#ifndef FILESYS_DIRECTORY_H +#define FILESYS_DIRECTORY_H #include #include -#include "disk.h" +#include "devices/block.h" -/* Maximum length of a filename. - This is the traditional UNIX maximum. */ -#define FILENAME_LEN_MAX 14 +/* Maximum length of a file name component. + This is the traditional UNIX maximum length. + After directories are implemented, this maximum length may be + retained, but much longer full path names must be allowed. */ +#define NAME_MAX 14 -struct dir - { - size_t entry_cnt; - struct dir_entry *entries; - }; +struct inode; -struct dir_entry - { - bool in_use; - char name[FILENAME_LEN_MAX + 1]; - disk_sector_no filehdr_sector; - }; +/* Opening and closing directories. */ +bool dir_create (block_sector_t sector, size_t entry_cnt); +struct dir *dir_open (struct inode *); +struct dir *dir_open_root (void); +struct dir *dir_reopen (struct dir *); +void dir_close (struct dir *); +struct inode *dir_get_inode (struct dir *); -struct file; -bool dir_init (struct dir *, size_t entry_cnt); -void dir_destroy (struct dir *); -void dir_read (struct dir *, struct file *); -void dir_write (struct dir *, struct file *); -bool dir_lookup (const struct dir *, const char *name, disk_sector_no *); -bool dir_add (struct dir *, const char *name, disk_sector_no); +/* Reading and writing. */ +bool dir_lookup (const struct dir *, const char *name, struct inode **); +bool dir_add (struct dir *, const char *name, block_sector_t); bool dir_remove (struct dir *, const char *name); -void dir_list (const struct dir *); -void dir_dump (const struct dir *); +bool dir_readdir (struct dir *, char name[NAME_MAX + 1]); -#endif /* directory.h */ +#endif /* filesys/directory.h */