-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45e9a80
commit bbcb8f2
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build ceph_preview | ||
// +build ceph_preview | ||
|
||
package cephfs | ||
|
||
/* | ||
#cgo LDFLAGS: -lcephfs | ||
#cgo CPPFLAGS: -D_FILE_OFFSET_BITS=64 | ||
#include <stdlib.h> | ||
#include <cephfs/libcephfs.h> | ||
*/ | ||
import "C" | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
// MakeDirs creates multiple directories at once. | ||
// | ||
// Implements: | ||
// | ||
// int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode); | ||
func (mount *MountInfo) MakeDirs(path string, mode uint32) error { | ||
if err := mount.validate(); err != nil { | ||
return err | ||
} | ||
cPath := C.CString(path) | ||
defer C.free(unsafe.Pointer(cPath)) | ||
|
||
ret := C.ceph_mkdirs(mount.mount, cPath, C.mode_t(mode)) | ||
return getError(ret) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build ceph_preview | ||
// +build ceph_preview | ||
|
||
package cephfs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMakeDirs(t *testing.T) { | ||
mount := fsConnect(t) | ||
defer fsDisconnect(t, mount) | ||
|
||
dir1 := "/base/sub/way" | ||
err := mount.MakeDirs(dir1, 0755) | ||
assert.NoError(t, err) | ||
defer func() { | ||
assert.NoError(t, mount.RemoveDir("/base/sub/way")) | ||
assert.NoError(t, mount.RemoveDir("/base/sub")) | ||
assert.NoError(t, mount.RemoveDir("/base")) | ||
}() | ||
|
||
dir, err := mount.OpenDir(dir1) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, dir) | ||
err = dir.Close() | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters