Don't panic on failure in ialloc

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