コード例 #1
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));
  }
コード例 #2
0
 public BootSector getBootSector() {
   return formatter.getBootSector();
 }