From 2bc8356577804cf5779c6ace31419f4bb7a1ea8c Mon Sep 17 00:00:00 2001 From: h2-addad <hamza2.addad@live.uwe.ac.uk> Date: Sun, 16 Jul 2023 01:04:23 +0000 Subject: [PATCH] Update --- src/filesys/directory.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/filesys/directory.h diff --git a/src/filesys/directory.h b/src/filesys/directory.h new file mode 100644 index 0000000..930acf9 --- /dev/null +++ b/src/filesys/directory.h @@ -0,0 +1,30 @@ +#ifndef FILESYS_DIRECTORY_H +#define FILESYS_DIRECTORY_H + +#include <stdbool.h> +#include <stddef.h> +#include "devices/block.h" + +/* 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 inode; + +/* 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 *); + +/* 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); +bool dir_readdir (struct dir *, char name[NAME_MAX + 1]); + +#endif /* filesys/directory.h */ -- GitLab