Skip to content

Commit

Permalink
Merge pull request #32 from thaJeztah/mountinfo_bsd
Browse files Browse the repository at this point in the history
Add support for OpenBSD in addition to FreeBSD
  • Loading branch information
kolyshkin authored Oct 1, 2020
2 parents 832ae17 + cb807b1 commit 9fe7f4e
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mount/flags_freebsd.go → mount/flags_bsd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build freebsd
// +build freebsd openbsd

package mount

Expand Down
2 changes: 1 addition & 1 deletion mount/mount_unix_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !windows,!darwin
// +build !darwin,!windows

package mount

Expand Down
2 changes: 1 addition & 1 deletion mount/mounter_freebsd.go → mount/mounter_bsd.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build freebsd cgo
// +build freebsd,cgo openbsd,cgo

package mount

Expand Down
2 changes: 0 additions & 2 deletions mount/mounter_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build linux

package mount

import (
Expand Down
4 changes: 2 additions & 2 deletions mount/mounter_unsupported.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 0 additions & 2 deletions mount/sharedsubtree_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build linux

package mount

import (
Expand Down
2 changes: 1 addition & 1 deletion mountinfo/doc.go
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down
2 changes: 1 addition & 1 deletion mountinfo/mounted_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build linux freebsd,cgo
// +build linux freebsd,cgo openbsd,cgo

package mountinfo

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build freebsd,cgo openbsd,cgo

package mountinfo

/*
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions mountinfo/mountinfo_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build go1.13

package mountinfo

import (
Expand Down
2 changes: 0 additions & 2 deletions mountinfo/mountinfo_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// +build linux

package mountinfo

import (
Expand Down
2 changes: 1 addition & 1 deletion mountinfo/mountinfo_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !windows,!linux,!freebsd freebsd,!cgo
// +build !windows,!linux,!freebsd,!openbsd freebsd,!cgo openbsd,!cgo

package mountinfo

Expand Down

0 comments on commit 9fe7f4e

Please sign in to comment.