remove remnants of sector size

This commit is contained in:
soypat
2024-01-23 20:33:05 -03:00
parent 8de5ab7c64
commit 37ae0ad5b8
+10 -19
View File
@@ -27,8 +27,8 @@ type Card interface {
} }
// NewBlockDevice creates a new BlockDevice from a Card. // NewBlockDevice creates a new BlockDevice from a Card.
func NewBlockDevice(card Card, blockSize int, numBlocks, eraseBlockSizeInBytes int64) (*BlockDevice, error) { func NewBlockDevice(card Card, blockSize int, numBlocks int64) (*BlockDevice, error) {
if card == nil || blockSize <= 0 || eraseBlockSizeInBytes <= 0 || numBlocks <= 0 { if card == nil || blockSize <= 0 || numBlocks <= 0 {
return nil, errors.New("invalid argument(s)") return nil, errors.New("invalid argument(s)")
} }
blk, err := makeBlockIndexer(blockSize) blk, err := makeBlockIndexer(blockSize)
@@ -36,22 +36,20 @@ func NewBlockDevice(card Card, blockSize int, numBlocks, eraseBlockSizeInBytes i
return nil, err return nil, err
} }
bd := &BlockDevice{ bd := &BlockDevice{
card: card, card: card,
blockbuf: make([]byte, blockSize), blockbuf: make([]byte, blockSize),
blk: blk, blk: blk,
numblocks: int64(numBlocks), numblocks: int64(numBlocks),
eraseBlockSize: eraseBlockSizeInBytes,
} }
return bd, nil return bd, nil
} }
// BlockDevice implements tinyfs.BlockDevice interface for an [sd.Card] type. // BlockDevice implements tinyfs.BlockDevice interface for an [sd.Card] type.
type BlockDevice struct { type BlockDevice struct {
card Card card Card
blockbuf []byte blockbuf []byte
blk blkIdxer blk blkIdxer
numblocks int64 numblocks int64
eraseBlockSize int64
} }
// ReadAt implements [io.ReadAt] interface for an SD card. // ReadAt implements [io.ReadAt] interface for an SD card.
@@ -170,13 +168,6 @@ func (bd *BlockDevice) EraseBlocks(startEraseBlockIdx, len int64) error {
return bd.card.EraseBlocks(startEraseBlockIdx, len) return bd.card.EraseBlocks(startEraseBlockIdx, len)
} }
// EraseBlockSize returns the smallest erasable area on this particular chip
// in bytes. This is used for the block size in EraseBlocks.
// It must be a power of two, and may be as small as 1. A typical size is 4096.
func (bd *BlockDevice) EraseBlockSize() int64 {
return bd.eraseBlockSize
}
// blkIdxer is a helper for calculating block indices and offsets. // blkIdxer is a helper for calculating block indices and offsets.
type blkIdxer struct { type blkIdxer struct {
blockshift int64 blockshift int64