{
__asm __volatile("cli");
use_console_lock = 0;
- cprintf("panic: ");
+ cprintf("panic (%d): ", cpu());
cprintf(s, 0);
cprintf("\n", 0);
panicked = 1; // freeze other CPU
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);
iput(ip);
}
+void
+iincref(struct inode *ip)
+{
+ ilock(ip);
+ ip->count++;
+ iunlock(ip);
+}
+
void
stati(struct inode *ip, struct stat *st)
{
ushort inum;
char name[DIRSIZ];
};
+
+
-#include "user.h"
#include "types.h"
+#include "stat.h"
+#include "user.h"
#include "fs.h"
#include "fcntl.h"
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();
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);
fd_incref(np->fds[i]);
}
+ // np->cwd = p->cwd;
+ // iincref(p->cwd);
+
return np;
}
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];