disk

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package disk provides helpers for managing macOS disk images via hdiutil.

It can query whether a disk image is currently attached, detach it safely with escalating retry strategies, and poll until a disk becomes available after a VM stops.

All operations shell out to hdiutil and diskutil; no cgo or framework bindings are required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDetached

func EnsureDetached(diskPath string) error

EnsureDetached detaches diskPath if it is currently attached. Returns nil immediately if the disk is not attached. On failure, returns an error with manual-fix instructions.

func FindAttachedDisk

func FindAttachedDisk(diskPath string) (device string, found bool, err error)

FindAttachedDisk checks whether diskPath is currently attached via hdiutil. If found, it returns the /dev/diskN device identifier. If the disk is not attached, found is false and err is nil. err is non-nil only when hdiutil info itself fails.

func StillAttached

func StillAttached(diskPath string) bool

StillAttached reports whether diskPath is currently attached.

func WaitForAvailable

func WaitForAvailable(diskPath string, timeout time.Duration) error

WaitForAvailable polls until diskPath is no longer attached, or timeout expires. This is useful after stopping a VM, since the VZ framework may hold the file handle briefly after the stop completes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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