- /*
- * we also loose its inumber, just in case (as iput
- * doesn't do that any more) - but as it isn't on its
- * hash chain, I doubt if this is really necessary .. kre
- * (probably the two methods are interchangable)
- */
- ip->i_number = 0;
- iput(ip);
- return(NULL);
- }
- dp = bp->b_un.b_dino;
- dp += itoo(fs, ino);
- ip->i_ic = dp->di_ic;
- brelse(bp);
- return (ip);
-}
-
-/*
- * Decrement reference count of
- * an inode structure.
- * On the last reference,
- * write the inode out and if necessary,
- * truncate and deallocate the file.
- */
-iput(ip)
- register struct inode *ip;
-{
-
- if ((ip->i_flag & ILOCK) == 0)
- panic("iput");
- iunlock(ip);
- irele(ip);
-}
-
-irele(ip)
- register struct inode *ip;
-{
- register int i, x;
- register struct inode *jp;
- int mode;
-
- if (ip->i_count == 1) {
- ip->i_flag |= ILOCK;
- if (ip->i_nlink <= 0) {
- itrunc(ip);
- mode = ip->i_mode;
- ip->i_mode = 0;
- ip->i_rdev = 0;
- ip->i_flag |= IUPD|ICHG;
- ifree(ip, ip->i_number, mode);
- }
- IUPDAT(ip, &time, &time, 0);
- iunlock(ip);
- ip->i_flag = 0;
- /*
- * Put the inode on the end of the free list.
- * Possibly in some cases it would be better to
- * put the inode at the head of the free list,
- * (eg: where i_mode == 0 || i_number == 0)
- * but I will think about that later .. kre
- * (i_number is rarely 0 - only after an i/o error in iget,
- * where i_mode == 0, the inode will probably be wanted
- * again soon for an ialloc, so possibly we should keep it)
- */
- if (ifreeh) {
- *ifreet = ip;
- ip->i_freeb = ifreet;
- } else {
- ifreeh = ip;
- ip->i_freeb = &ifreeh;
- }
- ip->i_freef = NULL;
- ifreet = &ip->i_freef;
- }
- ip->i_count--;
-}