From patchwork Thu Nov 11 01:10:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 316152 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 oAB1FaTG017876 for ; Thu, 11 Nov 2010 01:15:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932099Ab0KKBPf (ORCPT ); Wed, 10 Nov 2010 20:15:35 -0500 Received: from mail-qy0-f174.google.com ([209.85.216.174]:34883 "EHLO mail-qy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932078Ab0KKBPe (ORCPT ); Wed, 10 Nov 2010 20:15:34 -0500 Received: by qyk12 with SMTP id 12so3719393qyk.19 for ; Wed, 10 Nov 2010 17:15:34 -0800 (PST) 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=YgDoei7pwoDN/aibVfvQ5NH5ECpBdPlBzUF+fJpIP8E=; b=r0/UearggfWozr/H4snvpLDoBHgp91y/HvL91g6c7ytRe93ZBjpXw+xTHqD2v1jLFY Yr6ssULk2XTQL6HRldj6B8lIJ8bbXkn0mfsrp9MMNMKYdOpdA7NbX2MK8SJt1c7OGK4O E4qel0zzvbXW3jVQWc8NF48PMsVPFBqcYcZuo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=B3nwuqGsztPykYMCdbjHYyqmEbFPUC6U+uBjx2oT6iN8glhmqTY0xdLjuxMxBoV5+k ZAUuwtXRHEajDchnYJmuakSBYef9TjnUhS1f9Kp1HoVd1YFpJ3tGRZOyjhwSSHcYKN55 Sq9N3NJq1hRvdMSt++CI313t+DiwU+4ZfrpHk= Received: by 10.229.105.17 with SMTP id r17mr173327qco.187.1289438133732; Wed, 10 Nov 2010 17:15:33 -0800 (PST) Received: from localhost ([32.97.110.58]) by mx.google.com with ESMTPS id n7sm1297974qcu.4.2010.11.10.17.15.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Nov 2010 17:15:33 -0800 (PST) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com, linux-cifs@vger.kernel.org Cc: Shirish Pargaonkar Subject: [PATCH] cifs: Handle extended attribute name cifs_acl to generate cifs acl blob (try #3) Date: Wed, 10 Nov 2010 19:10:06 -0600 Message-Id: <1289437806-3708-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, 11 Nov 2010 01:15:37 +0000 (UTC) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 91992ab..b54fec0 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -608,7 +608,7 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, } /* Retrieve an ACL from the server */ -static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, +struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, struct inode *inode, const char *path, u32 *pacllen) { diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 6ed59af..a47ffc2 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -134,6 +134,8 @@ extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, struct inode *inode, const char *path, const __u16 *pfid); extern int mode_to_acl(struct inode *inode, const char *path, __u64); +extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *, + const char *, u32 *); extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *, const char *); diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index a264b74..6667d26 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c @@ -30,10 +30,11 @@ #define MAX_EA_VALUE_SIZE 65535 #define CIFS_XATTR_DOS_ATTRIB "user.DosAttrib" +#define CIFS_XATTR_CIFS_ACL "system.cifs_acl" #define CIFS_XATTR_USER_PREFIX "user." #define CIFS_XATTR_SYSTEM_PREFIX "system." #define CIFS_XATTR_OS2_PREFIX "os2." -#define CIFS_XATTR_SECURITY_PREFIX ".security" +#define CIFS_XATTR_SECURITY_PREFIX "security." #define CIFS_XATTR_TRUSTED_PREFIX "trusted." #define XATTR_TRUSTED_PREFIX_LEN 8 #define XATTR_SECURITY_PREFIX_LEN 9 @@ -217,11 +218,13 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, ssize_t rc = -EOPNOTSUPP; #ifdef CONFIG_CIFS_XATTR int xid; + u32 acllen; struct cifs_sb_info *cifs_sb; struct tcon_link *tlink; struct cifsTconInfo *pTcon; struct super_block *sb; char *full_path; + struct cifs_ntsd *pacl; if (direntry == NULL) return -EIO; @@ -277,27 +280,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 +295,24 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, #else cFYI(1, "query POSIX default ACL not supported yet"); #endif + } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, + strlen(CIFS_XATTR_CIFS_ACL)) == 0) { + pacl = get_cifs_acl(cifs_sb, direntry->d_inode, + full_path, &acllen); + if (IS_ERR(pacl)) { + rc = PTR_ERR(pacl); + cERROR(1, "%s: error %zd getting sec desc", + __func__, rc); + } else { + if (ea_value) { + if (acllen > buf_size) + acllen = -ERANGE; + else + memcpy(ea_value, pacl, acllen); + } + rc = acllen; + kfree(pacl); + } } else if (strncmp(ea_name, CIFS_XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0) { cFYI(1, "Trusted xattr namespace not supported yet");