hugelgupf / p9

Idiomatic Go 9P2000.L client and server, extracted from gVisor for general use
Apache License 2.0
90 stars 19 forks source link

composefs: never return the mounted p9.File #79

Closed hugelgupf closed 1 year ago

hugelgupf commented 1 year ago

Always return a clone, so the "original" mounted File remains avaiable for Walks.

@djdv your comment got me thinking (sorry I should have waited a bit before merging, heh). I made the original change because one of the tests in composefs had this issue:

=== RUN   TestFilesMatch/file-localfs/somefile                                                                                                                             
    filetest.go:179: Walk(localfs/somefile) failed: stat /tmp/TestFilesMatch3250066062/001: use of closed file

But really, that was an issue with composefs. Close should mean the p9.File is not used anymore, so any l.file gymnastics should be unnecessary. (Maybe this will change with whatever we do for #62, since we do retain references to parents, but this is how it currently is.)