Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

Commit

Permalink
cephfs: add mkdir
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
  • Loading branch information
dotnwat committed May 1, 2015
1 parent de82ee5 commit 0f4cf26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
12 changes: 12 additions & 0 deletions cephfs/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ func (mount *MountInfo) ChangeDir(path string) error {
return CephError(ret)
}
}

func (mount *MountInfo) MakeDir(path string, mode uint32) error {
c_path := C.CString(path)
defer C.free(unsafe.Pointer(c_path))

ret := C.ceph_mkdir(mount.mount, c_path, C.mode_t(mode))
if ret == 0 {
return nil
} else {
return CephError(ret)
}
}
20 changes: 9 additions & 11 deletions cephfs/cephfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,19 @@ func TestChangeDir(t *testing.T) {
err = mount.Mount()
assert.NoError(t, err)

err = mount.ChangeDir("/")
assert.NoError(t, err)
}
dir1 := mount.CurrentDir()
assert.NotNil(t, dir1)

func TestCurrentDir(t *testing.T) {
mount, err := cephfs.CreateMount()
err = mount.MakeDir("/asdf", 0755)
assert.NoError(t, err)
assert.NotNil(t, mount)

err = mount.ReadDefaultConfigFile()
err = mount.ChangeDir("/asdf")
assert.NoError(t, err)

err = mount.Mount()
assert.NoError(t, err)
dir2 := mount.CurrentDir()
assert.NotNil(t, dir2)

dir := mount.CurrentDir()
assert.NotNil(t, dir)
assert.NotEqual(t, dir1, dir2)
assert.Equal(t, dir1, "/")
assert.Equal(t, dir2, "/asdf")
}

0 comments on commit 0f4cf26

Please sign in to comment.