mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
[vfs2] Add FilesystemType.Release to avoid reference leaks.
Singleton filesystem like devpts and devtmpfs have a single filesystem shared among all mounts, so they acquire a "self-reference" when initialized that must be released when the entire virtual filesystem is released at sandbox exit. PiperOrigin-RevId: 336828852
This commit is contained in:
@@ -71,6 +71,15 @@ func (fst *FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virtua
|
||||
return fst.fs, fst.root, nil
|
||||
}
|
||||
|
||||
// Release implements vfs.FilesystemType.Release.
|
||||
func (fst *FilesystemType) Release(ctx context.Context) {
|
||||
if fst.fs != nil {
|
||||
// Release the original reference obtained when creating the filesystem.
|
||||
fst.root.DecRef(ctx)
|
||||
fst.fs.DecRef(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// Accessor allows devices to create device special files in devtmpfs.
|
||||
type Accessor struct {
|
||||
vfsObj *vfs.VirtualFilesystem
|
||||
|
||||
Reference in New Issue
Block a user