| 1 | //go:build !plan9 && !windows && !wasm |
| 2 | |
| 3 | package chroot |
| 4 | |
| 5 | type FileDescriptor interface { |
| 6 | Fd() (uintptr, bool) |
| 7 | } |
| 8 | |
| 9 | // Fd exposes the underlying [os.File.Fd] func, which returns the |
| 10 | // system file descriptor or handle referencing the open file. |
| 11 | // If the underlying Filesystem does not expose this func, |
| 12 | // the return will always be (0, false). |
| 13 | func (f *file) Fd() (uintptr, bool) { |
| 14 | fd, ok := f.File.(FileDescriptor) |
| 15 | if ok { |
| 16 | return fd.Fd() |
| 17 | } |
| 18 | return 0, false |
| 19 | } |