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 <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2019-12-18 17:27:12 -05:00 committed by Niels de Vos
parent 46ed646e03
commit 9929f63b13
1 changed files with 15 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import (
"unsafe" "unsafe"
"github.com/ceph/go-ceph/errutil" "github.com/ceph/go-ceph/errutil"
"github.com/ceph/go-ceph/rados"
) )
type CephFSError int type CephFSError int
@ -47,6 +48,20 @@ func CreateMount() (*MountInfo, error) {
return mount, nil 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. // ReadDefaultConfigFile loads the ceph configuration from the specified config file.
func (mount *MountInfo) ReadDefaultConfigFile() error { func (mount *MountInfo) ReadDefaultConfigFile() error {
ret := C.ceph_conf_read_file(mount.mount, nil) ret := C.ceph_conf_read_file(mount.mount, nil)