From patchwork Tue May 10 19:38:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Chrisman X-Patchwork-Id: 775152 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4AJfYMR007439 for ; Tue, 10 May 2011 19:41:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751429Ab1EJTlg (ORCPT ); Tue, 10 May 2011 15:41:36 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:52767 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750986Ab1EJTlg (ORCPT ); Tue, 10 May 2011 15:41:36 -0400 Received: by pvg12 with SMTP id 12so2967952pvg.19 for ; Tue, 10 May 2011 12:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=iUoXweWlnRRmBGYvIzm4kFZS9GVhlq2e1pKLBPpzRus=; b=mjdxZKUu4VoYDMH2LtGEnUXCtvCrWFfQ6w0WkfzO1kk24BFJgXpNs5Swjd/GJT5N21 1uTezfMgi7sph5by1f+eIpe8IouaKmcy1mt4pLH43BmcQvNE6mYVy1DPi8KGX0IfrYw/ Bpzv1X/wZJdoZURbMFO4DxkDVZ8Xfs3DiW5l8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=dvP9Ro5w9hnULkOav6pUsQmduKn7LpIFyAcnD16hxf9ChYPVxniP2Gtoa+tcPWWckR a9Xlj/KInB8UjcaO7QOIhSEEz2c3UPf5XbQ/6wlYT1hKSrdWXhMJhbGSIappfJjv9WcF cVks2gf/ad4NwpOuKhayfcXT+6TtOT4fr+zJ0= Received: by 10.68.57.168 with SMTP id j8mr4620255pbq.111.1305056495780; Tue, 10 May 2011 12:41:35 -0700 (PDT) Received: from localhost.localdomain ([70.35.37.146]) by mx.google.com with ESMTPS id v8sm4995171pbk.95.2011.05.10.12.41.34 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 May 2011 12:41:34 -0700 (PDT) From: Brian Chrisman To: ceph-devel@vger.kernel.org Cc: Brian Chrisman , Brian Chrisman Subject: [PATCH 1/2] support for xattrs in libceph Date: Tue, 10 May 2011 12:38:48 -0700 Message-Id: <1305056329-482-2-git-send-email-brchrisman@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1305056329-482-1-git-send-email-brchrisman@gmail.com> References: <1305056329-482-1-git-send-email-brchrisman@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 10 May 2011 19:41:37 +0000 (UTC) From: Brian Chrisman Signed-off-by: Brian Chrisman --- src/client/Client.cc | 67 +++++++++++++++++++++++++++++++++++++++++++- src/client/Client.h | 10 ++++++ src/include/ceph/libceph.h | 15 ++++++++++ src/libceph.cc | 42 +++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 1 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 6a27273..5083e99 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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) { @@ -5708,7 +5773,7 @@ int Client::ll_removexattr(vinodeno_t vino, const char *name, int uid, int gid) tout << name << std::endl; // only user xattrs, for now - if (strncmp(name, "user.", 5)) + if (strncmp(name, "user.", 5) && strncmp(name, "security.", 9) && strncmp(name, "trusted.", 8)) return -EOPNOTSUPP; Inode *in = _ll_get_inode(vino); diff --git a/src/client/Client.h b/src/client/Client.h index ab21dc8..b36621d 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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(); diff --git a/src/include/ceph/libceph.h b/src/include/ceph/libceph.h index 3ed3369..f9fc29e 100644 --- a/src/include/ceph/libceph.h +++ b/src/include/ceph/libceph.h @@ -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); diff --git a/src/libceph.cc b/src/libceph.cc index d1143d6..6388bde 100644 --- a/src/libceph.cc +++ b/src/libceph.cc @@ -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);