Don't panic on failure in ialloc

上级 6d02373b
......@@ -9,11 +9,12 @@ dolevel(int fd, int branch, int depth)
{
if (depth > 0) {
for (int i = 0; i < branch; i++) {
char name = 'a' + i;
if (mkdirat(fd, &name) < 0)
char name[] = "a";
*name += i;
if (mkdirat(fd, name) < 0)
die("mkdirat");
int nfd = openat(fd, &name, O_RDONLY);
int nfd = openat(fd, name, O_RDONLY);
if (nfd < 0)
die("openat");
dolevel(nfd, branch, depth-1);
......
......@@ -185,7 +185,8 @@ ialloc(u32 dev, short type)
//cprintf("ialloc oops %d\n", inum); // XXX harmless
}
}
panic("ialloc: no inodes");
cprintf("ialloc: no inodes\n");
return nullptr;
}
// Copy inode, which has changed, from memory to disk.
......
......@@ -228,11 +228,11 @@ create(inode *cwd, const char *path, short type, short major, short minor)
if(type == T_FILE && ip->type == T_FILE)
return ip;
iunlockput(ip);
return 0;
return nullptr;
}
if((ip = ialloc(dp->dev, type)) == 0)
panic("create: ialloc");
if((ip = ialloc(dp->dev, type)) == nullptr)
return nullptr;
ip->major = major;
ip->minor = minor;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论