cephfs: wrap ceph_create_from_rados function
Support creating a cephfs 'mount' from an existing rados connection
using the ceph_create_from_rados function.
@@ -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)
