PKUOS - Pintos
Pintos source browser for PKU Operating System 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
14struct inode;
15
16/** Opening and closing directories. */
17bool dir_create (block_sector_t sector, size_t entry_cnt);
18struct dir *dir_open (struct inode *);
19struct dir *dir_open_root (void);
20struct dir *dir_reopen (struct dir *);
21void dir_close (struct dir *);
22struct inode *dir_get_inode (struct dir *);
23
24/** Reading and writing. */
25bool dir_lookup (const struct dir *, const char *name, struct inode **);
26bool dir_add (struct dir *, const char *name, block_sector_t);
27bool dir_remove (struct dir *, const char *name);
28bool dir_readdir (struct dir *, char name[NAME_MAX + 1]);
29
30#endif /**< filesys/directory.h */
uint32_t block_sector_t
Index of a block device sector.
Definition: block.h:15
struct dir * dir_open(struct inode *)
Opens and returns the directory for the given INODE, of which it takes ownership.
Definition: directory.c:35
struct inode * dir_get_inode(struct dir *)
Returns the inode encapsulated by DIR.
Definition: directory.c:81
struct dir * dir_reopen(struct dir *)
Opens and returns a new directory for the same inode as DIR.
Definition: directory.c:63
bool dir_readdir(struct dir *, char name[NAME_MAX+1])
filesys/directory.h
Definition: directory.c:222
bool dir_remove(struct dir *, const char *name)
Removes any entry for NAME in DIR.
Definition: directory.c:185
void dir_close(struct dir *)
Destroys DIR and frees associated resources.
Definition: directory.c:70
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
bool dir_create(block_sector_t sector, size_t entry_cnt)
Opening and closing directories.
Definition: directory.c:27
#define NAME_MAX
Maximum length of a file name component.
Definition: directory.h:12
bool dir_lookup(const struct dir *, const char *name, struct inode **)
Reading and writing.
Definition: directory.c:119
struct dir * dir_open_root(void)
Opens the root directory and returns a directory for it.
Definition: directory.c:55
char * name[]
Definition: insult.c:47
A directory.
Definition: directory.c:11
In-memory inode.
Definition: inode.c:33
block_sector_t sector
Sector number of disk location.
Definition: inode.c:35