Documentation
¶
Overview ¶
Package diskimages2 provides convenience wrappers around the generated DiskImages2 framework bindings. It offers a high-level Go API for disk image operations (attach, detach, create, resize, info) while delegating the low-level ObjC interop to the generated package.
Index ¶
- Variables
- func AttachSimple(path string, readOnly, autoMount bool) (bsdName string, err error)
- func Available() bool
- func CreateASIF(path string, sizeBytes int64) error
- func Detach(bsdName string) error
- func DetachHandle(h *DeviceHandle) error
- func Resize(path string, newSizeBytes int64) error
- type AttachOptions
- type AttachedDeviceInfo
- type DeviceHandle
- type ImageInfo
Constants ¶
This section is empty.
Variables ¶
ErrFrameworkUnavailable is returned when DiskImages2.framework cannot be loaded.
Functions ¶
func AttachSimple ¶
AttachSimple attaches a disk image using DICommonAttach's convenience method. Returns the BSD device name (e.g., "disk27").
func Available ¶
func Available() bool
Available reports whether DiskImages2.framework is loaded and usable.
func CreateASIF ¶
CreateASIF creates an Apple Sparse Image Format disk image at the given path. ASIF only allocates blocks on write (similar to QCOW2), making it efficient for VM disk images.
sizeBytes is the virtual size of the image. The on-disk size starts near zero and grows as data is written.
func Detach ¶
Detach detaches a previously attached disk image by BSD name. DiskImages2 does not expose a detach API; this calls hdiutil detach.
func DetachHandle ¶
func DetachHandle(h *DeviceHandle) error
DetachHandle detaches using an existing DeviceHandle, then releases it.
Types ¶
type AttachOptions ¶
AttachOptions configures disk image attachment behavior.
type AttachedDeviceInfo ¶
AttachedDeviceInfo describes a currently attached disk image.
func ListAttached ¶
func ListAttached() ([]AttachedDeviceInfo, error)
ListAttached returns info about all currently attached disk images.
type DeviceHandle ¶
type DeviceHandle struct {
BSDName string // e.g., "disk27"
RegEntryID uint64
// contains filtered or unexported fields
}
DeviceHandle represents an attached disk image device. Call DeviceHandle.Release to free the underlying ObjC handle.
func Attach ¶
func Attach(path string, opts AttachOptions) (*DeviceHandle, error)
Attach attaches a disk image at the given path using DIAttachParams. Returns a DeviceHandle with the BSD device name. The caller must call DeviceHandle.Release when done (or use DetachHandle).
func (*DeviceHandle) Release ¶
func (h *DeviceHandle) Release()
Release releases the underlying ObjC handle.
type ImageInfo ¶
type ImageInfo struct {
// Raw is the NSDictionary returned by retrieveInfoWithParams:,
// exposed as a map for callers that need framework-specific keys.
Raw map[string]string
}
ImageInfo contains metadata about a disk image file.
func RetrieveInfo ¶
RetrieveInfo returns metadata about a disk image file using DIImageInfoParams. The returned ImageInfo.Raw contains the NSDictionary keys as strings.