mount: support truncate properly
This commit is contained in:
parent
3fb4fe31d2
commit
dc1c679c65
1 changed files with 10 additions and 7 deletions
|
@ -42,17 +42,20 @@ func (f *File) Attr(ctx context.Context, a *fuse.Attr) (err error) {
|
||||||
// Check interface satisfied
|
// Check interface satisfied
|
||||||
var _ fusefs.NodeSetattrer = (*File)(nil)
|
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) {
|
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)
|
defer fs.Trace(f, "a=%+v", req)("err=%v", &err)
|
||||||
if f.VFS().Opt.NoModTime {
|
if !f.VFS().Opt.NoModTime {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if req.Valid.MtimeNow() {
|
if req.Valid.MtimeNow() {
|
||||||
err = f.File.SetModTime(time.Now())
|
err = f.File.SetModTime(time.Now())
|
||||||
} else if req.Valid.Mtime() {
|
}
|
||||||
|
if req.Valid.Mtime() {
|
||||||
err = f.File.SetModTime(req.Mtime)
|
err = f.File.SetModTime(req.Mtime)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if req.Valid.Size() {
|
||||||
|
err = f.File.Truncate(int64(req.Size))
|
||||||
|
}
|
||||||
return translateError(err)
|
return translateError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue