mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Move hostfs mount to Kernel struct.
This is needed to set up host fds passed through a Unix socket. Note that the host package depends on kernel, so we cannot set up the hostfs mount directly in Kernel.Init as we do for sockfs and pipefs. Also, adjust sockfs to make its setup look more like hostfs's and pipefs's. PiperOrigin-RevId: 308274053
This commit is contained in:
@@ -24,26 +24,12 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/syserror"
|
||||
)
|
||||
|
||||
// NewFilesystem creates a new sockfs filesystem.
|
||||
//
|
||||
// Note that there should only ever be one instance of sockfs.Filesystem,
|
||||
// backing a global socket mount.
|
||||
func NewFilesystem(vfsObj *vfs.VirtualFilesystem) *vfs.Filesystem {
|
||||
fs, _, err := filesystemType{}.GetFilesystem(nil, vfsObj, nil, "", vfs.GetFilesystemOptions{})
|
||||
if err != nil {
|
||||
panic("failed to create sockfs filesystem")
|
||||
}
|
||||
return fs
|
||||
}
|
||||
|
||||
// filesystemType implements vfs.FilesystemType.
|
||||
type filesystemType struct{}
|
||||
|
||||
// GetFilesystem implements FilesystemType.GetFilesystem.
|
||||
func (fsType filesystemType) GetFilesystem(_ context.Context, vfsObj *vfs.VirtualFilesystem, _ *auth.Credentials, _ string, _ vfs.GetFilesystemOptions) (*vfs.Filesystem, *vfs.Dentry, error) {
|
||||
fs := &filesystem{}
|
||||
fs.Init(vfsObj, fsType)
|
||||
return fs.VFSFilesystem(), nil, nil
|
||||
panic("sockfs.filesystemType.GetFilesystem should never be called")
|
||||
}
|
||||
|
||||
// Name implements FilesystemType.Name.
|
||||
@@ -60,6 +46,16 @@ type filesystem struct {
|
||||
kernfs.Filesystem
|
||||
}
|
||||
|
||||
// NewFilesystem sets up and returns a new sockfs filesystem.
|
||||
//
|
||||
// Note that there should only ever be one instance of sockfs.Filesystem,
|
||||
// backing a global socket mount.
|
||||
func NewFilesystem(vfsObj *vfs.VirtualFilesystem) *vfs.Filesystem {
|
||||
fs := &filesystem{}
|
||||
fs.Init(vfsObj, filesystemType{})
|
||||
return fs.VFSFilesystem()
|
||||
}
|
||||
|
||||
// inode implements kernfs.Inode.
|
||||
//
|
||||
// TODO(gvisor.dev/issue/1476): Add device numbers to this inode (which are
|
||||
|
||||
Reference in New Issue
Block a user