From fd53dfd2ad88d9d277e5ab93fba1b81a5f2255d4 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 29 May 2016 22:41:46 +0200 Subject: fusefronted: check Fstat return value on file create The Fstat call should never fail, but still, if it does return an error it should be handled properly. --- internal/fusefrontend/file.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'internal/fusefrontend/file.go') diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go index ce806b6..33afcb9 100644 --- a/internal/fusefrontend/file.go +++ b/internal/fusefrontend/file.go @@ -41,9 +41,13 @@ type file struct { header *contentenc.FileHeader } -func NewFile(fd *os.File, writeOnly bool, contentEnc *contentenc.ContentEnc) nodefs.File { +func NewFile(fd *os.File, writeOnly bool, contentEnc *contentenc.ContentEnc) (nodefs.File, fuse.Status) { var st syscall.Stat_t - syscall.Fstat(int(fd.Fd()), &st) + err := syscall.Fstat(int(fd.Fd()), &st) + if err != nil { + toggledlog.Warn.Printf("NewFile: Fstat on fd %d failed: %v\n", fd.Fd(), err) + return nil, fuse.ToStatus(err) + } wlock.register(st.Ino) return &file{ @@ -51,7 +55,7 @@ func NewFile(fd *os.File, writeOnly bool, contentEnc *contentenc.ContentEnc) nod writeOnly: writeOnly, contentEnc: contentEnc, ino: st.Ino, - } + }, fuse.OK } // intFd - return the backing file descriptor as an integer. Used for debug -- cgit v1.2.3