mount: support truncate properly

This commit is contained in:
Nick Craig-Wood 2017-11-20 19:42:35 +00:00
parent 3fb4fe31d2
commit dc1c679c65

View file

@ -42,17 +42,20 @@ func (f *File) Attr(ctx context.Context, a *fuse.Attr) (err error) {
// Check interface satisfied
var _ fusefs.NodeSetattrer = (*File)(nil)
// Setattr handles attribute changes from FUSE. Currently supports ModTime only.
// Setattr handles attribute changes from FUSE. Currently supports ModTime and Size only
func (f *File) Setattr(ctx context.Context, req *fuse.SetattrRequest, resp *fuse.SetattrResponse) (err error) {
defer fs.Trace(f, "a=%+v", req)("err=%v", &err)
if f.VFS().Opt.NoModTime {
return nil
}
if !f.VFS().Opt.NoModTime {
if req.Valid.MtimeNow() {
err = f.File.SetModTime(time.Now())
} else if req.Valid.Mtime() {
}
if req.Valid.Mtime() {
err = f.File.SetModTime(req.Mtime)
}
}
if req.Valid.Size() {
err = f.File.Truncate(int64(req.Size))
}
return translateError(err)
}