}
void
-bwrite(uint dev, struct buf *b, uint sector)
+bwrite(struct buf *b, uint sector)
{
void *c;
extern struct spinlock ide_lock;
acquire(&ide_lock);
- c = ide_start_rw(dev & 0xff, sector, b->data, 1, 0);
+ c = ide_start_rw(b->dev & 0xff, sector, b->data, 1, 0);
sleep (c, &ide_lock);
ide_finish(c);
b->flags |= B_VALID;
cprintf ("balloc: allocate block %d\n", b);
bp->data[bi/8] |= 0x1 << (bi % 8);
- bwrite (dev, bp, BBLOCK(b, ninodes)); // mark it allocated on disk
+ bwrite (bp, BBLOCK(b, ninodes)); // mark it allocated on disk
brelse(bp);
return b;
}
bi = b % BPB;
m = ~(0x1 << (bi %8));
bp->data[bi/8] &= m;
- bwrite (dev, bp, BBLOCK(b, ninodes)); // mark it free on disk
+ bwrite (bp, BBLOCK(b, ninodes)); // mark it free on disk
brelse(bp);
}
dip->nlink = ip->nlink;
dip->size = ip->size;
memmove(dip->addrs, ip->addrs, sizeof(ip->addrs));
- bwrite (ip->dev, bp, IBLOCK(ip->inum)); // mark it allocated on the disk
+ bwrite (bp, IBLOCK(ip->inum)); // mark it allocated on the disk
brelse(bp);
}
cprintf ("ialloc: %d\n", inum);
dip->type = type;
- bwrite (dev, bp, IBLOCK(inum)); // mark it allocated on the disk
+ bwrite (bp, IBLOCK(inum)); // mark it allocated on the disk
brelse(bp);
ip = iget (dev, inum);
return ip;
m = min(BSIZE - off % BSIZE, n-r);
bp = bread(ip->dev, bmap(ip, off / BSIZE));
memmove (bp->data + off % BSIZE, addr, m);
- bwrite (ip->dev, bp, bmap(ip, off/BSIZE));
+ bwrite (bp, bmap(ip, off/BSIZE));
brelse (bp);
r += m;
off += m;
found:
ep->inum = ip->inum;
- for(i = 0; i < DIRSIZ && cp[i]; i++) ep->name[i] = cp[i];
- bwrite (dp->dev, bp, bmap(dp, off/BSIZE)); // write directory block
+ for(i = 0; i < DIRSIZ && cp[i]; i++)
+ ep->name[i] = cp[i];
+ for( ; i < DIRSIZ; i++)
+ ep->name[i] = '\0';
+ bwrite (bp, bmap(dp, off/BSIZE)); // write directory block
brelse(bp);
- dp->size += sizeof(struct dirent); // update directory inode
- iupdate (dp);
- iput(dp);
- return ip;
+
+ iput(dp);
+
+ return ip;
}
int
found:
ep->inum = 0;
- bwrite (dp->dev, bp, bmap(dp, off/BSIZE)); // write directory block
+ bwrite (bp, bmap(dp, off/BSIZE)); // write directory block
brelse(bp);
iupdate (dp);
iput(dp);