private void writeRoot(Mfs mfs) throws Exception { TivoDisk disk = mfs.getBootDisk(); MfsHeader mfsHeader = (disk == null) ? null : disk.getMfsHeader(); if (mfsHeader != null) { PartitionEntry pe = mfsHeader.getParent(); // Utils.printf( System.out, "Writing MFS header on %s: %s", disk.getName(), mfsHeader ); Utils.write(Utils.seekBlock(disk, pe.getStartBlock()), mfsHeader); long roundedSize = Utils.roundDown(pe.getSizeBlocks(), MfsView.VOLUME_SIZE_ROUNDING); Utils.write(Utils.seekBlock(disk, pe.getStartBlock() + roundedSize - 1), mfsHeader); } }
private AppleDisk findLargestFreeSpace(Mfs mfs) throws Exception { // find the disk with largest free space available Map<String, TivoDisk> disks = mfs.getDisks(); TivoDisk largest = null; if ((disks == null) || disks.isEmpty()) throw new Exception("No disks - MFS has not been initialized"); for (TivoDisk disk : disks.values()) { if ((largest == null) || (largest.getAllocatableBlocks() < disk.getAllocatableBlocks())) largest = disk; } return largest; }