From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756555AbbIUNz3 (ORCPT ); Mon, 21 Sep 2015 09:55:29 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:59687 "EHLO e28smtp07.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756221AbbIUNz1 (ORCPT ); Mon, 21 Sep 2015 09:55:27 -0400 X-Helo: d28dlp01.in.ibm.com X-MailFrom: aneesh.kumar@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org From: "Aneesh Kumar K.V" To: Andreas Gruenbacher , Alexander Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Artem Bityutskiy , Adrian Hunter , linux-mtd@lists.infradead.org, Richard Weinberger , Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , v9fs-developer@lists.sourceforge.net Subject: Re: [PATCH 3/5] 9p: Simplify the xattr handlers In-Reply-To: <1441367842-25079-4-git-send-email-agruenba@redhat.com> References: <1441367842-25079-1-git-send-email-agruenba@redhat.com> <1441367842-25079-4-git-send-email-agruenba@redhat.com> User-Agent: Notmuch/0.20.2 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Mon, 21 Sep 2015 13:00:57 +0530 Message-ID: <87pp1cdya6.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15092113-0025-0000-0000-00000711A772 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andreas Gruenbacher writes: > The generic_{get,set,remove}xattr inode operations use the xattr name prefix to > decide which of the defined xattr handlers to call, then call the appropriate > handler's get or set operation. The name suffix is passed to the get or set > operations, the prefix is still "there" in the name before the suffix though. > There is no need to recompose the name in a temporary buffer. > > Signed-off-by: Andreas Gruenbacher > --- > fs/9p/xattr_security.c | 34 ++++------------------------------ > fs/9p/xattr_trusted.c | 34 ++++------------------------------ > fs/9p/xattr_user.c | 34 ++++------------------------------ > 3 files changed, 12 insertions(+), 90 deletions(-) > > diff --git a/fs/9p/xattr_security.c b/fs/9p/xattr_security.c > index cb247a1..2c9b394 100644 > --- a/fs/9p/xattr_security.c > +++ b/fs/9p/xattr_security.c > @@ -22,10 +22,7 @@ > static int v9fs_xattr_security_get(struct dentry *dentry, const char *name, > void *buffer, size_t size, int type) > { > - int retval; > - char *full_name; > - size_t name_len; > - size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; > + const char *full_name = name - XATTR_SECURITY_PREFIX_LEN; > > if (name == NULL) > return -EINVAL; > @@ -33,26 +30,13 @@ static int v9fs_xattr_security_get(struct dentry *dentry, const char *name, > if (strcmp(name, "") == 0) > return -EINVAL; > > - name_len = strlen(name); > - full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL); > - if (!full_name) > - return -ENOMEM; > - memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len); > - memcpy(full_name+prefix_len, name, name_len); > - full_name[prefix_len + name_len] = '\0'; > - > - retval = v9fs_xattr_get(dentry, full_name, buffer, size); > - kfree(full_name); > - return retval; > + return v9fs_xattr_get(dentry, full_name, buffer, size); > } > I look strange, to expect that name argument passed to ->get() will have the full name details. In any case this need more documentation and a helper as Christoph suggested -aneesh