From 47fb3c7156005e5f2e96d90d7716a5108244e8d6 Mon Sep 17 00:00:00 2001 From: Socialpranker <273312799+Socialpranker@users.noreply.github.com> Date: Sat, 11 Jul 2026 07:32:51 +0200 Subject: [PATCH] nfsmount: fix mount_nfs options incompatible with OpenBSD - fixes #8578 nfsmount built its mount options for GNU/Linux syntax unconditionally: "-o port=N", "-o mountport=N" and "-o tcp". OpenBSD's mount_nfs(8) rejects "-o mountport" outright ("option not supported", per the reporter's log) and has no "tcp" suboption either, since it selects TCP with the separate "-T" flag instead of an -o suboption. Add a runtime.GOOS == "openbsd" branch that builds the option list OpenBSD's mount_nfs actually accepts: "-o port=N" plus "-T" for TCP, with no mountport option since OpenBSD's mountd is located via portmap rather than a fixed, settable port. This follows the same GOOS-branching pattern already used in this file's unmount function (darwin) and in cmd/cmount/mount.go for openbsd/freebsd differences. FreeBSD's mount_nfs(8) documents "port=", "mountport=" and "tcp" as -o suboptions identical to Linux, so the existing option set is left unchanged for freebsd and all other platforms. Verified by cross-compiling (go build and go vet) for GOOS=openbsd, freebsd, linux and darwin, all of which succeed. Actually mounting via mount_nfs on OpenBSD needs a BSD machine to confirm at runtime, which wasn't available here. Co-Authored-By: Claude Opus 4.8 --- cmd/nfsmount/nfsmount.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/cmd/nfsmount/nfsmount.go b/cmd/nfsmount/nfsmount.go index 89821a82d..3a003e28f 100644 --- a/cmd/nfsmount/nfsmount.go +++ b/cmd/nfsmount/nfsmount.go @@ -55,10 +55,25 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (asyncerrors } // Options - options := []string{ - "-o", fmt.Sprintf("port=%s", port), - "-o", fmt.Sprintf("mountport=%s", port), - "-o", "tcp", + // + // OpenBSD's mount_nfs(8) doesn't understand "-o mountport=" or "-o + // tcp" - the mountd port isn't settable that way and TCP is + // requested with the "-T" flag instead, so build a different set of + // options there. FreeBSD's mount_nfs(8) accepts the same "-o + // port=", "-o mountport=" and "-o tcp" options as Linux so it uses + // the common case. + var options []string + if runtime.GOOS == "openbsd" { + options = []string{ + "-o", fmt.Sprintf("port=%s", port), + "-T", + } + } else { + options = []string{ + "-o", fmt.Sprintf("port=%s", port), + "-o", fmt.Sprintf("mountport=%s", port), + "-o", "tcp", + } } for _, option := range opt.ExtraOptions { options = append(options, "-o", option)