removed block system call

renumber system calls (run gmake clean!)
skeleton for dup system call
This commit is contained in:
kaashoek 2006-08-20 03:08:54 +00:00
parent 8787cd01df
commit 16083d4462
7 changed files with 43 additions and 59 deletions

1
defs.h
View file

@ -94,6 +94,7 @@ int fd_read(struct fd *fd, char *addr, int n);
int fd_write(struct fd *fd, char *addr, int n);
int fd_stat(struct fd *fd, struct stat *);
void fd_incref(struct fd *fd);
int fd_dup(struct fd *fd);
// ide.c
void ide_init(void);

6
fd.c
View file

@ -149,3 +149,9 @@ fd_incref(struct fd *fd)
fd->ref++;
release(&fd_table_lock);
}
int
fd_dup(struct fd *fd)
{
return -1;
}

View file

@ -398,6 +398,23 @@ sys_fstat(void)
return r;
}
int
sys_dup(void)
{
struct proc *cp = curproc[cpu()];
uint fd;
int r;
if(fetcharg(0, &fd) < 0)
return -1;
if(fd < 0 || fd >= NOFILE)
return -1;
if(cp->fds[fd] == 0)
return -1;
r = fd_dup (cp->fds[fd]);
return r;
}
int
sys_link(void)
{
@ -543,44 +560,6 @@ sys_exec(void)
return 0;
}
int
sys_block(void)
{
int i, j;
struct buf *b;
struct inode *ip;
for (i = 0; i < 2; i++) {
cprintf ("issue read\n");
b = bread(1, i);
cprintf("disk 1 sector %d: ", i);
for (j = 0; j < 4; j++)
cprintf("%x ", b->data[j] & 0xff);
cprintf("\n");
brelse(b);
}
ip = iget(1, 1);
cprintf("iget 1: %d %d %d %d %d %d %d %d\n",
ip->dev, ip->inum, ip->count, ip->busy,
ip->type, ip->nlink, ip->size, ip->addrs[0]);
iput(ip);
ip = namei(".././//./../usertests", NAMEI_LOOKUP, 0);
if(ip){
cprintf("namei(usertests): %d %d %d %d %d %d %d %d\n",
ip->dev, ip->inum, ip->count, ip->busy,
ip->type, ip->nlink, ip->size, ip->addrs[0]);
iput(ip);
} else {
cprintf("namei(usertests) failed\n");
}
return 0;
}
void
syscall(void)
{
@ -610,9 +589,6 @@ syscall(void)
case SYS_close:
ret = sys_close();
break;
case SYS_block:
ret = sys_block();
break;
case SYS_kill:
ret = sys_kill();
break;
@ -640,6 +616,9 @@ syscall(void)
case SYS_chdir:
ret = sys_chdir();
break;
case SYS_dup:
ret = sys_dup();
break;
default:
cprintf("unknown sys call %d\n", num);
// XXX fault

View file

@ -1,18 +1,18 @@
#define SYS_fork 1
#define SYS_exit 2
#define SYS_wait 3
#define SYS_pipe 5
#define SYS_write 6
#define SYS_read 7
#define SYS_close 8
#define SYS_block 9
#define SYS_kill 10
#define SYS_exec 13
#define SYS_open 14
#define SYS_mknod 15
#define SYS_unlink 16
#define SYS_fstat 17
#define SYS_link 18
#define SYS_mkdir 19
#define SYS_chdir 20
#define SYS_pipe 4
#define SYS_write 5
#define SYS_read 6
#define SYS_close 7
#define SYS_kill 9
#define SYS_exec 10
#define SYS_open 11
#define SYS_mknod 12
#define SYS_unlink 13
#define SYS_fstat 14
#define SYS_link 15
#define SYS_mkdir 16
#define SYS_chdir 17
#define SYS_dup 18

2
user.h
View file

@ -6,7 +6,6 @@ int pipe(int*);
int write(int, void*, int);
int read(int, void*, int);
int close(int);
int block(void);
int kill(int);
int panic(char*);
int cons_puts(char*);
@ -18,6 +17,7 @@ int fstat (int fd, struct stat *stat);
int link(char *, char *);
int mkdir(char *);
int chdir(char *);
int dup(int);
int stat(char *, struct stat *stat);
int puts(char*);

View file

@ -20,8 +20,6 @@ main(void)
printf(stdout, "userfs is running\n");
block();
fd = open("echo", 0);
if(fd >= 0){
printf(stdout, "open echo ok\n");

2
usys.S
View file

@ -15,7 +15,6 @@ STUB(pipe)
STUB(read)
STUB(write)
STUB(close)
STUB(block)
STUB(kill)
STUB(exec)
STUB(open)
@ -25,3 +24,4 @@ STUB(fstat)
STUB(link)
STUB(mkdir)
STUB(chdir)
STUB(dup)