Implement a proper block layer with partition support.
[pintos-anon] / src / filesys / directory.h
index aa07ad1b25586e5f1aa4f3c43a00b99241d4ed0f..930acf986df4b1a647cb8d7cbd01c522d1b2b786 100644 (file)
@@ -1,36 +1,30 @@
-#ifndef HEADER_DIRECTORY_H
-#define HEADER_DIRECTORY_H 1
+#ifndef FILESYS_DIRECTORY_H
+#define FILESYS_DIRECTORY_H
 
 #include <stdbool.h>
 #include <stddef.h>
-#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 */