writeable => writable
This commit is contained in:
parent
48b824703b
commit
d4c64e5d43
4
fd.c
4
fd.c
|
@ -58,7 +58,7 @@ fd_alloc(void)
|
||||||
int
|
int
|
||||||
fd_write(struct fd *fd, char *addr, int n)
|
fd_write(struct fd *fd, char *addr, int n)
|
||||||
{
|
{
|
||||||
if(fd->writeable == 0)
|
if(fd->writable == 0)
|
||||||
return -1;
|
return -1;
|
||||||
if(fd->type == FD_PIPE){
|
if(fd->type == FD_PIPE){
|
||||||
return pipe_write(fd->pipe, addr, n);
|
return pipe_write(fd->pipe, addr, n);
|
||||||
|
@ -114,7 +114,7 @@ fd_close(struct fd *fd)
|
||||||
release(&fd_table_lock);
|
release(&fd_table_lock);
|
||||||
|
|
||||||
if(dummy.type == FD_PIPE){
|
if(dummy.type == FD_PIPE){
|
||||||
pipe_close(dummy.pipe, dummy.writeable);
|
pipe_close(dummy.pipe, dummy.writable);
|
||||||
} else if(dummy.type == FD_FILE){
|
} else if(dummy.type == FD_FILE){
|
||||||
idecref(dummy.ip);
|
idecref(dummy.ip);
|
||||||
} else {
|
} else {
|
||||||
|
|
2
fd.h
2
fd.h
|
@ -2,7 +2,7 @@ struct fd {
|
||||||
enum { FD_CLOSED, FD_NONE, FD_PIPE, FD_FILE } type;
|
enum { FD_CLOSED, FD_NONE, FD_PIPE, FD_FILE } type;
|
||||||
int ref; // reference count
|
int ref; // reference count
|
||||||
char readable;
|
char readable;
|
||||||
char writeable;
|
char writable;
|
||||||
struct pipe *pipe;
|
struct pipe *pipe;
|
||||||
struct inode *ip;
|
struct inode *ip;
|
||||||
uint off;
|
uint off;
|
||||||
|
|
2
kalloc.c
2
kalloc.c
|
@ -51,7 +51,7 @@ kfree(char *cp, int len)
|
||||||
if(len % PAGE)
|
if(len % PAGE)
|
||||||
panic("kfree");
|
panic("kfree");
|
||||||
|
|
||||||
// XXX fill with junk to help debug
|
// Fill with junk to catch dangling refs.
|
||||||
for(i = 0; i < len; i++)
|
for(i = 0; i < len; i++)
|
||||||
cp[i] = 1;
|
cp[i] = 1;
|
||||||
|
|
||||||
|
|
8
pipe.c
8
pipe.c
|
@ -37,11 +37,11 @@ pipe_alloc(struct fd **fd1, struct fd **fd2)
|
||||||
initlock(&p->lock, "pipe");
|
initlock(&p->lock, "pipe");
|
||||||
(*fd1)->type = FD_PIPE;
|
(*fd1)->type = FD_PIPE;
|
||||||
(*fd1)->readable = 1;
|
(*fd1)->readable = 1;
|
||||||
(*fd1)->writeable = 0;
|
(*fd1)->writable = 0;
|
||||||
(*fd1)->pipe = p;
|
(*fd1)->pipe = p;
|
||||||
(*fd2)->type = FD_PIPE;
|
(*fd2)->type = FD_PIPE;
|
||||||
(*fd2)->readable = 0;
|
(*fd2)->readable = 0;
|
||||||
(*fd2)->writeable = 1;
|
(*fd2)->writable = 1;
|
||||||
(*fd2)->pipe = p;
|
(*fd2)->pipe = p;
|
||||||
return 0;
|
return 0;
|
||||||
oops:
|
oops:
|
||||||
|
@ -59,11 +59,11 @@ pipe_alloc(struct fd **fd1, struct fd **fd2)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pipe_close(struct pipe *p, int writeable)
|
pipe_close(struct pipe *p, int writable)
|
||||||
{
|
{
|
||||||
acquire(&p->lock);
|
acquire(&p->lock);
|
||||||
|
|
||||||
if(writeable){
|
if(writable){
|
||||||
p->writeopen = 0;
|
p->writeopen = 0;
|
||||||
wakeup(&p->readp);
|
wakeup(&p->readp);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -260,13 +260,13 @@ sys_open(void)
|
||||||
fd->type = FD_FILE;
|
fd->type = FD_FILE;
|
||||||
if(arg1 & O_RDWR) {
|
if(arg1 & O_RDWR) {
|
||||||
fd->readable = 1;
|
fd->readable = 1;
|
||||||
fd->writeable = 1;
|
fd->writable = 1;
|
||||||
} else if(arg1 & O_WRONLY) {
|
} else if(arg1 & O_WRONLY) {
|
||||||
fd->readable = 0;
|
fd->readable = 0;
|
||||||
fd->writeable = 1;
|
fd->writable = 1;
|
||||||
} else {
|
} else {
|
||||||
fd->readable = 1;
|
fd->readable = 1;
|
||||||
fd->writeable = 0;
|
fd->writable = 0;
|
||||||
}
|
}
|
||||||
fd->ip = ip;
|
fd->ip = ip;
|
||||||
fd->off = 0;
|
fd->off = 0;
|
||||||
|
|
Loading…
Reference in a new issue