Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions FileSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,26 @@ void FileSys::rm(const char *name)
// display stats about file or directory
void FileSys::stat(const char *name)
{
}

// HELPER FUNCTIONS (optional)
short FileSys::get_block_index(const char* name) {
for(int i = 0; i < curr_dir_block.num_entries; i++) {
if(std::strcmp(curr_dir_block.dir_entries[i].name, name))
return i;
}
return -1;
}

dirblock_t block;
short inode_index;
if (inode_index = get_block_index(name) == -1){
send_message(ERR_503);
return;
}
bfs.read_block(curr_dir_block.dir_entries[inode_index].block_num, &block);
if (block.magic == DIR_MAGIC_NUM){
send_message("FileName: " << name);
send_message("blockNumber: " << d.block_num);
}else{
inode_t b;
bfs.read_block(curr_dir_block.dir_entries[inode_index].block_num, &block);
send_message("inode Block: " << inode_index);
send_message("Bytes in file: " << block.size
send_message ("number of blocks " << (block.size /BLOCK_SIZE))
send_message("first number of blocks " << block.blocks[0])
}
}

void FileSys::send_message(std::string message) {

}