mounts

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 12 Imported by: 0 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

Overview

Package mounts is what a project's VM is given of this machine: the project, and the entries of ~/.agent-vm/volumes, each checked first.

Index

Constants

View Source
const SelfRef = "agent-vm itself"

SelfRef is the What of the Ref to agent-vm's own folder.

Variables

View Source
var BaseNames = []string{".git", ".hg", ".sl", ".jj"}

BaseNames are always read-only in every share. .hg: Mercurial runs the hooks of .hg/hgrc in a repository the user owns, which files written through a share are. .sl (Sapling) and .jj (Jujutsu) keep a repository's config, which names commands to run, in the same way. .lfsconfig is not one: git-lfs reads only a few URL and filter keys from it, no command.

Functions

func CacheOn

func CacheOn() bool

CacheOn is sshfs's cache mode asked from the shell: on with AGENT_VM_SSHFS_CACHE=1, never from the project. With it, a file the host adds, deletes or extends shows as it was for up to 20 seconds, and an agent writing back what it read would undo the host's change; it is off on the writable shares otherwise.

func CredentialLocation

func CredentialLocation(dir string, refs []Ref) (string, bool)

CredentialLocation says why dir must not be shared with a VM: it is, contains or is inside a folder of credentials or applications' data under the home folder (see credentialRel), found in refs. Those folders resolved through their links count too, as dir does.

func GitDirShare

func GitDirShare(dir string) (string, bool)

GitDirShare says why dir must not be a writable share: it is, or is inside, a repository's own folder: a .git or .hg (by name, as the SFTP server matches them), or a bare repository (HEAD, objects/ and refs/, as git finds one). The read-only names apply below a share's root, so such a share would be writable whole, hooks and config included.

func Matches

func Matches(filter, dir, home string, warn io.Writer) bool

Matches reports whether the project dir matches filter, the 4th field of a volumes entry: a path, ~ expanded, where * matches anything, / included (and ? and [...] as the shell has them). A filter that is not absolute matches nothing, with a warning; ~user is not expanded.

func ProjectMountpoint

func ProjectMountpoint(dir, rel, src string, warn io.Writer) (string, bool)

ProjectMountpoint makes, on the host, the mount point of a relative destination rel, inside the project dir: a folder, or an empty file for a file source src. virtiofs and 9p make mount points before the project is mounted, and --readonly refuses the guest's write. No component may be ".." or a symlink: the agent can write the project. Made without following links (env.MkdirIn), since the VM could swap one in after the check.

func RWDirs

func RWDirs(entries []Entry) []string

RWDirs are the folders of entries the VM can write besides the project: shares that are rw and directories.

func Stage

func Stage(src, dst string, warn io.Writer) bool

Stage puts src at dst by a hardlink, which keeps it in step with the host (same inode) without sharing its folder; by a copy when they are on two file systems, with a warning: then changes reach the VM on its next start.

func UnderName

func UnderName(rel string, names []string) bool

UnderName reports whether the relative path rel goes through one of names (BaseNames when nil), matched as the SFTP server does: per component, whatever the case.

func Unmountable

func Unmountable(dir string) (string, bool)

Unmountable says why Lima cannot be given dir as a share: with whitespace the mount fails silently, leaving a bare, root-owned mount point; a quote, a backslash or a control character are refused as 0.2 refused them; and what Lima would read as another path (Unwritable).

func UnsafeLocation

func UnsafeLocation(dir string, refs []Ref) (string, bool)

UnsafeLocation says why dir must not be shared with a VM, writable or not, when it is or contains the home folder, or is, contains or is inside one of the other refs. A project inside the home folder is what is expected. Compared as physical paths, whatever the case where the file system ignores it.

func UnsafeProject

func UnsafeProject(dir string, refs []Ref) (string, bool)

UnsafeProject says why the project dir must not be shared: see UnsafeLocation, CredentialLocation and GitDirShare.

func Unwritable

func Unwritable(s string) (string, bool)

Unwritable says why s cannot go into Lima's config as written: Lima expands Go templates in share paths ({{.Home}} is the home folder), and a byte that is not UTF-8 becomes U+FFFD on the way.

Types

type Entry

type Entry struct {
	Src  string // ~ expanded, existing
	Dst  string // absolute and normalized, relative as written, or "" for Src's own path
	Mode string // "ro" or "rw"
	Line string // source:destination:mode, for messages
}

Entry is a usable line of ~/.agent-vm/volumes.

func Entries

func Entries(file, dir, home string, refs []Ref, warn io.Writer) []Entry

Entries are the entries of the volumes file for the project dir: source[:destination][:ro|rw[:project]], ro by default. One that cannot be used is skipped, with a warning on warn. Nothing is created here.

type FileMount

type FileMount struct {
	Src, Staging, BindSrc, BindDst string
}

FileMount is a single file of ~/.agent-vm/volumes: hardlinked into a staging folder of its own, which is shared, then bound in place in the VM (BindSrc onto BindDst), so the VM never sees the file's folder.

func Build

func Build(s Shares) ([]vm.Mount, []FileMount)

Build is the shares of the project's VM: the project first, then the entries, read-only unless rw (and never writable under --readonly: a writable volume holding the project would be a second way to write it).

func (FileMount) Line

func (f FileMount) Line() string

Line is how the state folder records it, as 0.2 did.

type Ref

type Ref struct {
	What string // "your home directory", ...
	Path string // physical, folded
}

Ref is a location no share may reach.

func Refs

func Refs(home, self, state string, limaHomes ...string) []Ref

Refs are the locations no share may reach: the home folder (dotfiles, SSH keys, every other project), agent-vm itself (the host runs its files), agent-vm's state (every VM's env) and Lima's homes, agent-vm's and the user's own (the VMs' SSH key and disks, its _config adding mounts to every VM).

type Shares

type Shares struct {
	VM       string
	Dir      string // the project
	Writable bool   // false for --readonly, every share
	// Names are read-only on every share (none with .git left writable).
	// Every share is served by the builtin SFTP server: the one confined to
	// its folder (vm.Confined).
	Names    []string
	Entries  []Entry // see Entries
	StateDir string  // where single files are staged
	Warn     io.Writer
}

Shares is what Build is given.

Jump to

Keyboard shortcuts

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