summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--console.c2
-rw-r--r--defs.h2
-rw-r--r--fs.c8
-rw-r--r--fs.h2
-rw-r--r--init.c3
-rw-r--r--main.c7
-rw-r--r--proc.c3
-rw-r--r--proc.h1
8 files changed, 24 insertions, 4 deletions
diff --git a/console.c b/console.c
index a91029f..3d19a8e 100644
--- a/console.c
+++ b/console.c
@@ -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
diff --git a/defs.h b/defs.h
index da47691..2928428 100644
--- a/defs.h
+++ b/defs.h
@@ -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);
diff --git a/fs.c b/fs.c
index 2370e0e..530ef03 100644
--- a/fs.c
+++ b/fs.c
@@ -287,6 +287,14 @@ idecref(struct inode *ip)
}
void
+iincref(struct inode *ip)
+{
+ ilock(ip);
+ ip->count++;
+ iunlock(ip);
+}
+
+void
stati(struct inode *ip, struct stat *st)
{
st->st_dev = ip->dev;
diff --git a/fs.h b/fs.h
index 6e83373..2112c25 100644
--- a/fs.h
+++ b/fs.h
@@ -36,3 +36,5 @@ struct dirent {
ushort inum;
char name[DIRSIZ];
};
+
+
diff --git a/init.c b/init.c
index 928371d..983246b 100644
--- a/init.c
+++ b/init.c
@@ -1,5 +1,6 @@
-#include "user.h"
#include "types.h"
+#include "stat.h"
+#include "user.h"
#include "fs.h"
#include "fcntl.h"
diff --git a/main.c b/main.c
index a2ee845..6e1dabe 100644
--- a/main.c
+++ b/main.c
@@ -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();
@@ -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);
diff --git a/proc.c b/proc.c
index 7290693..6880fd4 100644
--- a/proc.c
+++ b/proc.c
@@ -124,6 +124,9 @@ copyproc(struct proc* p)
fd_incref(np->fds[i]);
}
+ // np->cwd = p->cwd;
+ // iincref(p->cwd);
+
return np;
}
diff --git a/proc.h b/proc.h
index 6ed2e78..88e630b 100644
--- a/proc.h
+++ b/proc.h
@@ -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];