Repository: ceph/go-ceph (go)

Issue:
Missing cephfs API components: function ceph_select_filesystem
The cephfs API implements function(s) below but go-ceph does not:
* ceph_select_filesystem

This issue has been filed to track implementing this missing
functionality in the appropriate package within go-ceph.
Please refer to the Ceph C API for details about the function(s)
in question.

NOTE: This issue was generated by a script.
If the content is innacurate or wording seems a bit odd
please excuse the script and blame the creator @phlogistonjohn



Pull request description:
cephfs: add wrapper for ceph_lchown
Signed-off-by: RAJAT SINGH <rajasing@redhat.com>


<!--
Thank you for opening a pull request. Please provide:

- A clear summary of your changes

- Descriptive and succinct commit messages with the format:
  """
  [topic]: [short description]

  [Longer description]

  Signed-off-by: [Your Name] <[your email]>
  """

  Topic will generally be the go ceph package dir you are working in.

- Ensure checklist items listed below are accounted for
-->
Added wrapper for lchown that was missing. Fixes #262 
## Checklist
- [x] Added tests for features and functional changes
- [ ] Public functions and types are documented
- [ ] Standard formatting is applied to Go code


Patch:
diff --git a/cephfs/permissions.go b/cephfs/permissions.go
index 77153fb..d55470b 100644
--- a/cephfs/permissions.go
+++ b/cephfs/permissions.go
@@ -29,3 +29,12 @@ func (mount *MountInfo) Chown(path string, user uint32, group uint32) error {
 	ret := C.ceph_chown(mount.mount, cPath, C.int(user), C.int(group))
 	return getError(ret)
 }
+
+// Lchown changes the ownership of a file/directory/etc without following symbolic links
+func (mount *MountInfo) Lchown(path string, user uint32, group uint32) error {
+	cPath := C.CString(path)
+	defer C.free(unsafe.Pointer(cPath))
+
+	ret := C.ceph_lchown(mount.mount, cPath, C.int(user), C.int(group))
+	return getError(ret)
+}


Test patch:
diff --git a/cephfs/permissions_test.go b/cephfs/permissions_test.go
index be16811..1d94afc 100644
--- a/cephfs/permissions_test.go
+++ b/cephfs/permissions_test.go
@@ -64,3 +64,32 @@ func TestChown(t *testing.T) {
 	assert.Equal(t, uint32(sx.Uid), bob)
 	assert.Equal(t, uint32(sx.Gid), bob)
 }
+
+func TestLchown(t *testing.T) {
+	dirname := "four"
+	var bob uint32 = 1010
+	var root uint32
+
+	mount := fsConnect(t)
+	defer fsDisconnect(t, mount)
+
+	err := mount.MakeDir(dirname, 0755)
+	assert.NoError(t, err)
+	defer mount.RemoveDir(dirname)
+
+	err = mount.SyncFs()
+	assert.NoError(t, err)
+
+	err = mount.Symlink(dirname, "symlnk")
+	assert.NoError(t, err)
+	defer mount.Unlink("symlnk")
+
+	err = mount.Lchown("symlnk", bob, bob)
+	sx, err := mount.Statx("symlnk", StatxBasicStats, AtSymlinkNofollow)
+	assert.NoError(t, err)
+	assert.Equal(t, uint32(sx.Uid), bob)
+	assert.Equal(t, uint32(sx.Gid), bob)
+	sx, err = mount.Statx(dirname, StatxBasicStats, AtSymlinkNofollow)
+	assert.Equal(t, uint32(sx.Uid), root)
+	assert.Equal(t, uint32(sx.Gid), root)
+}