From patchwork Thu Oct 7 14:03:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 238261 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 o97E8axD025897 for ; Thu, 7 Oct 2010 14:08:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760668Ab0JGOIg (ORCPT ); Thu, 7 Oct 2010 10:08:36 -0400 Received: from mail-qw0-f46.google.com ([209.85.216.46]:47044 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760557Ab0JGOIg (ORCPT ); Thu, 7 Oct 2010 10:08:36 -0400 Received: by qwf7 with SMTP id 7so55734qwf.19 for ; Thu, 07 Oct 2010 07:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=GoQUQBjnUOj+rnr6lU89TFwvYKq52y3E5cRZaU48VkE=; b=wcMpLLFxO42bwZA+vmj/fmr1iNm/Q/9E33UL2mTnrz63jMTfmDqwr7wGOFaqAUBKhQ CJuJWfGLVR6xnVlYnMw1r/8/Qfzx0ZvTqwGgpHcbOhVzlxWGeEf4078+6crnzyrleNK2 DpMVMhcESoP231vy4/NDOx6uFg1KrRJrMBrQY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=pBIq6nlMBeCOLz07XADvOBq12M7hARmaQW52il9NbUxozi7rMaI27IE4LkACVlIJDB NwnG8o4O1FNujPLN9De5n9k08r29L9LTOcxIIKg5Zyw4RHoTequlRKEOmQxv8OaGn+SW 1Jmk5iQmj5KaqYCzQprL5iu97INgxNpDN0YzA= Received: by 10.229.189.211 with SMTP id df19mr796645qcb.146.1286460515227; Thu, 07 Oct 2010 07:08:35 -0700 (PDT) Received: from localhost ([32.97.110.58]) by mx.google.com with ESMTPS id l13sm1293605qck.7.2010.10.07.07.08.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 07 Oct 2010 07:08:34 -0700 (PDT) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Shirish Pargaonkar Subject: [PATCH] handle extended attribute name cifsacl to generate cifs acl blob Date: Thu, 7 Oct 2010 09:03:27 -0500 Message-Id: <1286460207-4024-1-git-send-email-shirishpargaonkar@gmail.com> X-Mailer: git-send-email 1.6.0.2 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 07 Oct 2010 14:08:37 +0000 (UTC) diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index a264b74..eaf836f 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c @@ -30,6 +30,7 @@ #define MAX_EA_VALUE_SIZE 65535 #define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib" +#define CIFS_ACL_XATTR "system.cifsacl" #define CIFS_XATTR_USER_PREFIX "user." #define CIFS_XATTR_SYSTEM_PREFIX "system." #define CIFS_XATTR_OS2_PREFIX "os2." @@ -100,6 +101,42 @@ remove_ea_exit: return rc; } +static int +get_cifs_acl(int xid, struct cifsTconInfo *pTcon, char *full_path, + void *ea_value, size_t size, struct nls_table *nls_cp) +{ + __u16 fid; + int rc; + int oplock = 0; + unsigned int acllen = 0; + struct cifs_ntsd *pacl = NULL; + + rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, GENERIC_READ, + 0, &fid, &oplock, NULL, nls_cp, 0); + if (rc) { + cERROR(1, "%s: file open error: %d", __func__, rc); + return rc; + } + + rc = CIFSSMBGetCIFSACL(xid, pTcon, fid, &pacl, &acllen); + CIFSSMBClose(xid, pTcon, fid); + if (rc) { + cERROR(1, "%s: get acl error: %d", __func__, rc); + return rc; + } + + if (ea_value) { + if (acllen > size) { + kfree(pacl); + return -ERANGE; + } + memcpy(ea_value, pacl, acllen); + kfree(pacl); + } + + return acllen; +} + int cifs_setxattr(struct dentry *direntry, const char *ea_name, const void *ea_value, size_t value_size, int flags) { @@ -277,27 +314,6 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); -#ifdef CONFIG_CIFS_EXPERIMENTAL - else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { - __u16 fid; - int oplock = 0; - struct cifs_ntsd *pacl = NULL; - __u32 buflen = 0; - if (experimEnabled) - rc = CIFSSMBOpen(xid, pTcon, full_path, - FILE_OPEN, GENERIC_READ, 0, &fid, - &oplock, NULL, cifs_sb->local_nls, - cifs_sb->mnt_cifs_flags & - CIFS_MOUNT_MAP_SPECIAL_CHR); - /* else rc is EOPNOTSUPP from above */ - - if (rc == 0) { - rc = CIFSSMBGetCIFSACL(xid, pTcon, fid, &pacl, - &buflen); - CIFSSMBClose(xid, pTcon, fid); - } - } -#endif /* EXPERIMENTAL */ #else cFYI(1, "query POSIX ACL not supported yet"); #endif /* CONFIG_CIFS_POSIX */ @@ -313,6 +329,12 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, #else cFYI(1, "query POSIX default ACL not supported yet"); #endif +#ifdef CONFIG_CIFS_EXPERIMENTAL + } else if (strncmp(ea_name, CIFS_ACL_XATTR, + strlen(CIFS_ACL_XATTR)) == 0) { + rc = get_cifs_acl(xid, pTcon, full_path, ea_value, + buf_size, cifs_sb->local_nls); +#endif /* CONFIG_CIFS_EXPERIMENTAL */ } else if (strncmp(ea_name, CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) { cFYI(1, "Trusted xattr namespace not supported yet");