Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD fixes for pkg/mount #1219

Merged
merged 2 commits into from Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 3 additions & 13 deletions drivers/zfs/zfs_freebsd.go
Expand Up @@ -2,7 +2,6 @@ package zfs

import (
"fmt"
"strings"

"github.com/containers/storage/drivers"
"github.com/pkg/errors"
Expand All @@ -26,19 +25,10 @@ func checkRootdirFs(rootdir string) error {
}

func getMountpoint(id string) string {
maxlen := 12

// we need to preserve filesystem suffix
suffix := strings.SplitN(id, "-", 2)

if len(suffix) > 1 {
return id[:maxlen] + "-" + suffix[1]
}

return id[:maxlen]
return id
}

func detachUnmount(mountpoint string) error {
// FreeBSD doesn't have an equivalent to MNT_DETACH
return unix.Unmount(mountpoint, 0)
// FreeBSD's MNT_FORCE is roughly equivalent to MNT_DETACH
return unix.Unmount(mountpoint, unix.MNT_FORCE)
}
3 changes: 2 additions & 1 deletion pkg/mount/flags_freebsd.go
Expand Up @@ -27,6 +27,8 @@ const (
// NOATIME will not update the file access time when reading from a file.
NOATIME = unix.MNT_NOATIME

mntDetach = unix.MNT_FORCE

NODIRATIME = 0
NODEV = 0
DIRSYNC = 0
Expand All @@ -43,5 +45,4 @@ const (
RSHARED = 0
RELATIME = 0
STRICTATIME = 0
mntDetach = 0
)
21 changes: 16 additions & 5 deletions pkg/mount/mounter_freebsd.go
Expand Up @@ -28,14 +28,25 @@ func allocateIOVecs(options []string) []C.struct_iovec {
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 data != "" {
xs := strings.Split(data, ",")
for _, x := range xs {
if x == "bind" {
isNullFS = true
continue
}
opt := strings.SplitN(x, "=", 2)
options = append(options, opt[0])
if len(opt) == 2 {
options = append(options, opt[1])
} else {
options = append(options, "")
}
}
}

options := []string{"fspath", target}
if isNullFS {
options = append(options, "fstype", "nullfs", "target", device)
} else {
Expand Down