@Override
    public void freeClusters(int headCluster, boolean freeHead) throws IOException {
        if (headCluster < 0 )
            return;
        if (!freeHead) {
            int fatEntry = fs.getFatEntry(headCluster);
            // CLUSTER_ALLOCATED only
            if ((fatEntry & CLUSTER_STATUS) == CLUSTER_ALLOCATED) {
                // mark as EOC
                fs.putFatEntry(headCluster, CLUSTER_EOC);
                headCluster = fatEntry & CLUSTER_INDEX;
            } else {
                fs.setDirtyState("Cluster double free in tail.  Cluster#:" + headCluster
                        + " Value:" + fatEntry, true);
            }
        }
        while (true) {
            int fatEntry = fs.getFatEntry(headCluster);
            // CLUSTER_ALLOCATED or CLUSTER_EOC
            if ((fatEntry & CLUSTER_ALLOCATED) == CLUSTER_ALLOCATED) {
                // mark as DEALLOC
                fs.putFatEntry(headCluster, CLUSTER_DEALLOC);
                ++fs.freeClusterCount;
                if ((fatEntry & CLUSTER_EOC) == CLUSTER_EOC)
                    break;
                headCluster = fatEntry & CLUSTER_INDEX;
            } else {
                fs.setDirtyState("Cluster double free. Cluster#:" + headCluster
                        + " Value:" + fatEntry, true);
            }
        }
    }