From: huanwen ren Date: Thu, 22 Sep 2016 11:24:46 +0000 (+0800) Subject: libcephfs: add ceph_fsetattr() X-Git-Tag: v11.1.0~521^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=64dab063e9c484a72db4166ed128cb20f53402f6;p=ceph.git libcephfs: add ceph_fsetattr() Signed-off-by: huanwen ren --- diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index bf38b2b8f22..09e9801ea35 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -655,6 +655,17 @@ int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *st */ int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct stat *attr, int mask); +/** + * Set a file's attributes. + * + * @param cmount the ceph mount handle to use for performing the setattr. + * @param fd the fd of the open file/directory to set the attributes of. + * @param attr the stat struct that must include attribute values to set on the file. + * @param mask a mask of all the stat values that have been set on the stat struct. + * @returns 0 on success or negative error code on failure. + */ +int ceph_fsetattr(struct ceph_mount_info *cmount, int fd, struct stat *attr, int mask); + /** * Set a file's attributes (extended version). * diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 9e65bff95d2..8611c81e4ff 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -634,6 +634,14 @@ extern "C" int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, return cmount->get_client()->setattr(relpath, attr, mask); } +extern "C" int ceph_fsetattr(struct ceph_mount_info *cmount, int fd, + struct stat *attr, int mask) +{ + if (!cmount->is_mounted()) + return -ENOTCONN; + return cmount->get_client()->fsetattr(fd, attr, mask, cmount->default_perms); +} + extern "C" int ceph_setattrx(struct ceph_mount_info *cmount, const char *relpath, struct ceph_statx *stx, int mask, int flags) {