Skip to content

Commit

Permalink
commented out code for cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
kaashoek committed Aug 15, 2006
1 parent d7b3b80 commit e958c53
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion console.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ panic(char *s)
{
__asm __volatile("cli");
use_console_lock = 0;
cprintf("panic: ");
cprintf("panic (%d): ", cpu());
cprintf(s, 0);
cprintf("\n", 0);
panicked = 1; // freeze other CPU
Expand Down
2 changes: 2 additions & 0 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ void bwrite(struct buf *, uint);
void brelse(struct buf *);

// fs.c
extern uint rootdev;
void iinit(void);
struct inode * iget(uint dev, uint inum);
void ilock(struct inode *ip);
void iunlock(struct inode *ip);
void idecref(struct inode *ip);
void iincref(struct inode *ip);
void iput(struct inode *ip);
struct inode * namei(char *path, int, uint *);
void stati(struct inode *ip, struct stat *st);
Expand Down
8 changes: 8 additions & 0 deletions fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ idecref(struct inode *ip)
iput(ip);
}

void
iincref(struct inode *ip)
{
ilock(ip);
ip->count++;
iunlock(ip);
}

void
stati(struct inode *ip, struct stat *st)
{
Expand Down
2 changes: 2 additions & 0 deletions fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ struct dirent {
ushort inum;
char name[DIRSIZ];
};


3 changes: 2 additions & 1 deletion init.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "user.h"
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fs.h"
#include "fcntl.h"

Expand Down
7 changes: 5 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ main0(void)
p->sz = 4 * PAGE;
p->mem = kalloc(p->sz);
memset(p->mem, 0, p->sz);
p->kstack = kalloc(KSTACKSIZE);
p->tf = (struct trapframe *) (p->kstack + KSTACKSIZE - sizeof(struct trapframe));
p->kstack = kalloc(KSTACKSIbZE);
p->tf = (struct trapframe *) (p->kstack + KSTACKSIZE) - 1;
memset(p->tf, 0, sizeof(struct trapframe));
p->tf->es = p->tf->ds = p->tf->ss = (SEG_UDATA << 3) | 3;
p->tf->cs = (SEG_UCODE << 3) | 3;
p->tf->eflags = FL_IF;
setupsegs(p);
// curproc[cpu()] = p;

// initialize I/O devices, let them enable interrupts
console_init();
Expand All @@ -90,6 +91,8 @@ main0(void)
cpus[cpu()].nlock--;
sti();

// p->cwd = iget(rootdev, 1);
// iunlock(p->cwd);
p = copyproc(&proc[0]);

//load_icode(p, _binary_usertests_start, (uint) _binary_usertests_size);
Expand Down
3 changes: 3 additions & 0 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ copyproc(struct proc* p)
fd_incref(np->fds[i]);
}

// np->cwd = p->cwd;
// iincref(p->cwd);

return np;
}

Expand Down
1 change: 1 addition & 0 deletions proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct proc{
void *chan; // sleep
int killed;
struct fd *fds[NOFILE];
struct inode *cwd;

struct taskstate ts; // only to give cpu address of kernel stack
struct segdesc gdt[NSEGS];
Expand Down

0 comments on commit e958c53

Please sign in to comment.