$OpenBSD: patch-vendor_github_com_moby_sys_mount_mounter_openbsd_go,v 1.1 2021/01/04 14:15:21 solene Exp $

Index: vendor/github.com/moby/sys/mount/mounter_openbsd.go
--- vendor/github.com/moby/sys/mount/mounter_openbsd.go.orig
+++ vendor/github.com/moby/sys/mount/mounter_openbsd.go
@@ -0,0 +1,65 @@
+// +build openbsd,cgo
+
+package mount
+
+/*
+#include <sys/types.h>
+#include <sys/mount.h>
+*/
+import "C"
+
+import (
+	"fmt"
+	"syscall"
+	"unsafe"
+)
+
+func createExportInfo(readOnly bool) C.struct_export_args {
+	exportFlags := C.int(0)
+	if readOnly {
+		exportFlags = C.MNT_EXRDONLY
+	}
+	out := C.struct_export_args{
+		ex_root:  0,
+		ex_flags: exportFlags,
+	}
+	return out
+}
+
+func createUfsArgs(device string, readOnly bool) unsafe.Pointer {
+	out := &C.struct_ufs_args{
+		fspec:       C.CString(device),
+		export_info: createExportInfo(readOnly),
+	}
+	return unsafe.Pointer(out)
+}
+
+func mount(device, target, mType string, flag uintptr, data string) error {
+	readOnly := flag&RDONLY == 1
+
+	var fsArgs unsafe.Pointer
+
+	if mType == "ffs" {
+		fsArgs = createUfsArgs(device, readOnly)
+	} else {
+		return &mountError{
+			op:     "mount",
+			source: device,
+			target: target,
+			flags:  flag,
+			err:    fmt.Errorf("unsupported type"),
+		}
+	}
+
+	if errno := C.mount(C.CString(mType), C.CString(target), C.int(flag), fsArgs); errno != 0 {
+		return &mountError{
+			op:     "mount",
+			source: device,
+			target: target,
+			flags:  flag,
+			err:    syscall.Errno(errno),
+		}
+	}
+
+	return nil
+}
