diff options
author | Robert Morris <[email protected]> | 2022-08-23 12:26:26 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2022-08-23 12:26:26 -0400 |
commit | 7c1810e1ae9268581de6bec30cdb696c25bae030 (patch) | |
tree | f0f68318d2e0a6f4f24479fff7880557f2f262ad /kernel | |
parent | 948cfbdb1ff8af3924fe149960824d601df13163 (diff) | |
download | xv6-labs-7c1810e1ae9268581de6bec30cdb696c25bae030.tar.gz xv6-labs-7c1810e1ae9268581de6bec30cdb696c25bae030.tar.bz2 xv6-labs-7c1810e1ae9268581de6bec30cdb696c25bae030.zip |
tolerate running out of inodes
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fs.c | 6 | ||||
-rw-r--r-- | kernel/sysfile.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/kernel/fs.c b/kernel/fs.c index b220491..dea5864 100644 --- a/kernel/fs.c +++ b/kernel/fs.c @@ -193,7 +193,8 @@ static struct inode* iget(uint dev, uint inum); // Allocate an inode on device dev. // Mark it as allocated by giving it type type. -// Returns an unlocked but allocated and referenced inode. +// Returns an unlocked but allocated and referenced inode, +// or NULL if there is no free inode.. struct inode* ialloc(uint dev, short type) { @@ -213,7 +214,8 @@ ialloc(uint dev, short type) } brelse(bp); } - panic("ialloc: no inodes"); + printf("ialloc: no inodes\n"); + return 0; } // Copy a modified in-memory inode to disk. diff --git a/kernel/sysfile.c b/kernel/sysfile.c index d8a6fca..16b668c 100644 --- a/kernel/sysfile.c +++ b/kernel/sysfile.c @@ -262,8 +262,10 @@ create(char *path, short type, short major, short minor) return 0; } - if((ip = ialloc(dp->dev, type)) == 0) - panic("create: ialloc"); + if((ip = ialloc(dp->dev, type)) == 0){ + iunlockput(dp); + return 0; + } ilock(ip); ip->major = major; |