client: Support for fchmod

Signed-off-by: Sam Lang <sam.lang@inktank.com>
This commit is contained in:
Sam Lang 2012-10-10 09:33:34 -05:00
parent e6cecabb55
commit 14ef165534
4 changed files with 29 additions and 0 deletions

View 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);

View 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);

View 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.
*

View 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)
{