...and convert ceph_fsetattr callers to use it instead.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
return _setattr(f->inode, attr, mask, perms);
}
+int Client::fsetattrx(int fd, struct ceph_statx *stx, int mask, const UserPerm& perms)
+{
+ Mutex::Locker lock(client_lock);
+ tout(cct) << "fsetattr" << std::endl;
+ tout(cct) << fd << std::endl;
+ tout(cct) << mask << std::endl;
+
+ Fh *f = get_filehandle(fd);
+ if (!f)
+ return -EBADF;
+#if defined(__linux__) && defined(O_PATH)
+ if (f->flags & O_PATH)
+ return -EBADF;
+#endif
+ return _setattrx(f->inode, stx, mask, perms);
+}
+
int Client::stat(const char *relpath, struct stat *stbuf, const UserPerm& perms,
frag_info_t *dirstat, int mask)
{
int setattrx(const char *relpath, struct ceph_statx *stx, int mask,
const UserPerm& perms, int flags=0);
int fsetattr(int fd, struct stat *attr, int mask, const UserPerm& perms);
+ int fsetattrx(int fd, struct ceph_statx *stx, int mask, const UserPerm& perms);
int chmod(const char *path, mode_t mode, const UserPerm& perms);
int fchmod(int fd, mode_t mode, const UserPerm& perms);
int lchmod(const char *path, mode_t mode, const UserPerm& perms);
*/
int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct stat *attr, int mask);
+/**
+ * Set a file's attributes (extended version).
+ *
+ * @param cmount the ceph mount handle to use for performing the setattr.
+ * @param relpath the path to the file/directory to set the attributes of.
+ * @param stx the statx struct that must include attribute values to set on the file.
+ * @param mask a mask of all the CEPH_SETATTR_* values that have been set in the statx struct.
+ * @param flags mask of AT_* flags (only AT_ATTR_NOFOLLOW is respected for now)
+ * @returns 0 on success or negative error code on failure.
+ */
+int ceph_setattrx(struct ceph_mount_info *cmount, const char *relpath, struct ceph_statx *stx, int mask, int flags);
+
/**
* Set a file's attributes.
*
/**
* Set a file's attributes (extended version).
- *
+ *
* @param cmount the ceph mount handle to use for performing the setattr.
- * @param relpath the path to the file/directory to set the attributes of.
+ * @param fd the fd of the open file/directory to set the attributes of.
* @param stx the statx struct that must include attribute values to set on the file.
- * @param mask a mask of all the CEPH_SETATTR_* values that have been set in the statx struct.
- * @param flags mask of AT_* flags (only AT_ATTR_NOFOLLOW is respected for now)
+ * @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_setattrx(struct ceph_mount_info *cmount, const char *relpath, struct ceph_statx *stx, int mask, int flags);
+int ceph_fsetattrx(struct ceph_mount_info *cmount, int fd, struct ceph_statx *stx, int mask);
/**
* Change the mode bits (permissions) of a file/directory.
return cmount->get_client()->fsetattr(fd, attr, mask, cmount->default_perms);
}
+extern "C" int ceph_fsetattrx(struct ceph_mount_info *cmount, int fd,
+ struct ceph_statx *stx, int mask)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ return cmount->get_client()->fsetattrx(fd, stx, 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)
{
EXPECT_EQ(-ENOTCONN, ceph_setxattr(cmount, "/path", "name", NULL, 0, 0));
EXPECT_EQ(-ENOTCONN, ceph_lsetxattr(cmount, "/path", "name", NULL, 0, 0));
EXPECT_EQ(-ENOTCONN, ceph_fsetattr(cmount, 0, &st, 0));
+ EXPECT_EQ(-ENOTCONN, ceph_fsetattrx(cmount, 0, &stx, 0));
EXPECT_EQ(-ENOTCONN, ceph_chmod(cmount, "/path", 0));
EXPECT_EQ(-ENOTCONN, ceph_fchmod(cmount, 0, 0));
EXPECT_EQ(-ENOTCONN, ceph_chown(cmount, "/path", 0, 0));
int fd = ceph_open(cmount, filename, O_RDWR|O_CREAT|O_EXCL, 0666);
ASSERT_LT(0, fd);
- struct stat st;
+ struct ceph_statx stx;
uint64_t size = 8388608;
- st.st_size = (off_t)size;
- ASSERT_EQ(ceph_fsetattr(cmount, fd, &st, CEPH_SETATTR_SIZE), 0);
-
- struct stat stbuf;
- ASSERT_EQ(ceph_fstat(cmount, fd, &stbuf), 0);
- ASSERT_EQ(stbuf.st_size, (off_t)size);
+ stx.stx_size = (off_t)size;
+ ASSERT_EQ(ceph_fsetattrx(cmount, fd, &stx, CEPH_SETATTR_SIZE), 0);
+ ASSERT_EQ(ceph_fstatx(cmount, fd, &stx, CEPH_STATX_SIZE, 0), 0);
+ ASSERT_EQ(stx.stx_size, (off_t)size);
ceph_close(cmount, fd);
ceph_shutdown(cmount);