Skip to content
Snippets Groups Projects
Commit e4bcd2a3 authored by rtm's avatar rtm
Browse files

wdir now uses readi/writei

parent 17e3cf15
No related branches found
No related tags found
No related merge requests found
...@@ -450,43 +450,24 @@ void ...@@ -450,43 +450,24 @@ void
wdir(struct inode *dp, char *name, uint ino) wdir(struct inode *dp, char *name, uint ino)
{ {
uint off; uint off;
struct buf *bp = 0; struct dirent de;
struct dirent *ep = 0;
int i; int i;
int lb;
for(off = 0; off < dp->size; off += sizeof(de)){
if(dp->size % BSIZE) if(readi(dp, (char *) &de, off, sizeof(de)) != sizeof(de))
dp->size += (BSIZE - dp->size % BSIZE); panic("wdir read");
if(de.inum == 0)
for(off = 0; off < dp->size; off += BSIZE) { break;
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");
} }
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: de.inum = ino;
ep->inum = ino;
for(i = 0; i < DIRSIZ && name[i]; i++) for(i = 0; i < DIRSIZ && name[i]; i++)
ep->name[i] = name[i]; de.name[i] = name[i];
for( ; i < DIRSIZ; i++) for( ; i < DIRSIZ; i++)
ep->name[i] = '\0'; de.name[i] = '\0';
bwrite (bp, bmap(dp, off/BSIZE)); // write directory block
brelse(bp); if(writei(dp, (char *) &de, off, sizeof(de)) != sizeof(de))
iupdate(dp); panic("wdir write");
} }
struct inode * struct inode *
......
...@@ -17,7 +17,6 @@ static ushort irq_mask_8259A = 0xFFFF & ~(1<<IRQ_SLAVE); ...@@ -17,7 +17,6 @@ static ushort irq_mask_8259A = 0xFFFF & ~(1<<IRQ_SLAVE);
static void static void
irq_setmask_8259A(ushort mask) irq_setmask_8259A(ushort mask)
{ {
int i;
irq_mask_8259A = mask; irq_mask_8259A = mask;
outb(IO_PIC1+1, (char)mask); outb(IO_PIC1+1, (char)mask);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment