Skip to content

Commit

Permalink
refactor: Implement seeking if the backing file is a block device in …
Browse files Browse the repository at this point in the history
…example file backend (see #8)

Signed-off-by: Felicitas Pojtinger <felicitas@pojtinger.com>
  • Loading branch information
pojntfx committed Jul 30, 2024
1 parent 67583de commit 2d78be2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/backend/file.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package backend

import (
"io"
"os"
"sync"
)
Expand Down Expand Up @@ -35,12 +36,12 @@ func (b *FileBackend) WriteAt(p []byte, off int64) (n int, err error) {
}

func (b *FileBackend) Size() (int64, error) {
stat, err := b.file.Stat()
size, err := b.file.Seek(0, io.SeekEnd)
if err != nil {
return -1, err
}

return stat.Size(), nil
return size, nil
}

func (b *FileBackend) Sync() error {
Expand Down

0 comments on commit 2d78be2

Please sign in to comment.