]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Support for fchmod
authorSam Lang <sam.lang@inktank.com>
Wed, 10 Oct 2012 14:33:34 +0000 (09:33 -0500)
committerSam Lang <sam.lang@inktank.com>
Wed, 17 Oct 2012 17:50:47 +0000 (12:50 -0500)
Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/client/Client.cc
src/client/Client.h
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 6286996cc53e740b9dd3281dd98cf33e918a4985..a718a0cad66a61668137a304d0430d019751354d 100644 (file)
@@ -4188,6 +4188,19 @@ int Client::chmod(const char *relpath, mode_t mode)
   return _setattr(in, &attr, CEPH_SETATTR_MODE);
 }
 
+int Client::fchmod(int fd, mode_t mode)
+{
+  Mutex::Locker lock(client_lock);
+  tout(cct) << "fchmod" << std::endl;
+  tout(cct) << fd << std::endl;
+  tout(cct) << mode << std::endl;
+  assert(fd_map.count(fd));
+  Fh *f = fd_map[fd];
+  struct stat attr;
+  attr.st_mode = mode;
+  return _setattr(f->inode, &attr, CEPH_SETATTR_MODE);
+}
+
 int Client::chown(const char *relpath, uid_t uid, gid_t gid)
 {
   Mutex::Locker lock(client_lock);
index 404096bceed6c4a73d964e3a2ce9a032beee8c5d..d4f61d6ed0afbadc1e9b4d3ed115bed82e1a8720 100644 (file)
@@ -588,6 +588,7 @@ public:
 
   int setattr(const char *relpath, struct stat *attr, int mask);
   int chmod(const char *path, mode_t mode);
+  int fchmod(int fd, mode_t mode);
   int chown(const char *path, uid_t uid, gid_t gid);
   int utime(const char *path, struct utimbuf *buf);
   int truncate(const char *path, loff_t size);
index 937c192b22f45704fdfb042c2c77de103f9c0c7f..e0048b9e692b42292164dba5da1eff51a6809408 100644 (file)
@@ -462,6 +462,7 @@ int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *st
  * @returns 0 on success or negative error code on failure.
  */
 int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct stat *attr, int mask);
+
 /**
  * Change the mode bits (permissions) of a file/directory.
  *
@@ -472,6 +473,16 @@ int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct sta
  */
 int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode);
 
+/**
+ * Change the mode bits (permissions) of an open file.
+ *
+ * @param cmount the ceph mount handle to use for performing the chmod.
+ * @param fd the open file descriptor to change the mode bits on.
+ * @param mode the new permissions to set.
+ * @returns 0 on success or a negative error code on failure.
+ */
+int ceph_fchmod(struct ceph_mount_info *cmount, int fd, mode_t mode);
+
 /**
  * Change the ownership of a file/directory.
  * 
index f4e4ad0b03efa874922057d4fe622fb422d69809..8e1020e85e07070560f511f17962b1f9387d4441 100644 (file)
@@ -450,6 +450,10 @@ extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode
 {
   return cmount->get_client()->chmod(path, mode);
 }
+extern "C" int ceph_fchmod(struct ceph_mount_info *cmount, int fd, mode_t mode)
+{
+  return cmount->get_client()->fchmod(fd, mode);
+}
 extern "C" int ceph_chown(struct ceph_mount_info *cmount, const char *path,
                          uid_t uid, gid_t gid)
 {