// Trace emits a trace event for the operation and file path to the trace log, // but only when $GODEBUG contains gofsystrace=1. // The traces are appended to the file named by the $GODEBUG setting gofsystracelog, or else standard error. // For debugging, if the $GODEBUG setting gofsystracestack is non-empty, then trace events for paths // matching that glob pattern (using path.Match) will be followed by a full stack trace. func Trace(op, path string) { … } var doTrace … var traceFile … var traceMu … var gofsystrace … var gofsystracelog … var gofsystracestack … func init() { … } var OverlayFile … type OverlayJSON … type node … func (n *node) isDir() bool { … } func (n *node) isDeleted() bool { … } var overlay … var cwd … // canonicalize a path for looking it up in the overlay. // Important: filepath.Join(cwd, path) doesn't always produce // the correct absolute path if path is relative, because on // Windows producing the correct absolute path requires making // a syscall. So this should only be used when looking up paths // in the overlay, or canonicalizing the paths in the overlay. func canonicalize(path string) string { … } // Init initializes the overlay, if one is being used. func Init(wd string) error { … } func initFromJSON(overlayJSON OverlayJSON) error { … } // IsDir returns true if path is a directory on disk or in the // overlay. func IsDir(path string) (bool, error) { … } // parentIsOverlayFile returns whether name or any of // its parents are files in the overlay, and the first parent found, // including name itself, that's a file in the overlay. func parentIsOverlayFile(name string) (string, bool) { … } var errNotDir … func nonFileInOverlayError(overlayPath string) error { … } // readDir reads a dir on disk, returning an error that is errNotDir if the dir is not a directory. // Unfortunately, the error returned by os.ReadDir if dir is not a directory // can vary depending on the OS (Linux, Mac, Windows return ENOTDIR; BSD returns EINVAL). func readDir(dir string) ([]fs.FileInfo, error) { … } // ReadDir provides a slice of fs.FileInfo entries corresponding // to the overlaid files in the directory. func ReadDir(dir string) ([]fs.FileInfo, error) { … } // OverlayPath returns the path to the overlaid contents of the // file, the empty string if the overlay deletes the file, or path // itself if the file is not in the overlay, the file is a directory // in the overlay, or there is no overlay. // It returns true if the path is overlaid with a regular file // or deleted, and false otherwise. func OverlayPath(path string) (string, bool) { … } // Open opens the file at or overlaid on the given path. func Open(path string) (*os.File, error) { … } func openFile(path string, flag int, perm os.FileMode) (*os.File, error) { … } // ReadFile reads the file at or overlaid on the given path. func ReadFile(path string) ([]byte, error) { … } // IsDirWithGoFiles reports whether dir is a directory containing Go files // either on disk or in the overlay. func IsDirWithGoFiles(dir string) (bool, error) { … } // walk recursively descends path, calling walkFn. Copied, with some // modifications from path/filepath.walk. func walk(path string, info fs.FileInfo, walkFn filepath.WalkFunc) error { … } // Walk walks the file tree rooted at root, calling walkFn for each file or // directory in the tree, including root. func Walk(root string, walkFn filepath.WalkFunc) error { … } // Lstat implements a version of os.Lstat that operates on the overlay filesystem. func Lstat(path string) (fs.FileInfo, error) { … } // Stat implements a version of os.Stat that operates on the overlay filesystem. func Stat(path string) (fs.FileInfo, error) { … } // overlayStat implements lstat or Stat (depending on whether os.Lstat or os.Stat is passed in). func overlayStat(path string, osStat func(string) (fs.FileInfo, error), opName string) (fs.FileInfo, error) { … } type fakeFile … func (f fakeFile) Name() string { … } func (f fakeFile) Size() int64 { … } func (f fakeFile) Mode() fs.FileMode { … } func (f fakeFile) ModTime() time.Time { … } func (f fakeFile) IsDir() bool { … } func (f fakeFile) Sys() any { … } func (f fakeFile) String() string { … } type missingFile … func (f missingFile) Name() string { … } func (f missingFile) Size() int64 { … } func (f missingFile) Mode() fs.FileMode { … } func (f missingFile) ModTime() time.Time { … } func (f missingFile) IsDir() bool { … } func (f missingFile) Sys() any { … } func (f missingFile) String() string { … } type fakeDir … func (f fakeDir) Name() string { … } func (f fakeDir) Size() int64 { … } func (f fakeDir) Mode() fs.FileMode { … } func (f fakeDir) ModTime() time.Time { … } func (f fakeDir) IsDir() bool { … } func (f fakeDir) Sys() any { … } func (f fakeDir) String() string { … } // Glob is like filepath.Glob but uses the overlay file system. func Glob(pattern string) (matches []string, err error) { … } // cleanGlobPath prepares path for glob matching. func cleanGlobPath(path string) string { … } func volumeNameLen(path string) int { … } // cleanGlobPathWindows is windows version of cleanGlobPath. func cleanGlobPathWindows(path string) (prefixLen int, cleaned string) { … } // glob searches for files matching pattern in the directory dir // and appends them to matches. If the directory cannot be // opened, it returns the existing matches. New matches are // added in lexicographical order. func glob(dir, pattern string, matches []string) (m []string, e error) { … } // hasMeta reports whether path contains any of the magic characters // recognized by filepath.Match. func hasMeta(path string) bool { … }