cephfs: add missing cephfs API components: function ceph_version

Signed-off-by: Kim young jin <oct28-yjkim@gmail.com>
This commit is contained in:
yjkim1 2021-09-07 09:02:52 +09:00 committed by mergify[bot]
parent 361598d4d3
commit bb535d6df2
2 changed files with 14 additions and 0 deletions

View File

@ -37,6 +37,13 @@ func (mount *MountInfo) validate() error {
return nil
}
// Version returns the major, minor, and patch level of the libcephfs library.
func Version() (int, int, int) {
var cMajor, cMinor, cPatch C.int
C.ceph_version(&cMajor, &cMinor, &cPatch)
return int(cMajor), int(cMinor), int(cPatch)
}
// CreateMount creates a mount handle for interacting with Ceph.
func CreateMount() (*MountInfo, error) {
return createMount(nil)

View File

@ -357,3 +357,10 @@ func TestReadConfigFile(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "04862775-14d5-46e0-a015-000000000000", v)
}
func TestVersion(t *testing.T) {
var major, minor, patch = Version()
assert.False(t, major < 0 || major > 1000, "invalid major")
assert.False(t, minor < 0 || minor > 1000, "invalid minor")
assert.False(t, patch < 0 || patch > 1000, "invalid patch")
}