Skip to content

Commit cb807b1

Browse files
committed
Add support for OpenBSD in addition to FreeBSD
I am looking at using these modules in containerd, so that we can reduce the effort of maintaining "mountinfo" implementations. The containerd variant of this module currently supports OpenBSD in addition to FreeBSD. This patch bring in changes similar to the ones made in containerd in: containerd/containerd@0828b7a Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 832ae17 commit cb807b1

13 files changed

Lines changed: 12 additions & 18 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PACKAGES ?= mountinfo mount
33
BINDIR ?= _build/bin
44
CROSS ?= linux/arm linux/arm64 linux/ppc64le linux/s390x \
5-
freebsd/amd64 darwin/amd64 darwin/arm64 windows/amd64
5+
freebsd/amd64 openbsd/amd64 darwin/amd64 darwin/arm64 windows/amd64
66

77
.PHONY: all
88
all: lint test cross
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build freebsd
1+
// +build freebsd openbsd
22

33
package mount
44

mount/mount_unix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !windows,!darwin
1+
// +build !darwin,!windows
22

33
package mount
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build freebsd cgo
1+
// +build freebsd,cgo openbsd,cgo
22

33
package mount
44

mount/mounter_linux_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
package mount
42

53
import (

mount/mounter_unsupported.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// +build freebsd,!cgo
1+
// +build !linux,!freebsd,!openbsd,!windows freebsd,!cgo openbsd,!cgo
22

33
package mount
44

55
func mount(device, target, mType string, flag uintptr, data string) error {
6-
panic("cgo required on freebsd")
6+
panic("cgo required on freebsd and openbsd")
77
}

mount/sharedsubtree_linux_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// +build linux
2-
31
package mount
42

53
import (

mountinfo/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package mountinfo provides a set of functions to retrieve information about OS mounts.
22
//
3-
// Currently it supports Linux. For historical reasons, there is also some support for FreeBSD,
3+
// Currently it supports Linux. For historical reasons, there is also some support for FreeBSD and OpenBSD,
44
// and a shallow implementation for Windows, but in general this is Linux-only package, so
55
// the rest of the document only applies to Linux, unless explicitly specified otherwise.
66
//

mountinfo/mounted_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build linux freebsd,cgo
1+
// +build linux freebsd,cgo openbsd,cgo
22

33
package mountinfo
44

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build freebsd,cgo openbsd,cgo
2+
13
package mountinfo
24

35
/*
@@ -54,7 +56,7 @@ func parseMountTable(filter FilterFunc) ([]*Info, error) {
5456

5557
func mounted(path string) (bool, error) {
5658
// Fast path: compare st.st_dev fields.
57-
// This should always work for FreeBSD.
59+
// This should always work for FreeBSD and OpenBSD.
5860
mounted, err := mountedByStat(path)
5961
if err == nil {
6062
return mounted, nil

0 commit comments

Comments
 (0)