diff --git a/Makefile b/Makefile index 97151e5f..cd66db93 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ PACKAGES ?= mountinfo mount BINDIR ?= _build/bin CROSS ?= linux/arm linux/arm64 linux/ppc64le linux/s390x \ - freebsd/amd64 darwin/amd64 darwin/arm64 windows/amd64 + freebsd/amd64 openbsd/amd64 darwin/amd64 darwin/arm64 windows/amd64 .PHONY: all all: lint test cross diff --git a/mount/flags_freebsd.go b/mount/flags_bsd.go similarity index 97% rename from mount/flags_freebsd.go rename to mount/flags_bsd.go index a8840d4c..27d8440a 100644 --- a/mount/flags_freebsd.go +++ b/mount/flags_bsd.go @@ -1,4 +1,4 @@ -// +build freebsd +// +build freebsd openbsd package mount diff --git a/mount/mount_unix_test.go b/mount/mount_unix_test.go index 9b111f16..e2b37f62 100644 --- a/mount/mount_unix_test.go +++ b/mount/mount_unix_test.go @@ -1,4 +1,4 @@ -// +build !windows,!darwin +// +build !darwin,!windows package mount diff --git a/mount/mounter_freebsd.go b/mount/mounter_bsd.go similarity index 97% rename from mount/mounter_freebsd.go rename to mount/mounter_bsd.go index f4e2e0bb..656b762f 100644 --- a/mount/mounter_freebsd.go +++ b/mount/mounter_bsd.go @@ -1,4 +1,4 @@ -// +build freebsd cgo +// +build freebsd,cgo openbsd,cgo package mount diff --git a/mount/mounter_linux_test.go b/mount/mounter_linux_test.go index 9ba4857f..3dbcb77a 100644 --- a/mount/mounter_linux_test.go +++ b/mount/mounter_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package mount import ( diff --git a/mount/mounter_unsupported.go b/mount/mounter_unsupported.go index 41ac018a..e7ff5bd9 100644 --- a/mount/mounter_unsupported.go +++ b/mount/mounter_unsupported.go @@ -1,7 +1,7 @@ -// +build freebsd,!cgo +// +build !linux,!freebsd,!openbsd,!windows freebsd,!cgo openbsd,!cgo package mount func mount(device, target, mType string, flag uintptr, data string) error { - panic("cgo required on freebsd") + panic("cgo required on freebsd and openbsd") } diff --git a/mount/sharedsubtree_linux_test.go b/mount/sharedsubtree_linux_test.go index 1e2a053e..aa671d0c 100644 --- a/mount/sharedsubtree_linux_test.go +++ b/mount/sharedsubtree_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package mount import ( diff --git a/mountinfo/doc.go b/mountinfo/doc.go index ffac661f..2694d4c6 100644 --- a/mountinfo/doc.go +++ b/mountinfo/doc.go @@ -1,6 +1,6 @@ // Package mountinfo provides a set of functions to retrieve information about OS mounts. // -// Currently it supports Linux. For historical reasons, there is also some support for FreeBSD, +// Currently it supports Linux. For historical reasons, there is also some support for FreeBSD and OpenBSD, // and a shallow implementation for Windows, but in general this is Linux-only package, so // the rest of the document only applies to Linux, unless explicitly specified otherwise. // diff --git a/mountinfo/mounted_unix.go b/mountinfo/mounted_unix.go index c4d66b2f..efb03978 100644 --- a/mountinfo/mounted_unix.go +++ b/mountinfo/mounted_unix.go @@ -1,4 +1,4 @@ -// +build linux freebsd,cgo +// +build linux freebsd,cgo openbsd,cgo package mountinfo diff --git a/mountinfo/mountinfo_freebsd.go b/mountinfo/mountinfo_bsd.go similarity index 93% rename from mountinfo/mountinfo_freebsd.go rename to mountinfo/mountinfo_bsd.go index b30dc162..1d1484d4 100644 --- a/mountinfo/mountinfo_freebsd.go +++ b/mountinfo/mountinfo_bsd.go @@ -1,3 +1,5 @@ +// +build freebsd,cgo openbsd,cgo + package mountinfo /* @@ -54,7 +56,7 @@ func parseMountTable(filter FilterFunc) ([]*Info, error) { func mounted(path string) (bool, error) { // Fast path: compare st.st_dev fields. - // This should always work for FreeBSD. + // This should always work for FreeBSD and OpenBSD. mounted, err := mountedByStat(path) if err == nil { return mounted, nil diff --git a/mountinfo/mountinfo_linux.go b/mountinfo/mountinfo_linux.go index fd4fb341..f76b26c8 100644 --- a/mountinfo/mountinfo_linux.go +++ b/mountinfo/mountinfo_linux.go @@ -1,5 +1,3 @@ -// +build go1.13 - package mountinfo import ( diff --git a/mountinfo/mountinfo_linux_test.go b/mountinfo/mountinfo_linux_test.go index b77fb571..5f4133fb 100644 --- a/mountinfo/mountinfo_linux_test.go +++ b/mountinfo/mountinfo_linux_test.go @@ -1,5 +1,3 @@ -// +build linux - package mountinfo import ( diff --git a/mountinfo/mountinfo_unsupported.go b/mountinfo/mountinfo_unsupported.go index b9acfbdc..d33ebca0 100644 --- a/mountinfo/mountinfo_unsupported.go +++ b/mountinfo/mountinfo_unsupported.go @@ -1,4 +1,4 @@ -// +build !windows,!linux,!freebsd freebsd,!cgo +// +build !windows,!linux,!freebsd,!openbsd freebsd,!cgo openbsd,!cgo package mountinfo