Local filesystem paths
Local operations stay inside the selected volume directory. Symlinked volume roots and links that ultimately resolve inside that directory remain supported. Each operation pins its root so replacing the root path cannot redirect an operation already in progress. Go previously cleaned.. components before filesystem lookup. Paths where a symlink followed by .. would select a different destination now return an error. Use the destination explicitly:
.. paths remain supported. RemoveAll(ctx, ".") and RemoveAll(ctx, "") delete the local volume directory and its contents. If the root itself is a symlink, they unlink that root link and preserve its target, matching Go’s previous behavior. Descendant links never cause deletion outside the volume.
Functions
GetDefaultVolume()
FS(). The local backend returns ErrUnsupportedOperation; it never substitutes a directory from the caller’s machine.
Example
Example
CreateVolume()
Example
Example
*Volume with its name and host path. Configure the kind, quota, disk size, and labels with option functions. Returns ErrVolumeAlreadyExists if a volume with the given name already exists.
Parameters
ctxcontext.Contextnamestringopts…VolumeOptionReturns
Name and Path.GetVolume()
Example
Example
ErrVolumeNotFound if no such volume exists.
Parameters
ctxcontext.ContextnamestringReturns
ListVolumes()
Example
Example
Parameters
ctxcontext.ContextReturns
RemoveVolume()
Example
Example
Parameters
ctxcontext.ContextnamestringVolume
Returned by CreateVolume()
A named persistent volume.v.Name()
v.Path()
v.FS()
Example
Example
*VolumeFs for direct file operations. Local calls use the managed host directory; Cloud calls use the authenticated volume API.
Returns
v.Remove()
Example
Example
RemoveVolume(ctx, v.Name()).
VolumeHandle
Metadata reference for a named volume. Obtain viaGetVolume or ListVolumes.
Returned by GetVolume() · ListVolumes()
AVolumeHandle is the metadata reference returned by GetVolume and ListVolumes.
h.Name()
h.Path()
h.Kind()
VolumeKind.
Returns
h.QuotaMiB()
nil if unlimited.
h.UsedBytes()
h.CapacityBytes()
nil for directory volumes.
h.DiskFormat()
nil for directory volumes.
h.DiskFstype()
nil for directory volumes.
h.Labels()
h.CreatedAt()
time.Time value if unknown.
h.FS()
*VolumeFs for direct host-side file operations on this volume.
Returns
h.Remove()
RemoveVolume(ctx, h.Name()).
VolumeFs
Local operations follow paths through an opened volume directory, including symlink targets and missing parents. Paths that escape the volume returnErrPathEscape; valid in-volume symlinks remain usable.
Removing a final symlink unlinks the link itself. Remove(ctx, ".") and Remove(ctx, "") delete an empty root; RemoveAll also deletes its contents. After the root disappears, Exists returns false, nil, and Mkdir can recreate the root and missing parents.
Local OS failures retain *os.PathError and their native error number, so errors.Is checks against syscall.Errno and the standard os error predicates continue to work.
Local operations require the matching updated native SDK library; older libraries return ErrUnsupportedOperation with an upgrade instruction.
Returned by Volume.FS() · VolumeHandle.FS()
Host-side filesystem operations for a named volume.vfs.Root()
vfs.Read()
Parameters
relPathstringReturns
vfs.ReadString()
vfs.Write()
0o644.
Parameters
relPathstringdata[]bytevfs.WriteString()
0o644.
vfs.Mkdir()
0o755).
vfs.Remove()
vfs.RemoveAll()
vfs.Exists()
Returns
true if a file or directory exists at the path.Options
Functional options passed toCreateVolume, plus the Mount factory helpers that attach a volume, bind mount, tmpfs, or disk image to a sandbox via WithMounts.
WithVolumeKind()
VolumeKind. Defaults to VolumeKindDir.
Parameters
kindVolumeKindWithVolumeSize()
VolumeKindDisk.
Parameters
mebibytesuint32WithVolumeQuota()
Parameters
mebibytesuint32WithVolumeLabels()
Parameters
labelsmap[string]stringMount
Mount.Bind()
MountOptions.QuotaMiB to bound how much the guest may write beyond the host directory’s existing contents, overriding the runtime’s protective default. Returns a MountConfig for use with WithMounts.
Parameters
hostPathstringoptsMountOptionsExample
Example
Mount.Named()
Example
Example
CreateVolume). Returns a MountConfig.
Parameters
namestringoptsMountOptionsMount.NamedWith()
Example
Example
NamedVolumeOptions.Mode for accepted values; the default is "existing". Mode: "create" fails when the named volume already exists. Mode: "ensure-exists" creates the volume if it is missing and reuses a compatible existing volume. It errors when the existing volume has a different kind, quota, or capacity than requested.
It never mutates existing volume metadata.
Parameters
namestringoptsMountOptionsnamedOptsNamedVolumeOptionsMount.Tmpfs()
Example
Example
MountConfig.
Parameters
optsTmpfsOptionsMount.Disk()
Example
Example
MountConfig.
Parameters
hostPathstringoptsDiskOptionsMount.Owned()
Mount.Owned(OwnedVolumeOptions) for local storage allocated for one sandbox. It starts empty, survives stop/start and reboot, and is deleted with the sandbox. Owned mounts do not appear in ListVolumes() and cannot be shared or removed independently. Cloud rejects owned mounts.
OwnedVolumeOptions.Kind defaults to VolumeKindDir; QuotaMiB applies only to directories. VolumeKindDisk creates raw ext4 and requires positive SizeMiB. Common flags are Readonly, Noexec, Nosuid, and Nodev. StatVirtualization, HostPermissions, and Owner apply only to directories. No host path or volume name is accepted. Mounting over an existing image directory hides its contents without copying them.
MountConfig
Mount configuration produced by theMount factory.
Returned by Mount.Bind() · Mount.Named() · Mount.NamedWith() · Mount.Tmpfs() · Mount.Disk()
mount.Bind
string
Host path for bind mounts
mount.Named
string
Volume name for named mounts
mount.NamedMode
string
Provisioning mode for named mounts. See NamedVolumeOptions.Mode.
mount.NamedKind
string
Storage kind for provisioned named mounts. See VolumeKind.
mount.QuotaMiB
uint32
Quota in MiB for provisioned directory volumes
mount.Tmpfs
bool
Set for tmpfs mounts
mount.Disk
string
Host path for disk images
mount.Format
string
Disk format
mount.Fstype
string
Inner filesystem type
mount.Readonly
bool
Whether the mount is read-only
mount.Noexec
bool
Whether direct execution from the mount is disabled
mount.Nosuid
bool
Whether setuid/setgid elevation from files on the mount is ignored
mount.Nodev
bool
Whether device files on the mount are ignored
mount.SizeMiB
uint32
Size limit for tmpfs / capacity for provisioned disk volumes
mount.StatVirtualization
StatVirtualization
Per-mount stat-virtualization policy (bind / named only)
mount.HostPermissions
HostPermissions
Per-mount host-permission propagation policy (bind / named only)
mount.Owner
*MountOwner
Guest owner fallback for host files without a per-file stat override (bind / directory-backed named only)
mount.Kind()
Returns
MountKind
Types
ErrPathEscape
VolumeFs method when relPath is absolute, contains a .. sequence that resolves outside the volume root, or traverses a symlink outside the volume’s directory.
Returned by VolumeFs methods
VolumeConfig
The config struct populated byVolumeOption functions. Most callers go through CreateVolume(ctx, name, opts...); VolumeConfig is exported for callers that prefer to construct one directly.
Mutated by VolumeOption
VolumeOption
CreateVolume. Constructed by the WithVolume* helpers.
Used by CreateVolume()
VolumeKind
Used by VolumeConfig · WithVolumeKind() · VolumeHandle.Kind()
MountKind
mount.Kind().
Returned by MountConfig.Kind()
MountOptions
Tuning struct forMount.Bind, Mount.Named, and Mount.NamedWith. StatVirtualization, HostPermissions, and Owner are virtiofs-only; owner is rejected for disk-backed named volumes and when stat virtualization is off. Zero policy values preserve the conservative defaults (strict, private), while a nil owner keeps the runtime fallback identity.
Used by Mount.Bind() · Mount.Named() · Mount.NamedWith()
MountOwner
An inseparable guest ownership pair used byMountOptions.Owner. UID and GID may include zero; using a pointer to MountOwner keeps an unset owner distinct from root.
NamedVolumeOptions
Tunes sandbox-time named volume provisioning forMount.NamedWith.
Used by Mount.NamedWith()
TmpfsOptions
Tuning struct forMount.Tmpfs.
Used by Mount.Tmpfs()
DiskOptions
Tuning struct forMount.Disk.
Used by Mount.Disk()
OwnedVolumeOptions
Mount.Owned(). Kind defaults to VolumeKindDir; directory quota 0 means no quota. Disk storage requires positive SizeMiB.