2023-06-28 17:36:33 +08:00
|
|
|
package overlay
|
|
|
|
|
|
|
|
import (
|
|
|
|
//"fmt"
|
|
|
|
//"os"
|
|
|
|
//"path/filepath"
|
|
|
|
//"strings"
|
|
|
|
//"syscall"
|
|
|
|
"errors"
|
|
|
|
|
2025-08-29 20:55:12 +08:00
|
|
|
//"go.podman.io/storage/pkg/unshare"
|
2023-06-28 17:36:33 +08:00
|
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
|
|
|
)
|
|
|
|
|
2024-11-07 06:18:14 +08:00
|
|
|
// MountWithOptions returns a specs.Mount which makes the contents of ${source}
|
|
|
|
// visible at ${dest} in the container.
|
|
|
|
// Options allows the caller to configure whether or not the mount should be
|
|
|
|
// read-only.
|
|
|
|
// This API is used by podman.
|
2023-06-28 17:36:33 +08:00
|
|
|
func MountWithOptions(contentDir, source, dest string, opts *Options) (mount specs.Mount, Err error) {
|
2023-12-13 01:18:20 +08:00
|
|
|
if opts == nil {
|
|
|
|
opts = &Options{}
|
|
|
|
}
|
2023-06-28 17:36:33 +08:00
|
|
|
if opts.ReadOnly {
|
|
|
|
// Read-only overlay mounts can be simulated with nullfs
|
|
|
|
mount.Source = source
|
|
|
|
mount.Destination = dest
|
|
|
|
mount.Type = "nullfs"
|
|
|
|
mount.Options = []string{"ro"}
|
|
|
|
return mount, nil
|
|
|
|
} else {
|
|
|
|
return mount, errors.New("read/write overlay mounts not supported on freebsd")
|
|
|
|
}
|
|
|
|
}
|