示例#1
0
文件: MfsAdd.java 项目: krbaker/jmfs
  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());
  }
示例#2
0
文件: MfsAdd.java 项目: krbaker/jmfs
  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());
  }
示例#3
0
文件: MfsAdd.java 项目: krbaker/jmfs
  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;
  }
示例#4
0
文件: MfsAdd.java 项目: krbaker/jmfs
  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);
  }