Documentation
¶
Index ¶
- func Abs(path string) (string, error)
- func CopyFile(from, to string, mode os.FileMode) (err error)
- func CopyFileAtomic(from, to string, mode os.FileMode) (err error)
- func EnsureFileWithPermission(fn string, mode os.FileMode) error
- func EvalRelative(path string, root string) string
- func FileHasOwner(f *os.File, uid uint32) bool
- func FindSize(size int64) string
- func FirstExistingParent(path string) (string, error)
- func ForceRemoveAll(path string) error
- func IsDir(name string) bool
- func IsExec(name string) bool
- func IsFile(name string) bool
- func IsGroup(name string, gid uint32) bool
- func IsLink(name string) bool
- func IsOwner(name string, uid uint32) bool
- func IsReadable(path string) bool
- func IsSuid(name string) bool
- func IsWritable(path string) bool
- func MakeTmpDir(basedir, pattern string, mode os.FileMode) (string, error)
- func MakeTmpFile(basedir, pattern string, mode os.FileMode) (*os.File, error)
- func Mkdir(path string, mode os.FileMode) error
- func MkdirAll(path string, mode os.FileMode) error
- func MkdirAllAt(rootPath, relPath string, mode os.FileMode) error
- func MkdirAt(rootPath, relPath string, mode os.FileMode) error
- func NewFileFromFd(fd int, name string) (*os.File, error)
- func OpenTrustedExecutable(name string, uid uint32) (int, string, error)
- func OpenTrustedFile(name string, uid uint32) (*os.File, error)
- func PathExists(path string) (bool, error)
- func PermWalk(root string, walkFn filepath.WalkFunc) error
- func PermWalkRaiseError(root string, walkFn filepath.WalkFunc) error
- func ProcFdPath(fd uintptr) string
- func RootDir(path string) string
- func Touch(path string) error
- func WriteFileNoFollow(path string, data []byte, mode os.FileMode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
CopyFile copies file to the provided location making sure the resulting file has permission bits set to the mode prior to umask. To honor umask correctly the resulting file must not exist.
func CopyFileAtomic ¶
CopyFileAtomic copies file to a temporary file in the same destination directory and the renames to the final name. This is useful to avoid races where concurrent copies could happen to the same destination. It makes sure the resulting file has permission bits set to the mode prior to umask. To honor umask correctly the resulting file must not exist.
func EnsureFileWithPermission ¶
EnsureFileWithPermission takes a file path, and 1. Creates it with the specified permission, or 2. ensures a file is the specified permission.
func EvalRelative ¶
EvalRelative evaluates symlinks in path relative to root path, it returns a path as if it was evaluated from chroot. This function always returns an absolute path and is intended to be used to resolve mount points destinations, it helps the runtime to not bind mount directories/files outside of the container image provided by the root argument.
func FileHasOwner ¶ added in v4.5.0
FileHasOwner checks if passed os.File is owned by user identified with uid.
func FindSize ¶
FindSize takes a size in bytes and converts it to a human-readable string representation expressing kB, MB, GB or TB (whatever is smaller, but still larger than one).
func FirstExistingParent ¶
FirstExistingParent walks up the supplied path and returns the first parent that exists. If the supplied path exists, it will just return that path. Assumes cwd and the root directory always exists
func ForceRemoveAll ¶
ForceRemoveAll removes a directory like os.RemoveAll, except that it will chmod any directory who's permissions are preventing the removal of contents
func IsReadable ¶
IsReadable returns true if the file that is passed in is readable by the user (note: uid is checked, not euid).
func IsWritable ¶
IsWritable returns true if the file that is passed in is writable by the user (note: uid is checked, not euid).
func MakeTmpDir ¶
MakeTmpDir creates a temporary directory with provided mode in os.TempDir if basedir is "". This function assumes that basedir exists, so it's the caller's responsibility to create it before calling it.
func MakeTmpFile ¶
MakeTmpFile creates a temporary file with provided mode in os.TempDir if basedir is "". This function assumes that basedir exists, so it's the caller's responsibility to create it before calling it.
func MkdirAll ¶
MkdirAll creates a directory and parents if it doesn't exist with mode after umask reset.
func MkdirAllAt ¶ added in v4.5.0
MkdirAllAt creates a directory and parents below rootPath using os.Root, with mode after umask reset. relPath must be local, and may not escape rootPath.
func MkdirAt ¶ added in v4.5.0
MkdirAt creates a directory below rootPath using os.Root, with mode after umask reset. relPath must be local, and may not escape rootPath.
func NewFileFromFd ¶ added in v4.5.0
NewFileFromFd wraps fd in an *os.File.
func OpenTrustedExecutable ¶ added in v4.5.0
OpenTrustedExecutable opens name without following a final symlink and returns a file descriptor path only if the opened file is owned by uid, is regular, is not writable by group or other, and has an executable bit set. The returned descriptor does not have close-on-exec set, so callers must close it when it is no longer needed or intentionally keep it open for a later exec.
func OpenTrustedFile ¶ added in v4.5.0
OpenTrustedFile opens name without following a final symlink and returns the open file only if it is owned by user identified with uid, is regular, and is not writable by group or other.
func PathExists ¶
PathExists simply checks if a path exists.
func PermWalk ¶
PermWalk is similar to filepath.Walk - but:
- The skipDir checks are removed (we never want to skip anything here)
- Our walk will call walkFn on a directory *before* attempting to look inside that directory.
func PermWalkRaiseError ¶
PermWalkRaiseError is similar to filepath.Walk - but:
- The skipDir checks are removed (we never want to skip anything here)
- Our walk will call walkFn on a directory *before* attempting to look inside that directory.
- We back out of the recursion at the *first* error... we don't attempt to go through as much as we can.
func ProcFdPath ¶ added in v4.5.0
ProcFdPath returns a /proc/self/fd path for fd.
func RootDir ¶
RootDir returns the root directory of path (rootdir of /my/path is /my). Returns "." if path is empty.
func WriteFileNoFollow ¶ added in v4.5.0
WriteFileNoFollow mimics fs.WriteFileNoFollow but with O_NOFOLLOW to avoid following symlinks in the last part of the path. This prevents e.g. creating a file through a dangling symlink.
Types ¶
This section is empty.