CS318 - Pintos
Pintos source browser for JHU CS318 course
directory.h
Go to the documentation of this file.
1 #ifndef FILESYS_DIRECTORY_H
2 #define FILESYS_DIRECTORY_H
3 
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include "devices/block.h"
7 
8 /** Maximum length of a file name component.
9  This is the traditional UNIX maximum length.
10  After directories are implemented, this maximum length may be
11  retained, but much longer full path names must be allowed. */
12 #define NAME_MAX 14
13 
14 struct inode;
15 
16 /** Opening and closing directories. */
17 bool dir_create (block_sector_t sector, size_t entry_cnt);
18 struct dir *dir_open (struct inode *);
19 struct dir *dir_open_root (void);
20 struct dir *dir_reopen (struct dir *);
21 void dir_close (struct dir *);
22 struct inode *dir_get_inode (struct dir *);
23 
24 /** Reading and writing. */
25 bool dir_lookup (const struct dir *, const char *name, struct inode **);
26 bool dir_add (struct dir *, const char *name, block_sector_t);
27 bool dir_remove (struct dir *, const char *name);
28 bool dir_readdir (struct dir *, char name[NAME_MAX + 1]);
29 
30 #endif /**< filesys/directory.h */
name
char * name[]
Definition: insult.c:47
block.h
dir_close
void dir_close(struct dir *)
Destroys DIR and frees associated resources.
Definition: directory.c:70
dir_readdir
bool dir_readdir(struct dir *, char name[NAME_MAX+1])
filesys/directory.h
Definition: directory.c:222
dir_get_inode
struct inode * dir_get_inode(struct dir *)
Returns the inode encapsulated by DIR.
Definition: directory.c:81
dir_remove
bool dir_remove(struct dir *, const char *name)
Removes any entry for NAME in DIR.
Definition: directory.c:185
dir_add
bool dir_add(struct dir *, const char *name, block_sector_t)
Adds a file named NAME to DIR, which must not already contain a file by that name.
Definition: directory.c:142
stdbool.h
NAME_MAX
#define NAME_MAX
Maximum length of a file name component.
Definition: directory.h:12
dir_open
struct dir * dir_open(struct inode *)
Opens and returns the directory for the given INODE, of which it takes ownership.
Definition: directory.c:35
block_sector_t
uint32_t block_sector_t
Index of a block device sector.
Definition: block.h:15
dir_open_root
struct dir * dir_open_root(void)
Opens the root directory and returns a directory for it.
Definition: directory.c:55
dir_lookup
bool dir_lookup(const struct dir *, const char *name, struct inode **)
Reading and writing.
Definition: directory.c:119
inode
In-memory inode.
Definition: inode.c:32
inode::sector
block_sector_t sector
Sector number of disk location.
Definition: inode.c:35
dir_create
bool dir_create(block_sector_t sector, size_t entry_cnt)
Opening and closing directories.
Definition: directory.c:27
stddef.h
dir
A directory.
Definition: directory.c:10
dir_reopen
struct dir * dir_reopen(struct dir *)
Opens and returns a new directory for the same inode as DIR.
Definition: directory.c:63