mirror of
https://github.com/ceph/go-ceph
synced 2024-12-27 16:52:06 +00:00
5aadca02bf
Continue organizing the cephfs functionality by creating new files for chmod and chown functionality. Similarly, the dedicated test functions for those items are moved into a new file as well. Signed-off-by: John Mulligan <jmulligan@redhat.com>
32 lines
729 B
Go
32 lines
729 B
Go
package cephfs
|
|
|
|
/*
|
|
#cgo LDFLAGS: -lcephfs
|
|
#cgo CPPFLAGS: -D_FILE_OFFSET_BITS=64
|
|
#include <stdlib.h>
|
|
#include <cephfs/libcephfs.h>
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// Chmod changes the mode bits (permissions) of a file/directory.
|
|
func (mount *MountInfo) Chmod(path string, mode uint32) error {
|
|
cPath := C.CString(path)
|
|
defer C.free(unsafe.Pointer(cPath))
|
|
|
|
ret := C.ceph_chmod(mount.mount, cPath, C.mode_t(mode))
|
|
return getError(ret)
|
|
}
|
|
|
|
// Chown changes the ownership of a file/directory.
|
|
func (mount *MountInfo) Chown(path string, user uint32, group uint32) error {
|
|
cPath := C.CString(path)
|
|
defer C.free(unsafe.Pointer(cPath))
|
|
|
|
ret := C.ceph_chown(mount.mount, cPath, C.int(user), C.int(group))
|
|
return getError(ret)
|
|
}
|