146 bool success =
false;
189 bool success =
false;
uint32_t block_sector_t
Index of a block device sector.
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
struct dir * dir_open(struct inode *inode)
Opens and returns the directory for the given INODE, of which it takes ownership.
struct inode * dir_get_inode(struct dir *dir)
Returns the inode encapsulated by DIR.
bool dir_lookup(const struct dir *dir, const char *name, struct inode **inode)
Searches DIR for a file with the given NAME and returns true if one exists, false otherwise.
bool dir_add(struct dir *dir, const char *name, block_sector_t inode_sector)
Adds a file named NAME to DIR, which must not already contain a file by that name.
struct dir * dir_reopen(struct dir *dir)
Opens and returns a new directory for the same inode as DIR.
void dir_close(struct dir *dir)
Destroys DIR and frees associated resources.
static bool lookup(const struct dir *dir, const char *name, struct dir_entry *ep, off_t *ofsp)
Searches DIR for a file with the given NAME.
bool dir_create(block_sector_t sector, size_t entry_cnt)
Creates a directory with space for ENTRY_CNT entries in the given SECTOR.
bool dir_remove(struct dir *dir, const char *name)
Removes any entry for NAME in DIR.
bool dir_readdir(struct dir *dir, char name[NAME_MAX+1])
Reads the next directory entry in DIR and stores the name in NAME.
struct dir * dir_open_root(void)
Opens the root directory and returns a directory for it.
#define NAME_MAX
Maximum length of a file name component.
#define ROOT_DIR_SECTOR
Root directory file inode sector.
off_t inode_write_at(struct inode *inode, const void *buffer_, off_t size, off_t offset)
Writes SIZE bytes from BUFFER into INODE, starting at OFFSET.
off_t inode_read_at(struct inode *inode, void *buffer_, off_t size, off_t offset)
Reads SIZE bytes from INODE into BUFFER, starting at position OFFSET.
struct inode * inode_reopen(struct inode *inode)
Reopens and returns INODE.
void inode_close(struct inode *inode)
Closes INODE and writes it to disk.
struct inode * inode_open(block_sector_t sector)
Reads an inode from SECTOR and returns a ‘struct inode’ that contains it.
bool inode_create(block_sector_t sector, off_t length)
Initializes an inode with LENGTH bytes of data and writes the new inode to sector SECTOR on the file ...
void inode_remove(struct inode *inode)
Marks INODE to be deleted when it is closed by the last caller who has it open.
void * calloc(size_t a, size_t b)
Allocates and return A times B bytes initialized to zeroes.
void free(void *p)
Frees block P, which must have been previously allocated with malloc(), calloc(), or realloc().
int32_t off_t
An offset within a file.
size_t strlen(const char *string)
Returns the length of STRING.
size_t strlcpy(char *dst, const char *src, size_t size)
Copies string SRC to DST.
int strcmp(const char *a_, const char *b_)
Finds the first differing characters in strings A and B.
A single directory entry.
block_sector_t inode_sector
Sector number of header.
bool in_use
In use or free?
char name[NAME_MAX+1]
Null terminated file name.
off_t pos
Current position.
struct inode * inode
Backing store.