// MountedFast is a method of detecting a mount point without reading // mountinfo from procfs. A caller can only trust the result if no error // and sure == true are returned. Otherwise, other methods (e.g. parsing // /proc/mounts) have to be used. If unsure, use Mounted instead (which // uses MountedFast, but falls back to parsing mountinfo if needed). // // If a non-existent path is specified, an appropriate error is returned. // In case the caller is not interested in this particular error, it should // be handled separately using e.g. errors.Is(err, fs.ErrNotExist). // // This function is only available on Linux. When available (since kernel // v5.6), openat2(2) syscall is used to reliably detect all mounts. Otherwise, // the implementation falls back to using stat(2), which can reliably detect // normal (but not bind) mounts. func MountedFast(path string) (mounted, sure bool, err error) { … } // mountedByOpenat2 is a method of detecting a mount that works for all kinds // of mounts (incl. bind mounts), but requires a recent (v5.6+) linux kernel. func mountedByOpenat2(path string) (bool, error) { … } // mountedFast is similar to MountedFast, except it expects a normalized path. func mountedFast(path string) (mounted, sure bool, err error) { … } func mounted(path string) (bool, error) { … }