Example #1
0
  private AppleDisk createNewDisk(Mfs mfs, String name) throws Exception {
    int diskCount = mfs.getDisks().size();
    AppleDisk boot = mfs.getBootDisk();
    String bootName = boot.getName();
    String nextName =
        bootName.substring(0, bootName.length() - 1)
            + (char) (bootName.charAt(bootName.length() - 1) + diskCount);

    return new AppleDisk(name, nextName, boot.getBlock0().clone());
  }
Example #2
0
  public void add(String bootDisk, String externalDisk) throws Exception {
    log.debug("bootDisk='%s', externalDisk='%s'", bootDisk, externalDisk);

    Mfs mfs = new Mfs(true, bootDisk);
    AppleDisk target = null;

    if (externalDisk == null) target = findLargestFreeSpace(mfs);
    else target = createNewDisk(mfs, externalDisk);

    target = add(mfs, target);
    writeChanges(mfs, target);

    if (externalDisk != null)
      Utils.log(
          "Added disk external disk '%s'. It will be named in Tivo as device '%s'\n",
          externalDisk, target.getName());
  }
Example #3
0
  private AppleDisk add(Mfs mfs, AppleDisk target) throws Exception {
    long maxFreeBlocks = target.getAllocatableBlocks();
    long logicalStartBlock = mfs.getMfs().getSize();
    long chunkSize = 20480;
    SizeSet partitionSizes = calcSizes(maxFreeBlocks, chunkSize);

    addPartitions(mfs, target, partitionSizes);
    addZone(mfs, logicalStartBlock, partitionSizes, chunkSize);

    return target;
  }
Example #4
0
  private void writeChanges(Mfs mfs, AppleDisk disk) throws Exception {
    /*	to minimize chance of disk being left in intermediate state
    	write new zone first, then partitions, then finally link the new zone to zone set and write MFS root
    */
    List<Zone> zones = mfs.getZones();

    writeZone(mfs, zones.get(zones.size() - 1));
    //		Utils.printf( System.out, "Writing partition table: %s", disk.getName() );
    disk.write();
    writeZone(mfs, zones.get(zones.size() - 2));
    writeRoot(mfs);
  }