importFD generically imports a host file descriptor without adding it to any fd table.
(ctx context.Context, f *os.File)
| 2118 | // importFD generically imports a host file descriptor without adding it to any |
| 2119 | // fd table. |
| 2120 | func (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 | |
| 2139 | func (l *Loader) containerCount() int { |
| 2140 | l.mu.Lock() |