commit d3de47eaee8cb7d47e1ffb680def68c90318d5be
parent 3d15558b381b83dad24ec184e1d98467d2fe4632
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 29 Nov 2023 09:24:11 +0900
check wstat and newStat is the same
Diffstat:
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/server.go b/server.go
@@ -824,10 +824,14 @@ func sWStat(ctx context.Context, s *Server, r *Req) {
return
}
newStat := fi.Sys().(*Stat)
- if wstat.Type != ^uint16(0) || wstat.Dev != ^uint32(0) ||
- wstat.Qid.Type != QidType(^uint8(0)) || wstat.Qid.Vers != ^uint32(0) ||
- wstat.Qid.Path != ^uint64(0) || wstat.Atime != ^uint32(0) ||
- wstat.Uid != "" || wstat.Muid != "" {
+ if wstat.Type != ^uint16(0) && wstat.Type != newStat.Type ||
+ wstat.Dev != ^uint32(0) && wstat.Dev != newStat.Dev ||
+ wstat.Qid.Type != QidType(^uint8(0)) && wstat.Qid.Type != newStat.Qid.Type ||
+ wstat.Qid.Vers != ^uint32(0) && wstat.Qid.Vers != newStat.Qid.Vers ||
+ wstat.Qid.Path != ^uint64(0) && wstat.Qid.Path != newStat.Qid.Path ||
+ wstat.Atime != ^uint32(0) && wstat.Atime != newStat.Atime ||
+ wstat.Uid != "" && wstat.Uid != newStat.Uid ||
+ wstat.Muid != "" && wstat.Muid != newStat.Muid {
Respond(ctx, r, fmt.Errorf("operation not permitted"))
return
}
@@ -861,14 +865,14 @@ func sWStat(ctx context.Context, s *Server, r *Req) {
}
newStat.Name = wstat.Name
}
- if wstat.Length != ^int64(0) {
+ if wstat.Length != ^int64(0) && wstat.Length != newStat.Length {
if fi.IsDir() || !hasPerm(r.Fid.File, r.Fid.Uid, AWRITE) {
Respond(ctx, r, ErrPerm)
return
}
newStat.Length = wstat.Length
}
- if wstat.Mode != FileMode(^uint32(0)) {
+ if wstat.Mode != FileMode(^uint32(0)) && wstat.Mode != newStat.Mode {
// the owner of the file or the group leader of the file's group.
if r.Fid.Uid != newStat.Uid && r.Fid.Uid != newStat.Gid {
Respond(ctx, r, ErrPerm)
@@ -880,7 +884,7 @@ func sWStat(ctx context.Context, s *Server, r *Req) {
}
newStat.Mode = wstat.Mode
}
- if wstat.Mtime != ^uint32(0) {
+ if wstat.Mtime != ^uint32(0) && wstat.Mtime != newStat.Mtime {
// the owner of the file or the group leader of the file's group.
if r.Fid.Uid != newStat.Uid && r.Fid.Uid != newStat.Gid {
Respond(ctx, r, ErrPerm)
@@ -888,7 +892,7 @@ func sWStat(ctx context.Context, s *Server, r *Req) {
}
newStat.Mtime = wstat.Mtime
}
- if wstat.Gid != "" {
+ if wstat.Gid != "" && wstat.Gid != newStat.Gid {
// TODO implement
Respond(ctx, r, fmt.Errorf("not implemented"))
return