]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: allow change file owner or group only
authorAndras Elso <elso.andras@gmail.com>
Tue, 26 Feb 2013 23:20:39 +0000 (00:20 +0100)
committerAndras Elso <elso.andras@gmail.com>
Wed, 27 Feb 2013 00:53:06 +0000 (01:53 +0100)
Signed-off-by: Andras Elso <elso.andras@gmail.com>
src/client/Client.cc
src/client/Client.h
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 71bb5d92143fafbd4fc214f480ba16bced676fd4..eee7fdd6c1fb54e9709126f2079164aa8a5efbfb 100644 (file)
@@ -4435,7 +4435,7 @@ int Client::fchmod(int fd, mode_t mode)
   return _setattr(f->inode, &attr, CEPH_SETATTR_MODE);
 }
 
-int Client::chown(const char *relpath, uid_t uid, gid_t gid)
+int Client::chown(const char *relpath, int uid, int gid)
 {
   Mutex::Locker lock(client_lock);
   tout(cct) << "chown" << std::endl;
@@ -4450,10 +4450,13 @@ int Client::chown(const char *relpath, uid_t uid, gid_t gid)
   struct stat attr;
   attr.st_uid = uid;
   attr.st_gid = gid;
-  return _setattr(in, &attr, CEPH_SETATTR_UID|CEPH_SETATTR_GID);
+  int mask = 0;
+  if (uid != -1) mask |= CEPH_SETATTR_UID;
+  if (gid != -1) mask |= CEPH_SETATTR_GID;
+  return _setattr(in, &attr, mask);
 }
 
-int Client::fchown(int fd, uid_t uid, gid_t gid)
+int Client::fchown(int fd, int uid, int gid)
 {
   Mutex::Locker lock(client_lock);
   tout(cct) << "fchown" << std::endl;
@@ -4466,10 +4469,13 @@ int Client::fchown(int fd, uid_t uid, gid_t gid)
   struct stat attr;
   attr.st_uid = uid;
   attr.st_gid = gid;
-  return _setattr(f->inode, &attr, CEPH_SETATTR_UID|CEPH_SETATTR_GID);
+  int mask = 0;
+  if (uid != -1) mask |= CEPH_SETATTR_UID;
+  if (gid != -1) mask |= CEPH_SETATTR_GID;
+  return _setattr(f->inode, &attr, mask);
 }
 
-int Client::lchown(const char *relpath, uid_t uid, gid_t gid)
+int Client::lchown(const char *relpath, int uid, int gid)
 {
   Mutex::Locker lock(client_lock);
   tout(cct) << "lchown" << std::endl;
@@ -4485,7 +4491,10 @@ int Client::lchown(const char *relpath, uid_t uid, gid_t gid)
   struct stat attr;
   attr.st_uid = uid;
   attr.st_gid = gid;
-  return _setattr(in, &attr, CEPH_SETATTR_UID|CEPH_SETATTR_GID);
+  int mask = 0;
+  if (uid != -1) mask |= CEPH_SETATTR_UID;
+  if (gid != -1) mask |= CEPH_SETATTR_GID;
+  return _setattr(in, &attr, mask);
 }
 
 int Client::utime(const char *relpath, struct utimbuf *buf)
index 3fcdf481ad1796ad8e9726c53a844accc6e5a85d..3ebf27fd0a9ad0d132f17b2143be7e04d3d1509a 100644 (file)
@@ -622,9 +622,9 @@ 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 fchown(int fd, uid_t uid, gid_t gid);
-  int lchown(const char *path, uid_t uid, gid_t gid);
+  int chown(const char *path, int uid, int gid);
+  int fchown(int fd, int uid, int gid);
+  int lchown(const char *path, int uid, int gid);
   int utime(const char *path, struct utimbuf *buf);
   int truncate(const char *path, loff_t size);
 
index adcdb39e6007a004b29e7b4515eb8bb191d69c05..abfd25cfd7e9d4f19063e290ff37e6ed2e2e6657 100644 (file)
@@ -530,7 +530,7 @@ int ceph_fchmod(struct ceph_mount_info *cmount, int fd, mode_t mode);
  * @param gid the group id to set on the file/directory.
  * @returns 0 on success or negative error code on failure.
  */
-int ceph_chown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid);
+int ceph_chown(struct ceph_mount_info *cmount, const char *path, int uid, int gid);
 
 /**
  * Change the ownership of a file from an open file descriptor.
@@ -541,7 +541,7 @@ int ceph_chown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_
  * @param gid the group id to set on the file/directory.
  * @returns 0 on success or negative error code on failure.
  */
-int ceph_fchown(struct ceph_mount_info *cmount, int fd, uid_t uid, gid_t gid);
+int ceph_fchown(struct ceph_mount_info *cmount, int fd, int uid, int gid);
 
 /**
  * Change the ownership of a file/directory, don't follow symlinks.
@@ -552,7 +552,7 @@ int ceph_fchown(struct ceph_mount_info *cmount, int fd, uid_t uid, gid_t gid);
  * @param gid the group id to set on the file/directory.
  * @returns 0 on success or negative error code on failure.
  */
-int ceph_lchown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid);
+int ceph_lchown(struct ceph_mount_info *cmount, const char *path, int uid, int gid);
 
 /**
  * Change file/directory last access and modification times.
index 75937586cb0746919e6253110dd36090ee66659e..d2fe0dac861b0f2d6c3df34713bbff491b9bcd87 100644 (file)
@@ -574,21 +574,21 @@ 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)
+                         int uid, int gid)
 {
   if (!cmount->is_mounted())
     return -ENOTCONN;
   return cmount->get_client()->chown(path, uid, gid);
 }
 extern "C" int ceph_fchown(struct ceph_mount_info *cmount, int fd,
-                          uid_t uid, gid_t gid)
+                          int uid, int gid)
 {
   if (!cmount->is_mounted())
     return -ENOTCONN;
   return cmount->get_client()->fchown(fd, uid, gid);
 }
 extern "C" int ceph_lchown(struct ceph_mount_info *cmount, const char *path,
-                          uid_t uid, gid_t gid)
+                          int uid, int gid)
 {
   if (!cmount->is_mounted())
     return -ENOTCONN;