9p: fix stat Length=0 for session files breaking 9pfuse reads
This commit is contained in:
parent
c4e1950f8c
commit
21b0cf1543
|
|
@ -1238,9 +1238,13 @@ func (s *Server) makeStat(path string) plan9.Dir {
|
|||
dir.Length = uint64(info.Size())
|
||||
}
|
||||
case strings.HasPrefix(path, fs.PathSessions):
|
||||
// Skip all session file size computation during stat/readdir.
|
||||
// Sizes are dynamic and some trigger expensive API calls.
|
||||
// Clients read the file to discover actual size.
|
||||
// HACK: 9pfuse trusts stat Length — if we report 0, the kernel
|
||||
// never issues a read. Compute size by reading the file content.
|
||||
if entry, err := s.openEntry(path); err == nil {
|
||||
if data, err := entry.Read(); err == nil {
|
||||
dir.Length = uint64(len(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in New Issue