Commit 46bf7a5b authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

fs: fix FileAllocater type assertion

The type assertion was meant to operate on `f.file`,
not on `n.ops` again.

Fixes xfstests generic/228.

Change-Id: I8f8ca0cead91a512a6d7826dd7e7e5d1887ae627
parent 32ac1d91
......@@ -811,7 +811,7 @@ func (b *rawBridge) Fallocate(cancel <-chan struct{}, input *fuse.FallocateIn) f
if a, ok := n.ops.(NodeAllocater); ok {
return errnoToStatus(a.Allocate(&fuse.Context{Caller: input.Caller, Cancel: cancel}, f.file, input.Offset, input.Length, input.Mode))
}
if a, ok := n.ops.(FileAllocater); ok {
if a, ok := f.file.(FileAllocater); ok {
return errnoToStatus(a.Allocate(&fuse.Context{Caller: input.Caller, Cancel: cancel}, input.Offset, input.Length, input.Mode))
}
return fuse.ENOTSUP
......
......@@ -39,6 +39,7 @@ var All = map[string]func(*testing.T, string){
"ReadDirPicksUpCreate": ReadDirPicksUpCreate,
"DirectIO": DirectIO,
"OpenAt": OpenAt,
"Fallocate": Fallocate,
}
func DirectIO(t *testing.T, mnt string) {
......@@ -600,3 +601,23 @@ func OpenAt(t *testing.T, mnt string) {
t.Error(err)
}
}
func Fallocate(t *testing.T, mnt string) {
rwFile, err := os.OpenFile(mnt+"/file", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666)
if err != nil {
t.Fatalf("OpenFile failed: %v", err)
}
defer rwFile.Close()
err = syscall.Fallocate(int(rwFile.Fd()), 0, 1024, 4096)
if err != nil {
t.Fatalf("Fallocate failed: %v", err)
}
fi, err := os.Lstat(mnt + "/file")
if err != nil {
t.Fatalf("Lstat failed: %v", err)
}
if fi.Size() < (1024 + 4096) {
t.Fatalf("fallocate should have changed file size. Got %d bytes",
fi.Size())
}
}
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