]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
support for xattrs in libceph
authorBrian Chrisman <brchrisman@gmail.com>
Wed, 11 May 2011 17:27:50 +0000 (10:27 -0700)
committerSage Weil <sage@newdream.net>
Wed, 11 May 2011 17:28:17 +0000 (10:28 -0700)
Signed-off-by: Brian Chrisman <brchrisman@gmail.com>
src/client/Client.cc
src/client/Client.h
src/include/ceph/libceph.h
src/libceph.cc

index 30724a4a0293902120b550988f590a97980a87d3..f906fe179f5431820f4789c89be273fa2bb2325f 100644 (file)
@@ -5563,6 +5563,71 @@ int Client::ll_setattr(vinodeno_t vino, struct stat *attr, int mask, int uid, in
 // ----------
 // xattrs
 
+int Client::getxattr(const char *path, const char *name, void *value, size_t size)
+{
+  Mutex::Locker lock(client_lock);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, true);
+  return Client::_getxattr(ceph_inode, name, value, size, getuid(), getgid());
+}
+
+int Client::lgetxattr(const char *path, const char *name, void *value, size_t size)
+{
+  Mutex::Locker lock(client_lock);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, false);
+  return Client::_getxattr(ceph_inode, name, value, size, getuid(), getgid());
+}
+
+int Client::listxattr(const char *path, char *list, size_t size)
+{
+  Mutex::Locker lock(client_lock);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, true);
+  return Client::_listxattr(ceph_inode, list, size, getuid(), getgid());
+}
+
+int Client::llistxattr(const char *path, char *list, size_t size)
+{
+  Mutex::Locker lock(client_lock);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, false);
+  return Client::_listxattr(ceph_inode, list, size, getuid(), getgid());
+}
+
+int Client::removexattr(const char *path, const char *name)
+{
+  Mutex::Locker lock(client_lock);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, true);
+  return Client::_removexattr(ceph_inode, name, getuid(), getgid());
+}
+
+int Client::lremovexattr(const char *path, const char *name)
+{
+  Mutex::Locker lock(client_lock);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, false);
+  return Client::_removexattr(ceph_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);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, true);
+  return Client::_setxattr(ceph_inode, name, value, size, flags, getuid(), getgid());
+}
+
+int Client::lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
+{
+  Mutex::Locker lock(client_lock);
+  Inode *ceph_inode;
+  Client::path_walk(path, &ceph_inode, false);
+  return Client::_setxattr(ceph_inode, name, value, size, flags, getuid(), getgid());
+}
+
+
 int Client::_getxattr(Inode *in, const char *name, void *value, size_t size,
                      int uid, int gid)
 {
index ab21dc89e611d366812941057ad88cc24396881b..b36621db989eb77e3d017ccebd739ade0a263682 100644 (file)
@@ -1258,6 +1258,16 @@ public:
   int fsync(int fd, bool syncdataonly);
   int fstat(int fd, struct stat *stbuf);
 
+  // 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 listxattr(const char *path, char *list, size_t size);
+  int llistxattr(const char *path, char *list, size_t size);
+  int removexattr(const char *path, const char *name);
+  int lremovexattr(const char *path, 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 sync_fs();
   int64_t drop_caches();
 
index 3ed3369367f1a591e380affc05a1b3e0a501bfd9..f9fc29ea1b5cae07deefc2e8289a494bf3fc66ae 100644 (file)
@@ -121,6 +121,21 @@ int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf);
 
 int ceph_sync_fs(struct ceph_mount_info *cmount);
 
+/* xattr support */
+int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       void *value, size_t size);
+int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       void *value, size_t size);
+int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size);
+int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size);
+int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name);
+int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name);
+int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       const void *value, size_t size, int flags);
+int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, 
+       const void *value, size_t size, int flags);
+
+
 
 /* expose file layout */
 int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh);
index d1143d617cbaa97f7d8c3b337e8c5aa085c74e8d..6388bde1f2636aad700dc411ec2bb553b9634623 100644 (file)
@@ -416,6 +416,48 @@ extern "C" int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath,
   return cmount->get_client()->setattr(relpath, attr, mask);
 }
 
+// *xattr() calls supporting samba/vfs
+extern "C" int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size)
+{
+  return cmount->get_client()->getxattr(path, name, value, size);
+}
+
+extern "C" int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size)
+{
+  return cmount->get_client()->lgetxattr(path, name, value, size);
+}
+
+extern "C" int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size)
+{
+  return cmount->get_client()->listxattr(path, list, size);
+}
+
+extern "C" int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size)
+{
+  return cmount->get_client()->llistxattr(path, list, size);
+}
+
+extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name)
+{
+  return cmount->get_client()->removexattr(path, name);
+}
+
+extern "C" int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name)
+{
+  return cmount->get_client()->lremovexattr(path, 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)
+{
+  return cmount->get_client()->setxattr(path, name, value, size, flags);
+}
+
+extern "C" int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags)
+{
+  return cmount->get_client()->lsetxattr(path, name, value, size, flags);
+}
+/* end xattr support */
+
 extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode)
 {
   return cmount->get_client()->chmod(path, mode);