From patchwork Mon Nov 8 15:47:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 308702 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 oA8Fqipc022549 for ; Mon, 8 Nov 2010 15:52:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752122Ab0KHPwh (ORCPT ); Mon, 8 Nov 2010 10:52:37 -0500 Received: from mail-gw0-f46.google.com ([74.125.83.46]:39437 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751439Ab0KHPwh (ORCPT ); Mon, 8 Nov 2010 10:52:37 -0500 Received: by gwj21 with SMTP id 21so3428724gwj.19 for ; Mon, 08 Nov 2010 07:52:36 -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=emlLrnBrGEH21o2ak/qFQD7cK4NYfLMeA3jrUi3LLEo=; b=sIzC9FIELJasXmmf/V+UQ41u5atljj+FYuChyreOtDDUHjqTkIXjOC6B5HpGONCqxa IleZDcZvbwhDdXaQF6GqgdSxq+Dmpuvrag+R+daMcGdc1hWa9fdjknDXbTTJ2xtnq2/0 eQ4TE6pJ9BdN8DDtywfIUXnqyu64FGXUcvoGQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=J1LE11pfTxoEhw1ep/SvqBPFCApiNzdVi+ys3wUHpq5jWIIqunX82NHONDCO0+9Rar HyTAlFF77xExpxy6nzjVfEtrbMK34CXYEp/CKkHb65U0Q+jUDG0c4ef3cN5r65QiPfcI NfRiYah2qzZoTVBRFtVHGgVpgyV7M1zSZvFMs= Received: by 10.239.189.2 with SMTP id r2mr107436hbh.50.1289231555777; Mon, 08 Nov 2010 07:52:35 -0800 (PST) Received: from localhost ([32.97.110.58]) by mx.google.com with ESMTPS id q3sm10005vcr.27.2010.11.08.07.52.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 08 Nov 2010 07:52:34 -0800 (PST) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com, linux-cifs@vger.kernel.org Cc: Shirish Pargaonkar Subject: [PATCH] cifs: Percolate errors up to the caller during get/set acls Date: Mon, 8 Nov 2010 09:47:18 -0600 Message-Id: <1289231238-15203-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]); Mon, 08 Nov 2010 15:52:45 +0000 (UTC) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index c9b4792..8c260b9 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -552,38 +552,40 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, return rc; } -static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, - __u16 fid, u32 *pacllen) +static int +get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, + __u16 fid, u32 *pacllen, struct cifs_ntsd **pntsd) { - struct cifs_ntsd *pntsd = NULL; - int xid, rc; + int xid; + int rc = 0; struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); if (IS_ERR(tlink)) - return NULL; + PTR_ERR(tlink); xid = GetXid(); - rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen); + rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, pntsd, pacllen); FreeXid(xid); cifs_put_tlink(tlink); cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); - return pntsd; + return rc; } -static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, - const char *path, u32 *pacllen) +static int +get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path, + u32 *pacllen, struct cifs_ntsd **pntsd) { - struct cifs_ntsd *pntsd = NULL; int oplock = 0; - int xid, rc; + int xid; + int rc = 0; __u16 fid; struct cifsTconInfo *tcon; struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); if (IS_ERR(tlink)) - return NULL; + return PTR_ERR(tlink); tcon = tlink_tcon(tlink); xid = GetXid(); @@ -596,32 +598,34 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, goto out; } - rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); + rc = CIFSSMBGetCIFSACL(xid, tcon, fid, pntsd, pacllen); cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); CIFSSMBClose(xid, tcon, fid); out: cifs_put_tlink(tlink); FreeXid(xid); - return pntsd; + return rc; } /* Retrieve an ACL from the server */ -static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, - struct inode *inode, const char *path, - u32 *pacllen) +static int +get_cifs_acl(struct cifs_sb_info *cifs_sb, struct inode *inode, + const char *path, u32 *pacllen, struct cifs_ntsd **pntsd) { - struct cifs_ntsd *pntsd = NULL; + int rc = 0; struct cifsFileInfo *open_file = NULL; if (inode) open_file = find_readable_file(CIFS_I(inode), true); - if (!open_file) - return get_cifs_acl_by_path(cifs_sb, path, pacllen); + if (open_file) { + rc = get_cifs_acl_by_fid(cifs_sb, open_file->netfid, pacllen, + pntsd); + cifsFileInfo_put(open_file); + } else + rc = get_cifs_acl_by_path(cifs_sb, path, pacllen, pntsd); - pntsd = get_cifs_acl_by_fid(cifs_sb, open_file->netfid, pacllen); - cifsFileInfo_put(open_file); - return pntsd; + return rc; } static int set_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, __u16 fid, @@ -686,11 +690,13 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, cFYI(DBG2, "set ACL for %s from mode 0x%x", path, inode->i_mode); open_file = find_readable_file(CIFS_I(inode), true); - if (!open_file) - return set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen); + if (open_file) { + rc = set_cifs_acl_by_fid(cifs_sb, open_file->netfid, pnntsd, + acllen); + cifsFileInfo_put(open_file); + } else + rc = set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen); - rc = set_cifs_acl_by_fid(cifs_sb, open_file->netfid, pnntsd, acllen); - cifsFileInfo_put(open_file); return rc; } @@ -706,15 +712,18 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, cFYI(DBG2, "converting ACL to mode for %s", path); if (pfid) - pntsd = get_cifs_acl_by_fid(cifs_sb, *pfid, &acllen); + rc = get_cifs_acl_by_fid(cifs_sb, *pfid, &acllen, &pntsd); else - pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); + rc = get_cifs_acl(cifs_sb, inode, path, &acllen, &pntsd); /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ - if (pntsd) - rc = parse_sec_desc(pntsd, acllen, fattr); if (rc) - cFYI(1, "parse sec desc failed rc = %d", rc); + cFYI(1, "%s: get acl failed rc: %d", __func__, rc); + else { + rc = parse_sec_desc(pntsd, acllen, fattr); + if (rc) + cFYI(1, "%s: parse sec desc fail rc: %d", __func__, rc); + } kfree(pntsd); return; @@ -731,12 +740,15 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) cFYI(DBG2, "set ACL from mode for %s", path); /* Get the security descriptor */ - pntsd = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen); + rc = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen, + &pntsd); /* Add three ACEs for owner, group, everyone getting rid of other ACEs as chmod disables ACEs and set the security descriptor */ - if (pntsd) { + if (rc) + cFYI(DBG2, "%s: get cifs acl failed rc: %d", __func__, rc); + else { /* allocate memory for the smb header, set security descriptor request security descriptor parameters, and secuirty descriptor itself */ @@ -760,10 +772,10 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) cFYI(DBG2, "set_cifs_acl rc: %d", rc); } - kfree(pnntsd); - kfree(pntsd); } + kfree(pnntsd); + kfree(pntsd); return rc; } #endif /* CONFIG_CIFS_EXPERIMENTAL */