don't panic if out of disk space when extending a directory.
This commit is contained in:
parent
cd6207a972
commit
dc405cdb7b
3 changed files with 39 additions and 3 deletions
|
@ -573,6 +573,7 @@ dirlookup(struct inode *dp, char *name, uint *poff)
|
|||
}
|
||||
|
||||
// Write a new directory entry (name, inum) into the directory dp.
|
||||
// Returns 0 on success, -1 on failure (e.g. out of disk blocks).
|
||||
int
|
||||
dirlink(struct inode *dp, char *name, uint inum)
|
||||
{
|
||||
|
@ -597,7 +598,7 @@ dirlink(struct inode *dp, char *name, uint inum)
|
|||
strncpy(de.name, name, DIRSIZ);
|
||||
de.inum = inum;
|
||||
if(writei(dp, 0, (uint64)&de, off, sizeof(de)) != sizeof(de))
|
||||
panic("dirlink");
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -279,8 +279,13 @@ create(char *path, short type, short major, short minor)
|
|||
panic("create dots");
|
||||
}
|
||||
|
||||
if(dirlink(dp, name, ip->inum) < 0)
|
||||
panic("create: dirlink");
|
||||
if(dirlink(dp, name, ip->inum) < 0){
|
||||
// oops. we don't need ip after all.
|
||||
ip->nlink = 0;
|
||||
iupdate(ip);
|
||||
iunlockput(ip);
|
||||
ip = 0;
|
||||
}
|
||||
|
||||
iunlockput(dp);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue