]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: add link in cephfs
authorhuanwen ren <ren.huanwen@zte.com.cn>
Tue, 10 May 2016 11:35:38 +0000 (19:35 +0800)
committerhuanwen ren <ren.huanwen@zte.com.cn>
Tue, 10 May 2016 11:35:38 +0000 (19:35 +0800)
in addition to support symlink,but also need to support link

Signed-off-by: huanwen ren <ren.huanwen@zte.com.cn>
src/pybind/cephfs/cephfs.pyx

index d3b581b815774fcd09c80dc907253de46dfaae33..a067a7db331e68f9badf16f3479e9ac6cfa78218 100644 (file)
@@ -115,6 +115,7 @@ cdef extern from "cephfs/libcephfs.h" nogil:
                          const char *inbuf, size_t inbuflen, char **outbuf, size_t *outbuflen,
                          char **outs, size_t *outslen)
     int ceph_rename(ceph_mount_info *cmount, const char *from_, const char *to)
+    int ceph_link(ceph_mount_info *cmount, const char *existing, const char *newname)
     int ceph_unlink(ceph_mount_info *cmount, const char *path)
     int ceph_symlink(ceph_mount_info *cmount, const char *existing, const char *newname)
     int ceph_setxattr(ceph_mount_info *cmount, const char *path, const char *name,
@@ -798,6 +799,19 @@ cdef class LibCephFS(object):
             ret = ceph_symlink(self.cluster, _existing, _newname)
         if ret < 0:
             raise make_ex(ret, "error in symlink")
+    
+    def link(self, existing, newname):
+        self.require_state("mounted")
+        existing = cstr(existing, 'existing')
+        newname = cstr(newname, 'newname')
+        cdef:
+            char* _existing = existing
+            char* _newname = newname
+        
+        with nogil:
+            ret = ceph_link(self.cluster, _existing, _newname)
+        if ret < 0:
+            raise make_ex(ret, "error in link")    
 
     def unlink(self, path):
         self.require_state("mounted")