From patchwork Sun Oct 10 20:31:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 244631 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 o9AKYdmR004512 for ; Sun, 10 Oct 2010 20:37:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750887Ab0JJUhL (ORCPT ); Sun, 10 Oct 2010 16:37:11 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:50864 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750776Ab0JJUhK (ORCPT ); Sun, 10 Oct 2010 16:37:10 -0400 Received: by yxd39 with SMTP id 39so557551yxd.19 for ; Sun, 10 Oct 2010 13:37:09 -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=ua6eKtVdZ/moc/EtWpl792WUpg2iaPpQYl8WA2bz8T0=; b=vs+4WK9xGp/h9Pyp1AhNMu6WLpY8MZxmtFrq5dXENw5RMXrdGnw6UCp1gBkJwsRzvi VCuo7EQaEvmK03YOJW0j/dtvmcpLYk0NfG0c/IDgHSTR0VYciHEcL/IDnBdrtKOfRmYU x/keFTjFp38kHhCwdB5LNTDCgeUU4DVuycZUo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=ZHVgnDy5np/ngscrGQUu2PN3nXrN9s/4uTQXHrJAQuMVxw3XRVQCpXKfxGXIgLC8gu s/acJnhJa8D8VyaPepGOs+i8/IsWgoEBfutWja+aVZggwttYEmI+vcw2Q5OKPHE8nW3H LxNhXXYLr7kgQ6PXL2X5ZTz6hVTDxpKYMt/e0= Received: by 10.150.50.3 with SMTP id x3mr5759423ybx.29.1286743029535; Sun, 10 Oct 2010 13:37:09 -0700 (PDT) Received: from localhost ([32.97.110.58]) by mx.google.com with ESMTPS id z16sm5030546ybm.4.2010.10.10.13.37.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 10 Oct 2010 13:37:08 -0700 (PDT) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Shirish Pargaonkar Subject: [PATCH] CIFS Handle extended attribute name cifsacl to generate cifs acl blob (try #2) Date: Sun, 10 Oct 2010 15:31:56 -0500 Message-Id: <1286742716-4467-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]); Sun, 10 Oct 2010 20:37:11 +0000 (UTC) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index c9b4792..bafe774 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -607,7 +607,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 29a2ee8..229156e 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -134,6 +134,8 @@ extern void 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..6899438 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." @@ -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,23 @@ 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_ACL_XATTR, + strlen(CIFS_ACL_XATTR)) == 0) { + pacl = get_cifs_acl(cifs_sb, direntry->d_inode, + full_path, &acllen); + if (!pacl) { + cERROR(1, "get CIFS ACL xattr error"); + rc = -EIO; + } 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");