| 1 | // Package chroot provides functions to determine whether paths are inside a |
| 2 | // chroot and to make them relative to that chroot if so. |
| 3 | // |
| 4 | // In order for this package to work, you must chroot via the Chroot function |
| 5 | // provided via this package. |
| 6 | // |
| 7 | // All functions except Chroot are available on Windows but act as identity |
| 8 | // functions. |
| 9 | package chroot |
| 10 | |
| 11 | // Returns the "chroot anchor", the path under which the process has been |
| 12 | // chrooted. If the process has not been chrooted, this is "/". This can be |
| 13 | // used to obtain chroot-relative paths necessary to access files after |
| 14 | // chrooting. See Rel. |
| 15 | func Anchor() string { |
| 16 | return getAnchor() |
| 17 | } |
| 18 | |
| 19 | // path should be an absolute path. If, given the current Anchor, it can |
| 20 | // be accessed, returns the path which should be used to open the file given |
| 21 | // the current chroot and returns true. Otherwise returns false. |
| 22 | func Rel(path string) (chrootRelativePath string, canAddress bool) { |
| 23 | return rel(path) |
| 24 | } |