From 123b55e9ced5e34cef47628ef8047e2aaa7bbf13 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Sun, 24 Apr 2022 14:12:01 +0100 Subject: [PATCH] Use MNT_FORCE as an approximate equivalent to MNT_DETACH 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 --- drivers/zfs/zfs_freebsd.go | 16 +++------------- pkg/mount/flags_freebsd.go | 3 ++- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/zfs/zfs_freebsd.go b/drivers/zfs/zfs_freebsd.go index fd98ad305c..61a2ed871a 100644 --- a/drivers/zfs/zfs_freebsd.go +++ b/drivers/zfs/zfs_freebsd.go @@ -2,7 +2,6 @@ package zfs import ( "fmt" - "strings" "github.com/containers/storage/drivers" "github.com/pkg/errors" @@ -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) } diff --git a/pkg/mount/flags_freebsd.go b/pkg/mount/flags_freebsd.go index 630d313dcd..3ba99cf935 100644 --- a/pkg/mount/flags_freebsd.go +++ b/pkg/mount/flags_freebsd.go @@ -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 @@ -43,5 +45,4 @@ const ( RSHARED = 0 RELATIME = 0 STRICTATIME = 0 - mntDetach = 0 )