Skip to content

Commit

Permalink
Set root to be working directory on system start and fix bitmap...
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaosky committed Dec 8, 2012
1 parent dcfb1d1 commit 08e05b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions P6/minifile.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ int minifile_mkdir(char *dirname)
} else {
parent_inum = namei(parent);
}

if (parent_inum == 0) {
free(parent);
free(name);
Expand All @@ -317,7 +318,7 @@ int minifile_mkdir(char *dirname)
return -1;
} else {
inum = ialloc(maindisk);
if (0 == inum) {
if (0 == inum || -1 == inum) {
return -1;
}
}
Expand Down Expand Up @@ -448,13 +449,13 @@ int minifile_cd(char *path)
return -1;
}
/* Not a directory or the dirctory is mark deleted. Can't create file there since can't delete non-emptry dir */
semaphore_P(new_dir->inode_lock);
ilock(new_dir);
if (new_dir->type != MINIDIRECTORY || new_dir->status == TO_DELETE) {
semaphore_V(new_dir->inode_lock);
iunlock(new_dir);
iput(new_dir);
return -1;
}
semaphore_V(new_dir->inode_lock);
iunlock(new_dir);

/* Release previous directory inode if not root */
if (cur_inodenum != mainsb->root_inum) {
Expand Down
2 changes: 1 addition & 1 deletion P6/minifile_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fs_format(mem_sblock_t sbp)
bitmap_set(sbp->block_bitmap, i);
}
/* Set inode 0 to be occupied */
bitmap_set(sbp->inode_bitmap, 1);
bitmap_set(sbp->inode_bitmap, 0);
/* Push updates to disk */
for (i = sbp->inode_bitmap_first; i <= sbp->inode_bitmap_last; ++i) {
bpush(i, (char*) sbp->inode_bitmap + (i - sbp->inode_bitmap_first)
Expand Down
5 changes: 4 additions & 1 deletion P6/minithread.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,10 @@ minithread_initialize_filesystem()
if (iget(maindisk, mainsb->root_inum, &root_inode) != 0) {
return -1;
}


minithread_set_wd(mainsb->root_inum);
minithread_set_wd_inode(root_inode);

return 0;
}

Expand Down

0 comments on commit 08e05b9

Please sign in to comment.