Skip to content

Commit

Permalink
wdir now uses readi/writei
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm committed Aug 13, 2006
1 parent 17e3cf1 commit e4bcd2a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
45 changes: 13 additions & 32 deletions fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,43 +450,24 @@ void
wdir(struct inode *dp, char *name, uint ino)
{
uint off;
struct buf *bp = 0;
struct dirent *ep = 0;
struct dirent de;
int i;
int lb;

if(dp->size % BSIZE)
dp->size += (BSIZE - dp->size % BSIZE);

for(off = 0; off < dp->size; off += BSIZE) {
bp = bread(dp->dev, bmap(dp, off / BSIZE));
for(ep = (struct dirent *) bp->data;
ep < (struct dirent *) (bp->data + BSIZE);
ep++){
if(ep->inum == 0)
goto found;
}
brelse(bp);
}
lb = dp->size / BSIZE;
if (lb >= NDIRECT) {
panic ("wdir: too many entries");

for(off = 0; off < dp->size; off += sizeof(de)){
if(readi(dp, (char *) &de, off, sizeof(de)) != sizeof(de))
panic("wdir read");
if(de.inum == 0)
break;
}
dp->addrs[lb] = balloc(dp->dev);
bp = bread(dp->dev, dp->addrs[lb]);
memset(bp->data, 0, BSIZE);
ep = (struct dirent *) (bp->data);
dp->size += BSIZE;

found:
ep->inum = ino;
de.inum = ino;
for(i = 0; i < DIRSIZ && name[i]; i++)
ep->name[i] = name[i];
de.name[i] = name[i];
for( ; i < DIRSIZ; i++)
ep->name[i] = '\0';
bwrite (bp, bmap(dp, off/BSIZE)); // write directory block
brelse(bp);
iupdate(dp);
de.name[i] = '\0';

if(writei(dp, (char *) &de, off, sizeof(de)) != sizeof(de))
panic("wdir write");
}

struct inode *
Expand Down
1 change: 0 additions & 1 deletion picirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ static ushort irq_mask_8259A = 0xFFFF & ~(1<<IRQ_SLAVE);
static void
irq_setmask_8259A(ushort mask)
{
int i;
irq_mask_8259A = mask;

outb(IO_PIC1+1, (char)mask);
Expand Down

0 comments on commit e4bcd2a

Please sign in to comment.