-
-/*
- * Remove any inodes in the inode cache belonging to dev.
- *
- * There should not be any active ones, return error if any are found
- * (nb: this is a user error, not a system err).
- */
-int busyprt = 0; /* patch to print out busy inodes */
-
-#ifdef QUOTA
-iflush(mp, iq)
- struct mount *mp;
- struct inode *iq;
-#else
-iflush(mp)
- struct mount *mp;
-#endif
-{
- register struct vnode *vp, *nvp;
- register struct inode *ip;
- int busy = 0;
-
- for (vp = mp->m_mounth; vp; vp = nvp) {
- nvp = vp->v_mountf;
- ip = VTOI(vp);
-#ifdef QUOTA
- if (ip == iq)
- continue;
-#endif
- if (vp->v_count) {
- busy++;
- if (!busyprt)
- continue;
- printf("%s %d on dev 0x%x count %d type %d\n",
- "iflush: busy inode ", ip->i_number, ip->i_dev,
- vp->v_count, vp->v_type);
- continue;
- }
- /*
- * With v_count == 0, all we need to do is clear out the
- * vnode data structures and we are done.
- */
- vgone(vp);
- }
- if (busy)
- return (EBUSY);
- return (0);
-}
-
-/*
- * Lock an inode. If its already locked, set the WANT bit and sleep.
- */
-ilock(ip)
- register struct inode *ip;
-{
-
- while (ip->i_flag & ILOCKED) {
- ip->i_flag |= IWANT;
- (void) sleep((caddr_t)ip, PINOD);
- }
- ip->i_flag |= ILOCKED;
-}
-
-/*
- * Unlock an inode. If WANT bit is on, wakeup.
- */
-iunlock(ip)
- register struct inode *ip;
-{
-
- if ((ip->i_flag & ILOCKED) == 0)
- printf("unlocking unlocked inode %d on dev 0x%x\n",
- ip->i_number, ip->i_dev);
- ip->i_flag &= ~ILOCKED;
- if (ip->i_flag&IWANT) {
- ip->i_flag &= ~IWANT;
- wakeup((caddr_t)ip);
- }
-}
-
-/*
- * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC.
- * The mode is shifted to select the owner/group/other fields. The
- * super user is granted all permissions.
- *
- * NB: Called from vnode op table. It seems this could all be done
- * using vattr's but...
- */
-iaccess(ip, mode, cred)
- register struct inode *ip;
- register int mode;
- struct ucred *cred;
-{
- register gid_t *gp;
- int i;
-
- /*
- * If you're the super-user, you always get access.
- */
- if (cred->cr_uid == 0)
- return (0);
- /*
- * Access check is based on only one of owner, group, public.
- * If not owner, then check group. If not a member of the
- * group, then check public access.
- */
- if (cred->cr_uid != ip->i_uid) {
- mode >>= 3;
- gp = cred->cr_groups;
- for (i = 0; i < cred->cr_ngroups; i++, gp++)
- if (ip->i_gid == *gp)
- goto found;
- mode >>= 3;
-found:
- ;
- }
- if ((ip->i_mode & mode) != 0)
- return (0);
- return (EACCES);
-}