fusefrontend: add File.SeekData() function
This function will enable "gocryptfs -fsck" to handle sparse files efficiently.
This commit is contained in:
parent
a2af1fb5da
commit
e951043084
@ -3,6 +3,9 @@ package fusefrontend
|
|||||||
// Helper functions for sparse files (files with holes)
|
// Helper functions for sparse files (files with holes)
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/hanwen/go-fuse/fuse"
|
"github.com/hanwen/go-fuse/fuse"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/internal/tlog"
|
"github.com/rfjakob/gocryptfs/internal/tlog"
|
||||||
@ -53,3 +56,15 @@ func (f *File) zeroPad(plainSize uint64) fuse.Status {
|
|||||||
_, status := f.doWrite(pad, int64(plainSize))
|
_, status := f.doWrite(pad, int64(plainSize))
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SeekData calls the lseek syscall with SEEK_DATA. It returns the offset of the
|
||||||
|
// next data bytes, skipping over file holes.
|
||||||
|
func (f *File) SeekData(oldOffset int64) (int64, error) {
|
||||||
|
if runtime.GOOS != "linux" {
|
||||||
|
// Does MacOS support something like this?
|
||||||
|
return 0, syscall.EOPNOTSUPP
|
||||||
|
}
|
||||||
|
const SEEK_DATA = 3
|
||||||
|
fd := f.intFd()
|
||||||
|
return syscall.Seek(fd, oldOffset, SEEK_DATA)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user