summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bio.c6
-rw-r--r--cat.c8
2 files changed, 6 insertions, 8 deletions
diff --git a/bio.c b/bio.c
index 90dbcdc..fd3a47c 100644
--- a/bio.c
+++ b/bio.c
@@ -65,16 +65,12 @@ bget(uint dev, uint blockno)
acquire(&bcache.lock);
- // cprintf("bget %d\n", blockno);
-
// Is the block already cached?
for(b = bcache.head.next; b != &bcache.head; b = b->next){
if(b->dev == dev && b->blockno == blockno){
- //cprintf("bget %d; get sleep lock for buffer %p\n", blockno, b - bcache.buf);
b->refcnt++;
release(&bcache.lock);
acquiresleep(&b->lock);
- //cprintf("bget: return buffer %p for blk %d\n", b - bcache.buf, blockno);
return b;
}
}
@@ -84,14 +80,12 @@ bget(uint dev, uint blockno)
// hasn't yet committed the changes to the buffer.
for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) {
- // cprintf("bget %d; use %p for %d\n", b - bcache.buf, blockno);
b->dev = dev;
b->blockno = blockno;
b->flags = 0;
b->refcnt = 1;
release(&bcache.lock);
acquiresleep(&b->lock);
- // cprintf("bget: return buffer %p for blk %d\n", b - bcache.buf, blockno);
return b;
}
}
diff --git a/cat.c b/cat.c
index 2b2dcc7..5ddc820 100644
--- a/cat.c
+++ b/cat.c
@@ -9,8 +9,12 @@ cat(int fd)
{
int n;
- while((n = read(fd, buf, sizeof(buf))) > 0)
- write(1, buf, n);
+ while((n = read(fd, buf, sizeof(buf))) > 0) {
+ if (write(1, buf, n) != n) {
+ printf(1, "cat: write error\n");
+ exit();
+ }
+ }
if(n < 0){
printf(1, "cat: read error\n");
exit();