Print this page
7653 tmpfs: calling unlink() on a directory which isn't empty should fail

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/tmpfs/tmp_vnops.c
          +++ new/usr/src/uts/common/fs/tmpfs/tmp_vnops.c
↓ open down ↓ 1097 lines elided ↑ open up ↑
1098 1098          error = tdirlookup(parent, nm, &tp, cred);
1099 1099          if (error)
1100 1100                  return (error);
1101 1101  
1102 1102          ASSERT(tp);
1103 1103          rw_enter(&parent->tn_rwlock, RW_WRITER);
1104 1104          rw_enter(&tp->tn_rwlock, RW_WRITER);
1105 1105  
1106 1106          if (tp->tn_type != VDIR ||
1107 1107              (error = secpolicy_fs_linkdir(cred, dvp->v_vfsp)) == 0)
1108      -                error = tdirdelete(parent, tp, nm, tp->tn_type == VDIR ?
1109      -                    DR_RMDIR : DR_REMOVE, cred);
     1108 +                error = tdirdelete(parent, tp, nm, DR_REMOVE, cred);
1110 1109  
1111 1110          rw_exit(&tp->tn_rwlock);
1112 1111          rw_exit(&parent->tn_rwlock);
1113 1112          vnevent_remove(TNTOV(tp), dvp, nm, ct);
1114 1113          tmpnode_rele(tp);
1115 1114  
1116 1115          TRACE_3(TR_FAC_TMPFS, TR_TMPFS_REMOVE,
1117 1116              "tmpfs remove:dvp %p nm %s error %d", dvp, nm, error);
1118 1117          return (error);
1119 1118  }
↓ open down ↓ 298 lines elided ↑ open up ↑
1418 1417                  goto done1;
1419 1418          }
1420 1419          mutex_exit(&self->tn_tlock);
1421 1420  
1422 1421          if (vn_vfswlock(vp)) {
1423 1422                  error = EBUSY;
1424 1423                  goto done1;
1425 1424          }
1426 1425          if (vn_mountedvfs(vp) != NULL) {
1427 1426                  error = EBUSY;
1428      -                goto done;
1429      -        }
1430      -
1431      -        /*
1432      -         * Check for an empty directory
1433      -         * i.e. only includes entries for "." and ".."
1434      -         */
1435      -        if (self->tn_dirents > 2) {
1436      -                error = EEXIST;         /* SIGH should be ENOTEMPTY */
1437      -                /*
1438      -                 * Update atime because checking tn_dirents is logically
1439      -                 * equivalent to reading the directory
1440      -                 */
1441      -                gethrestime(&self->tn_atime);
1442 1427                  goto done;
1443 1428          }
1444 1429  
1445 1430          error = tdirdelete(parent, self, nm, DR_RMDIR, cred);
1446 1431  done:
1447 1432          vn_vfsunlock(vp);
1448 1433  done1:
1449 1434          rw_exit(&self->tn_rwlock);
1450 1435          rw_exit(&parent->tn_rwlock);
1451 1436          vnevent_rmdir(TNTOV(self), dvp, nm, ct);
↓ open down ↓ 1020 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX