diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-01-05 20:09:35 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-01-05 20:09:35 +0900 |
| commit | e2489059c103800ab62250351db895415e0cdfed (patch) | |
| tree | bc09c183d938adddc578145204d1eea115d1ec2c /helper/bwrap/config.set.go | |
| parent | 2e3f6a4c5194e2f571f488e81cd1511fe3fbba48 (diff) | |
helper/bwrap: implement overlayfs builder
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'helper/bwrap/config.set.go')
| -rw-r--r-- | helper/bwrap/config.set.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/helper/bwrap/config.set.go b/helper/bwrap/config.set.go index ca2f8554..8cbafda3 100644 --- a/helper/bwrap/config.set.go +++ b/helper/bwrap/config.set.go @@ -96,6 +96,31 @@ func (c *Config) Tmpfs(dest string, size int, perm ...os.FileMode) *Config { return c } +// Overlay mount overlayfs on DEST, with writes going to an invisible tmpfs +// (--tmp-overlay DEST) +func (c *Config) Overlay(dest string, src ...string) *Config { + c.Filesystem = append(c.Filesystem, &OverlayConfig{Src: src, Dest: dest}) + return c +} + +// Join mount overlayfs read-only on DEST +// (--ro-overlay DEST) +func (c *Config) Join(dest string, src ...string) *Config { + c.Filesystem = append(c.Filesystem, &OverlayConfig{Src: src, Dest: dest, Persist: new([2]string)}) + return c +} + +// Persist mount overlayfs on DEST, with RWSRC as the host path for writes and +// WORKDIR an empty directory on the same filesystem as RWSRC +// (--overlay RWSRC WORKDIR DEST) +func (c *Config) Persist(dest, rwsrc, workdir string, src ...string) *Config { + if rwsrc == "" || workdir == "" { + panic("persist called without required paths") + } + c.Filesystem = append(c.Filesystem, &OverlayConfig{Src: src, Dest: dest, Persist: &[2]string{rwsrc, workdir}}) + return c +} + // Mqueue mount new mqueue in sandbox // (--mqueue DEST) func (c *Config) Mqueue(dest string) *Config { |
