Skip to content
Snippets Groups Projects
Commit e958c538 authored by kaashoek's avatar kaashoek
Browse files

commented out code for cwd

parent d7b3b802
No related branches found
No related tags found
No related merge requests found
...@@ -160,7 +160,7 @@ panic(char *s) ...@@ -160,7 +160,7 @@ panic(char *s)
{ {
__asm __volatile("cli"); __asm __volatile("cli");
use_console_lock = 0; use_console_lock = 0;
cprintf("panic: "); cprintf("panic (%d): ", cpu());
cprintf(s, 0); cprintf(s, 0);
cprintf("\n", 0); cprintf("\n", 0);
panicked = 1; // freeze other CPU panicked = 1; // freeze other CPU
......
...@@ -110,11 +110,13 @@ void bwrite(struct buf *, uint); ...@@ -110,11 +110,13 @@ void bwrite(struct buf *, uint);
void brelse(struct buf *); void brelse(struct buf *);
// fs.c // fs.c
extern uint rootdev;
void iinit(void); void iinit(void);
struct inode * iget(uint dev, uint inum); struct inode * iget(uint dev, uint inum);
void ilock(struct inode *ip); void ilock(struct inode *ip);
void iunlock(struct inode *ip); void iunlock(struct inode *ip);
void idecref(struct inode *ip); void idecref(struct inode *ip);
void iincref(struct inode *ip);
void iput(struct inode *ip); void iput(struct inode *ip);
struct inode * namei(char *path, int, uint *); struct inode * namei(char *path, int, uint *);
void stati(struct inode *ip, struct stat *st); void stati(struct inode *ip, struct stat *st);
......
...@@ -286,6 +286,14 @@ idecref(struct inode *ip) ...@@ -286,6 +286,14 @@ idecref(struct inode *ip)
iput(ip); iput(ip);
} }
void
iincref(struct inode *ip)
{
ilock(ip);
ip->count++;
iunlock(ip);
}
void void
stati(struct inode *ip, struct stat *st) stati(struct inode *ip, struct stat *st)
{ {
......
...@@ -36,3 +36,5 @@ struct dirent { ...@@ -36,3 +36,5 @@ struct dirent {
ushort inum; ushort inum;
char name[DIRSIZ]; char name[DIRSIZ];
}; };
#include "user.h"
#include "types.h" #include "types.h"
#include "stat.h"
#include "user.h"
#include "fs.h" #include "fs.h"
#include "fcntl.h" #include "fcntl.h"
......
...@@ -68,13 +68,14 @@ main0(void) ...@@ -68,13 +68,14 @@ main0(void)
p->sz = 4 * PAGE; p->sz = 4 * PAGE;
p->mem = kalloc(p->sz); p->mem = kalloc(p->sz);
memset(p->mem, 0, p->sz); memset(p->mem, 0, p->sz);
p->kstack = kalloc(KSTACKSIZE); p->kstack = kalloc(KSTACKSIbZE);
p->tf = (struct trapframe *) (p->kstack + KSTACKSIZE - sizeof(struct trapframe)); p->tf = (struct trapframe *) (p->kstack + KSTACKSIZE) - 1;
memset(p->tf, 0, sizeof(struct trapframe)); memset(p->tf, 0, sizeof(struct trapframe));
p->tf->es = p->tf->ds = p->tf->ss = (SEG_UDATA << 3) | 3; p->tf->es = p->tf->ds = p->tf->ss = (SEG_UDATA << 3) | 3;
p->tf->cs = (SEG_UCODE << 3) | 3; p->tf->cs = (SEG_UCODE << 3) | 3;
p->tf->eflags = FL_IF; p->tf->eflags = FL_IF;
setupsegs(p); setupsegs(p);
// curproc[cpu()] = p;
// initialize I/O devices, let them enable interrupts // initialize I/O devices, let them enable interrupts
console_init(); console_init();
...@@ -90,6 +91,8 @@ main0(void) ...@@ -90,6 +91,8 @@ main0(void)
cpus[cpu()].nlock--; cpus[cpu()].nlock--;
sti(); sti();
// p->cwd = iget(rootdev, 1);
// iunlock(p->cwd);
p = copyproc(&proc[0]); p = copyproc(&proc[0]);
//load_icode(p, _binary_usertests_start, (uint) _binary_usertests_size); //load_icode(p, _binary_usertests_start, (uint) _binary_usertests_size);
......
...@@ -124,6 +124,9 @@ copyproc(struct proc* p) ...@@ -124,6 +124,9 @@ copyproc(struct proc* p)
fd_incref(np->fds[i]); fd_incref(np->fds[i]);
} }
// np->cwd = p->cwd;
// iincref(p->cwd);
return np; return np;
} }
......
...@@ -46,6 +46,7 @@ struct proc{ ...@@ -46,6 +46,7 @@ struct proc{
void *chan; // sleep void *chan; // sleep
int killed; int killed;
struct fd *fds[NOFILE]; struct fd *fds[NOFILE];
struct inode *cwd;
struct taskstate ts; // only to give cpu address of kernel stack struct taskstate ts; // only to give cpu address of kernel stack
struct segdesc gdt[NSEGS]; struct segdesc gdt[NSEGS];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment