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;
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;
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;
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)
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);
* @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.
* @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.
* @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.
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;