MCPcopy
hub / github.com/google/gvisor / importFD

Method importFD

runsc/boot/loader.go:2120–2137  ·  view source on GitHub ↗

importFD generically imports a host file descriptor without adding it to any fd table.

(ctx context.Context, f *os.File)

Source from the content-addressed store, hash-verified

2118// importFD generically imports a host file descriptor without adding it to any
2119// fd table.
2120func (l *Loader) importFD(ctx context.Context, f *os.File) (*vfs.FileDescription, error) {
2121 hostFD, err := fd.NewFromFile(f)
2122 if err != nil {
2123 return nil, err
2124 }
2125 defer hostFD.Close()
2126 fd, err := host.NewFD(ctx, l.k.HostMount(), hostFD.FD(), &host.NewFDOptions{
2127 Savable: false, // We disconnect and close on save.
2128 IsTTY: false,
2129 VirtualOwner: false, // FD not visible to the sandboxed app so user can't be changed.
2130 })
2131
2132 if err != nil {
2133 return nil, err
2134 }
2135 hostFD.Release()
2136 return fd, nil
2137}
2138
2139func (l *Loader) containerCount() int {
2140 l.mu.Lock()

Callers 1

portForwardMethod · 0.95

Calls 5

NewFDFunction · 0.92
HostMountMethod · 0.80
CloseMethod · 0.65
FDMethod · 0.65
ReleaseMethod · 0.65

Tested by

no test coverage detected