Skip to content

Commit 1edbc1b

Browse files
committed
cgofuse: use Seeker extension function
1 parent b9c138a commit 1edbc1b

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

internal/filesystem/cgofuse/file.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,11 @@ func readFile(file fs.File, buff []byte, ofst int64) (int, error) {
250250
}
251251

252252
func seekFile(file fs.File, ofst int64) (errNo, error) {
253-
const noSeekFmt = "file %T does not support seeking"
254-
seeker, ok := file.(seekerFile)
255-
if !ok {
256-
return -fuse.ESPIPE, fmt.Errorf(noSeekFmt, file)
257-
}
258-
if _, err := seeker.Seek(ofst, io.SeekStart); err != nil {
259-
// HACK: This is probably a bad idea actually.
260-
// TODO: Re-evaluate putting the onus
261-
// back on the implementation, rather than us.
262-
if errors.Is(err, fserrors.ErrUnsupported) {
263-
return -fuse.ESPIPE, fmt.Errorf(noSeekFmt, file)
253+
if _, err := filesystem.Seek(file, ofst, io.SeekStart); err != nil {
254+
if errors.Is(err, errors.ErrUnsupported) {
255+
return -fuse.ESPIPE, err
264256
}
265-
return -fuse.EIO, fmt.Errorf("offset seek error: %w", err)
257+
return -fuse.EIO, err
266258
}
267259
return operationSuccess, nil
268260
}

internal/filesystem/cgofuse/fuse.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ type (
3232
// (So that cross API locks can be possible. E.g. FUSE+9P accessing the same `fs.File`)
3333
ioMu sync.Mutex
3434
}
35-
seekerFile interface {
36-
fs.File
37-
io.Seeker
38-
}
39-
4035
fillFunc = func(name string, stat *fuse.Stat_t, ofst int64) bool
4136
)
4237

0 commit comments

Comments
 (0)