Пример #1
0
 /**
  * Constructor for GrubFatFormatter.
  *
  * @param bootSectorOffset
  * @param stage1ResourceName
  * @param stage2ResourceName
  */
 public GrubFatFormatter(
     int bootSectorOffset, String stage1ResourceName, String stage2ResourceName) {
   GrubBootSector bs = (GrubBootSector) createBootSector(stage1ResourceName, stage2ResourceName);
   bs.setOemName("JNode1.0");
   formatter = FatFormatter.fat144FloppyFormatter(calculateReservedSectors(512), bs);
   this.bootSectorOffset = bootSectorOffset;
 }
Пример #2
0
  /** @see org.jnode.fs.fat.FatFormatter#format(BlockDeviceAPI) */
  public void format(BlockDeviceAPI api) throws IOException {

    formatter.format(api);
    GrubBootSector bs = (GrubBootSector) formatter.getBootSector();
    /* Fixup the blocklist end the end of the first sector of stage2 */
    LittleEndian.setInt32(stage2, 512 - 8, bootSectorOffset + 2);

    /* Fixup the install partition */
    LittleEndian.setInt32(stage2, 512 + 0x08, installPartition);

    /* Fixup the config file */
    if (configFile != null) {
      int ofs = 512 + 0x12;
      while (stage2[ofs] != 0) {
        ofs++;
      }
      ofs++; /* Skip '\0' */
      for (int i = 0; i < configFile.length(); i++) {
        stage2[ofs++] = (byte) configFile.charAt(i);
      }
      stage2[ofs] = 0;
    }

    /* Write stage2 */
    api.write(bs.getBytesPerSector(), ByteBuffer.wrap(stage2));
  }
Пример #3
0
  /**
   * @param bps
   * @param spc
   * @param geom
   * @param fatSize
   */
  public GrubFatFormatter(
      int bps,
      int spc,
      Geometry geom,
      FatType fatSize,
      int bootSectorOffset,
      String stage1ResourceName,
      String stage2ResourceName) {

    GrubBootSector bs = (GrubBootSector) createBootSector(stage1ResourceName, stage2ResourceName);
    bs.setOemName("JNode1.0");
    formatter =
        FatFormatter.HDFormatter(
            bps,
            (int) geom.getTotalSectors(),
            geom.getSectors(),
            geom.getHeads(),
            fatSize,
            0,
            calculateReservedSectors(512),
            bs);
    this.bootSectorOffset = bootSectorOffset;
  }