From 9929f63b13f23518d84d1558913c37522085cb04 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 18 Dec 2019 17:27:12 -0500 Subject: [PATCH] cephfs: wrap ceph_create_from_rados function Support creating a cephfs 'mount' from an existing rados connection using the ceph_create_from_rados function. Signed-off-by: John Mulligan --- cephfs/cephfs.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cephfs/cephfs.go b/cephfs/cephfs.go index 517cf57..b2adfb7 100644 --- a/cephfs/cephfs.go +++ b/cephfs/cephfs.go @@ -13,6 +13,7 @@ import ( "unsafe" "github.com/ceph/go-ceph/errutil" + "github.com/ceph/go-ceph/rados" ) type CephFSError int @@ -47,6 +48,20 @@ func CreateMount() (*MountInfo, error) { return mount, nil } +// CreateFromRados creates a mount handle using an existing rados cluster +// connection. +// +// Implements: +// int ceph_create_from_rados(struct ceph_mount_info **cmount, rados_t cluster); +func CreateFromRados(conn *rados.Conn) (*MountInfo, error) { + mount := &MountInfo{} + ret := C.ceph_create_from_rados(&mount.mount, C.rados_t(conn.Cluster())) + if ret != 0 { + return nil, getError(ret) + } + return mount, nil +} + // ReadDefaultConfigFile loads the ceph configuration from the specified config file. func (mount *MountInfo) ReadDefaultConfigFile() error { ret := C.ceph_conf_read_file(mount.mount, nil)