Commit 41672d15 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: by default return input offset for Lseek

parent 1ee3533f
......@@ -21,3 +21,9 @@ func ToErrno(err error) syscall.Errno {
// RENAME_EXCHANGE is a flag argument for renameat2()
const RENAME_EXCHANGE = 0x2
// seek to the next data
const _SEEK_DATA = 3
// seek to the next hole
const _SEEK_HOLE = 4
......@@ -195,10 +195,16 @@ func (n *OperationStubs) CopyFileRange(ctx context.Context, fhIn FileHandle,
return 0, syscall.EROFS
}
// Lseek is called for seeking to and beyond holes. By default, it
// returns the input offset unchanged.
func (n *OperationStubs) Lseek(ctx context.Context, f FileHandle, off uint64, whence uint32) (uint64, syscall.Errno) {
if f != nil {
return f.Lseek(ctx, off, whence)
}
if whence == _SEEK_DATA || whence == _SEEK_HOLE {
return off, OK
}
return 0, syscall.ENOTSUP
}
......
......@@ -81,9 +81,7 @@ func TestDirectIO(t *testing.T) {
t.Errorf("got %q want %q", got, want)
}
const SEEK_DATA = 3 /* seek to the next data */
if n, err := syscall.Seek(int(f.Fd()), 512, SEEK_DATA); err != nil {
if n, err := syscall.Seek(int(f.Fd()), 512, _SEEK_DATA); err != nil {
t.Errorf("Seek: %v", err)
} else if n != 1024 {
t.Errorf("seek: got %d, want %d", n, 1024)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment