package com.github.mjdev.libaums.partition.mbr;

import androidx.annotation.Nullable;

import com.github.mjdev.libaums.driver.BlockDeviceDriver;
import com.github.mjdev.libaums.partition.PartitionTable;
import com.github.mjdev.libaums.partition.PartitionTableFactory;

import java.io.IOException;
import java.nio.ByteBuffer;

/**
 * Created by magnusja on 30/07/17.
 */

public class MasterBootRecordCreator implements PartitionTableFactory.PartitionTableCreator {
    @Nullable
    @Override
    public PartitionTable read(BlockDeviceDriver blockDevice) throws IOException {
        ByteBuffer buffer = ByteBuffer.allocate(512);
        blockDevice.read(0, buffer);
        return MasterBootRecord.read(buffer);
    }
}

@@ -317,16 +317,39 @@
 eBuffer;
+%0Aimport java.lang.Math;
 %0A%0A/**%0A *
@@ -644,11 +644,49 @@
 ate(
-512
+Math.max(512, blockDevice.getBlockSize())
 );%0A 

fix buffer size mbr if block device size > 512