Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

nfsmount: call mount_nfs directly on OpenBSD so -T is accepted

Socialprankerb78a43d05f51
diff --git a/cmd/nfsmount/nfsmount.go b/cmd/nfsmount/nfsmount.go
index 3a003e28f..b33fb2d04 100644
--- a/cmd/nfsmount/nfsmount.go
+++ b/cmd/nfsmount/nfsmount.go
@@ -54,16 +54,20 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (asyncerrors
return
}
- // Options
+ // Options and mount binary
//
// 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.
+ // requested with the "-T" flag instead. "-T" is a mount_nfs(8) flag,
+ // not a generic mount(8) one, so on OpenBSD we call mount_nfs(8)
+ // directly; running it through mount(8) makes mount reject "-T" with
+ // "unknown option". FreeBSD's mount_nfs(8) accepts the same "-o
+ // port=", "-o mountport=" and "-o tcp" options as Linux, and mount(8)
+ // there forwards them, so it stays on the common path.
+ mountBin := "mount"
var options []string
if runtime.GOOS == "openbsd" {
+ mountBin = "mount_nfs"
options = []string{
"-o", fmt.Sprintf("port=%s", port),
"-T",
@@ -84,7 +88,7 @@ func mount(VFS *vfs.VFS, mountpoint string, opt *mountlib.Options) (asyncerrors
if sudo {
cmd = append(cmd, "sudo")
}
- cmd = append(cmd, "mount")
+ cmd = append(cmd, mountBin)
cmd = append(cmd, options...)
cmd = append(cmd, "localhost:"+mountPath, mountpoint)
fs.Debugf(nil, "Running mount command: %q", cmd)