Skip to content

Commit

Permalink
Use MNT_FORCE as an approximate equivalent to MNT_DETACH
Browse files Browse the repository at this point in the history
Also, we don't need to truncate the path name for zfs mount points.
FreeBSD versions prior to 12.0 had a limitation of 88 characters
for mount points but this has been increased to 1024.

Signed-off-by: Doug Rabson <dfr@rabson.org>
  • Loading branch information
dfr committed Apr 27, 2022
1 parent ca405bd commit 84861ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
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
)

0 comments on commit 84861ad

Please sign in to comment.