From 1755e31f71828a523971cf2d7b63517b1d17cbe6 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 6 Feb 2023 16:14:10 -0500 Subject: [PATCH] cephfs: add SelectFileystem implementing ceph_select_filesystem Add SelectFileystem implementing ceph_select_filesystem which can be used to select a cephfs by name, prior to calling mount, when the ceph cluster hosts more than one cephfs file system. Fixes: #262 Fixes: #818 Original-Version-By: "Arvid E. Picciani" Original-PR-URL: https://github.com/ceph/go-ceph/pull/819 Signed-off-by: John Mulligan --- cephfs/select_fs.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cephfs/select_fs.go diff --git a/cephfs/select_fs.go b/cephfs/select_fs.go new file mode 100644 index 0000000..acc96e4 --- /dev/null +++ b/cephfs/select_fs.go @@ -0,0 +1,33 @@ +//go:build ceph_preview +// +build ceph_preview + +package cephfs + +/* +#cgo LDFLAGS: -lcephfs +#cgo CPPFLAGS: -D_FILE_OFFSET_BITS=64 +#define _GNU_SOURCE +#include +#include +*/ +import "C" + +import ( + "unsafe" +) + +// SelectFilesystem selects a file system to be mounted. If the ceph cluster +// supports more than one cephfs this optional function selects which one to +// use. Can only be called prior to calling Mount. The name of the file system +// is not validated by this call - if the supplied file system name is not +// valid then only the subsequent mount call will fail. +// +// Implements: +// int ceph_select_filesystem(struct ceph_mount_info *cmount, const char *fs_name); +func (mount *MountInfo) SelectFilesystem(name string) error { + cName := C.CString(name) + defer C.free(unsafe.Pointer(cName)) + + ret := C.ceph_select_filesystem(mount.mount, cName) + return getError(ret) +}