Skip to content

Commit

Permalink
cephfs: add SelectFileystem implementing ceph_select_filesystem
Browse files Browse the repository at this point in the history
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" <[email protected]>
Original-PR-URL: #819
Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn committed Feb 13, 2023
1 parent 530fea2 commit 1755e31
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cephfs/select_fs.go
Original file line number Diff line number Diff line change
@@ -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 <stdlib.h>
#include <cephfs/libcephfs.h>
*/
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)
}

0 comments on commit 1755e31

Please sign in to comment.