mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
32d506b394
full diff: https://github.com/moby/sys/compare/mountinfo/v0.1.3...mountinfo/v0.4.0 > Note that this dependency uses submodules, providing "github.com/moby/sys/mount" > and "github.com/moby/sys/mountinfo". Our vendoring tool (vndr) currently doesn't > support submodules, so we vendor the top-level moby/sys repository (which contains > both) and pick the most recent tag, which could be either `mountinfo/vXXX` or > `mount/vXXX`. github.com/moby/sys/mountinfo v0.4.0 -------------------------------------------------------------------------------- Breaking changes: - `PidMountInfo` is now deprecated and will be removed before v1.0; users should switch to `GetMountsFromReader` Fixes and improvements: - run filter after all fields are parsed - correct handling errors from bufio.Scan - documentation formatting fixes github.com/moby/sys/mountinfo v0.3.1 -------------------------------------------------------------------------------- - mount: use MNT_* flags from golang.org/x/sys/unix on freebsd - various godoc and CI fixes - mountinfo: make GetMountinfoFromReader Linux-specific - Add support for OpenBSD in addition to FreeBSD - mountinfo: use idiomatic naming for fields github.com/moby/sys/mountinfo v0.2.0 -------------------------------------------------------------------------------- Bug fixes: - Fix path unescaping for paths with double quotes Improvements: - Mounted: speed up by adding fast paths using openat2 (Linux-only) and stat - Mounted: relax path requirements (allow relative, non-cleaned paths, symlinks) - Unescape fstype and source fields - Documentation improvements Testing/CI: - Unit tests: exclude darwin - CI: run tests under Fedora 32 to test openat2 - TestGetMounts: fix for Ubuntu build system - Makefile: fix ignoring test failures - CI: add cross build github.com/moby/sys/mount v0.1.1 -------------------------------------------------------------------------------- https://github.com/moby/sys/releases/tag/mount%2Fv0.1.1 Improvements: - RecursiveUnmount: add a fast path (#26) - Unmount: improve doc - fix CI linter warning on Windows Testing/CI: - Unit tests: exclude darwin - Makefile: fix ignoring test failures - CI: add cross build Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
// +build freebsd,cgo openbsd,cgo
|
|
|
|
package mount
|
|
|
|
/*
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sys/_iovec.h>
|
|
#include <sys/mount.h>
|
|
#include <sys/param.h>
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"strings"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
func allocateIOVecs(options []string) []C.struct_iovec {
|
|
out := make([]C.struct_iovec, len(options))
|
|
for i, option := range options {
|
|
out[i].iov_base = unsafe.Pointer(C.CString(option))
|
|
out[i].iov_len = C.size_t(len(option) + 1)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func mount(device, target, mType string, flag uintptr, data string) error {
|
|
isNullFS := false
|
|
|
|
xs := strings.Split(data, ",")
|
|
for _, x := range xs {
|
|
if x == "bind" {
|
|
isNullFS = true
|
|
}
|
|
}
|
|
|
|
options := []string{"fspath", target}
|
|
if isNullFS {
|
|
options = append(options, "fstype", "nullfs", "target", device)
|
|
} else {
|
|
options = append(options, "fstype", mType, "from", device)
|
|
}
|
|
rawOptions := allocateIOVecs(options)
|
|
for _, rawOption := range rawOptions {
|
|
defer C.free(rawOption.iov_base)
|
|
}
|
|
|
|
if errno := C.nmount(&rawOptions[0], C.uint(len(options)), C.int(flag)); errno != 0 {
|
|
return &mountError{
|
|
op: "mount",
|
|
source: device,
|
|
target: target,
|
|
flags: flag,
|
|
err: syscall.Errno(errno),
|
|
}
|
|
}
|
|
return nil
|
|
}
|