fsutil

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableCopyOnWrite added in v2.3.0

func DisableCopyOnWrite(dir string) error

DisableCopyOnWrite sets the No_COW attribute (`chattr +C`) on dir when dir is on btrfs, like libvirt does for new storage pools. Files created in dir afterwards inherit it, so in-place writes do not fragment VM disk images there. Files already in dir are not affected. On other filesystems, and with the environment variable LIMA_BTRFS_NOCOW=false, DisableCopyOnWrite does nothing.

func IsNFS

func IsNFS(path string) (bool, error)

IsNFS checks if the path is on NFS. If the path does not exist yet, it will walk up parent directories until one exists, or it hits '/' or '.'. Any other stat errors will cause IsNFS to fail.

func MatchCopyOnWrite added in v2.3.0

func MatchCopyOnWrite(dst, src string) error

MatchCopyOnWrite gives dst the No_COW attribute of src, or takes it away when src has none, if both are on btrfs. btrfs cannot reflink between files with and without the attribute, so the directory for a copy of an instance must follow the original, whatever LIMA_BTRFS_NOCOW says. When src is not on btrfs, dst gets what DisableCopyOnWrite gives a new directory.

func TranslateWindowsToWSLPath added in v2.3.0

func TranslateWindowsToWSLPath(orig string) (string, error)

TranslateWindowsToWSLPath translates a Windows path (e.g., C:\Users\...) to a WSL-compliant path (e.g., /mnt/c/Users/...).

func WarnIfFullCopy added in v2.3.0

func WarnIfFullCopy(dst, src string)

WarnIfFullCopy warns that copying src to dst will copy every block when both are on btrfs and only one of src and the directory of dst has the No_COW attribute: btrfs cannot reflink between them, and the copy functions do not report whether they made a reflink.

func WindowsSubsystemPath added in v2.2.0

func WindowsSubsystemPath(_ context.Context, _ string) (string, error)

WindowsSubsystemPath is the non-Windows stub for the Windows-only implementation in fsutil_windows.go.

func WindowsSubsystemPathForLinux added in v2.2.0

func WindowsSubsystemPathForLinux(_ context.Context, _, _ string) (string, error)

WindowsSubsystemPathForLinux is the non-Windows stub for the Windows-only implementation in fsutil_windows.go.

func WindowsSubsystemPathWithCygpath added in v2.2.0

func WindowsSubsystemPathWithCygpath(_ context.Context, _, _ string) (string, error)

WindowsSubsystemPathWithCygpath is the non-Windows stub for the Windows-only implementation in fsutil_windows.go.

func WriteFileAtomic added in v2.3.0

func WriteFileAtomic(path string, data []byte) error

WriteFileAtomic writes data to a temp file in path's directory and renames it onto path, so a reader sees the old file or the whole new one, never a partial write; the rename is atomic on Unix only. os.CreateTemp requests 0600, so the result is 0600 masked by the umask (0600 under a typical umask).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL