return Client::_getxattr(ceph_inode, name, value, size, getuid(), getgid());
}
+int Client::fgetxattr(int fd, const char *name, void *value, size_t size)
+{
+ Mutex::Locker lock(client_lock);
+ Fh *f = get_filehandle(fd);
+ if (!f)
+ return -EBADF;
+ return Client::_getxattr(f->inode, name, value, size, getuid(), getgid());
+}
+
int Client::listxattr(const char *path, char *list, size_t size)
{
Mutex::Locker lock(client_lock);
return Client::_listxattr(ceph_inode, list, size, getuid(), getgid());
}
+int Client::flistxattr(int fd, char *list, size_t size)
+{
+ Mutex::Locker lock(client_lock);
+ Fh *f = get_filehandle(fd);
+ if (!f)
+ return -EBADF;
+ return Client::_listxattr(f->inode, list, size, getuid(), getgid());
+}
+
int Client::removexattr(const char *path, const char *name)
{
Mutex::Locker lock(client_lock);
return Client::_removexattr(ceph_inode, name, getuid(), getgid());
}
+int Client::fremovexattr(int fd, const char *name)
+{
+ Mutex::Locker lock(client_lock);
+ Fh *f = get_filehandle(fd);
+ if (!f)
+ return -EBADF;
+ return Client::_removexattr(f->inode, name, getuid(), getgid());
+}
+
int Client::setxattr(const char *path, const char *name, const void *value, size_t size, int flags)
{
Mutex::Locker lock(client_lock);
return Client::_setxattr(ceph_inode, name, value, size, flags, getuid(), getgid());
}
+int Client::fsetxattr(int fd, const char *name, const void *value, size_t size, int flags)
+{
+ Mutex::Locker lock(client_lock);
+ Fh *f = get_filehandle(fd);
+ if (!f)
+ return -EBADF;
+ return Client::_setxattr(f->inode, name, value, size, flags, getuid(), getgid());
+}
+
int Client::_getxattr(Inode *in, const char *name, void *value, size_t size,
int uid, int gid)
{
// full path xattr ops
int getxattr(const char *path, const char *name, void *value, size_t size);
int lgetxattr(const char *path, const char *name, void *value, size_t size);
+ int fgetxattr(int fd, const char *name, void *value, size_t size);
int listxattr(const char *path, char *list, size_t size);
int llistxattr(const char *path, char *list, size_t size);
+ int flistxattr(int fd, char *list, size_t size);
int removexattr(const char *path, const char *name);
int lremovexattr(const char *path, const char *name);
+ int fremovexattr(int fd, const char *name);
int setxattr(const char *path, const char *name, const void *value, size_t size, int flags);
int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags);
+ int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags);
int sync_fs();
int64_t drop_caches();
int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name,
void *value, size_t size);
+/**
+ * Get an extended attribute.
+ *
+ * @param cmount the ceph mount handle to use for performing the getxattr.
+ * @param fd the open file descriptor referring to the file to get extended attribute from.
+ * @param name the name of the extended attribute to get
+ * @param value a pre-allocated buffer to hold the xattr's value
+ * @param size the size of the pre-allocated buffer
+ * @returns the size of the value or a negative error code on failure.
+ */
+int ceph_fgetxattr(struct ceph_mount_info *cmount, int fd, const char *name,
+ void *value, size_t size);
+
/**
* Get an extended attribute wihtout following symbolic links. This function is
* identical to ceph_getxattr, but if the path refers to a symbolic link,
*/
int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size);
+/**
+ * List the extended attribute keys on a file.
+ *
+ * @param cmount the ceph mount handle to use for performing the listxattr.
+ * @param fd the open file descriptor referring to the file to list extended attributes on.
+ * @param list a buffer to be filled in with the list of extended attributes keys.
+ * @param size the size of the list buffer.
+ * @returns the size of the resulting list filled in.
+ */
+int ceph_flistxattr(struct ceph_mount_info *cmount, int fd, char *list, size_t size);
+
/**
* Get the list of extended attribute keys on a file, but do not follow symbolic links.
*
*/
int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name);
+/**
+ * Remove an extended attribute from a file.
+ *
+ * @param cmount the ceph mount handle to use for performing the removexattr.
+ * @param fd the open file descriptor referring to the file to remove extended attribute from.
+ * @param name the name of the extended attribute to remove.
+ * @returns 0 on success or a negative error code on failure.
+ */
+int ceph_fremovexattr(struct ceph_mount_info *cmount, int fd, const char *name);
+
/**
* Remove the extended attribute from a file, do not follow symbolic links.
*
int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name,
const void *value, size_t size, int flags);
+/**
+ * Set an extended attribute on a file.
+ *
+ * @param cmount the ceph mount handle to use for performing the setxattr.
+ * @param fd the open file descriptor referring to the file to set extended attribute on.
+ * @param name the name of the extended attribute to set.
+ * @param value the bytes of the extended attribute value
+ * @param size the size of the extended attribute value
+ * @param flags the flags can be:
+ * CEPH_XATTR_CREATE: create the extended attribute. Must not exist.
+ * CEPH_XATTR_REPLACE: replace the extended attribute, Must already exist.
+ * @returns 0 on success or a negative error code on failure.
+ */
+int ceph_fsetxattr(struct ceph_mount_info *cmount, int fd, const char *name,
+ const void *value, size_t size, int flags);
+
/**
* Set an extended attribute on a file, do not follow symbolic links.
*
return cmount->get_client()->lgetxattr(path, name, value, size);
}
+extern "C" int ceph_fgetxattr(struct ceph_mount_info *cmount, int fd, const char *name, void *value, size_t size)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ return cmount->get_client()->fgetxattr(fd, name, value, size);
+}
+
+
extern "C" int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size)
{
if (!cmount->is_mounted())
return cmount->get_client()->llistxattr(path, list, size);
}
+extern "C" int ceph_flistxattr(struct ceph_mount_info *cmount, int fd, char *list, size_t size)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ return cmount->get_client()->flistxattr(fd, list, size);
+}
+
extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name)
{
if (!cmount->is_mounted())
return cmount->get_client()->lremovexattr(path, name);
}
+extern "C" int ceph_fremovexattr(struct ceph_mount_info *cmount, int fd, const char *name)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ return cmount->get_client()->fremovexattr(fd, name);
+}
+
extern "C" int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags)
{
if (!cmount->is_mounted())
return -ENOTCONN;
return cmount->get_client()->lsetxattr(path, name, value, size, flags);
}
+
+extern "C" int ceph_fsetxattr(struct ceph_mount_info *cmount, int fd, const char *name, const void *value, size_t size, int flags)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+ return cmount->get_client()->fsetxattr(fd, name, value, size, flags);
+}
/* end xattr support */
extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode)