]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
libcephfs: Add ceph_setlk and ceph_getlk wrapper functions
authorGiorgos Kappes <giorgos@giorgoskappes.com>
Tue, 22 Jul 2025 14:12:58 +0000 (17:12 +0300)
committerGiorgos Kappes <giorgos@giorgoskappes.com>
Tue, 22 Jul 2025 16:02:05 +0000 (19:02 +0300)
Signed-off-by: Giorgos Kappes <giorgos@giorgoskappes.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 18e44b656eef1dac2ae8ac8adc83607ae567d9cb..485b51a2ac15a65fdd9b7ff2607ca51163914884 100644 (file)
@@ -1276,6 +1276,32 @@ int ceph_utimensat(struct ceph_mount_info *cmount, int dirfd, const char *relpat
 int ceph_flock(struct ceph_mount_info *cmount, int fd, int operation,
               uint64_t owner);
 
+/**
+ * Test the existence of a record lock.
+ *
+ * @param cmount the ceph mount handle to use for performing the lock.
+ * @param fd the open file descriptor to test the existence of a record lock.
+ * @param pointer to an flock structure.
+ * @param owner the user-supplied owner identifier (an arbitrary integer)
+ * @returns 0 on success or negative error code on failure.
+ */ 
+ int ceph_getlk(struct ceph_mount_info *cmount, int fd, struct flock *flock,
+               uint64_t owner);
+
+/**
+ * Set a record lock.
+ *
+ * @param cmount the ceph mount handle to use for performing the lock.
+ * @param fd the open file descriptor to set a record lock
+ * @param pointer to an flock structure.
+ * @param owner the user-supplied owner identifier (an arbitrary integer)
+ * @param sleep the user-supplied sleep flag
+ * @returns 0 on success or negative error code on failure.
+ */ 
+ int ceph_setlk(struct ceph_mount_info *cmount, int fd, struct flock *flock,
+               uint64_t owner, int sleep);
+
 /**
  * Truncate the file to the given size.  If this operation causes the
  * file to expand, the empty bytes will be filled in with zeros.
index 5102be67e769348735878b7dfa380c927b025e6f..049a47c4f53bc85d8d5a6075807c954f450ccc53 100644 (file)
@@ -1405,6 +1405,22 @@ extern "C" int ceph_flock(struct ceph_mount_info *cmount, int fd, int operation,
   return cmount->get_client()->flock(fd, operation, owner);
 }
 
+extern "C" int ceph_getlk(struct ceph_mount_info *cmount, int fd, struct flock *fl,
+                         uint64_t owner)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->getlk(fd, fl, owner);
+}
+
+extern "C" int ceph_setlk(struct ceph_mount_info *cmount, int fd, struct flock *fl,
+                         uint64_t owner, int sleep)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->setlk(fd, fl, owner, sleep);
+}
+
 extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path,
                             int64_t size)
 {