From patchwork Thu Aug 5 19:50:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 117393 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o75JoYrp000916 for ; Thu, 5 Aug 2010 19:50:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759348Ab0HETuj (ORCPT ); Thu, 5 Aug 2010 15:50:39 -0400 Received: from mo-p05-ob.rzone.de ([81.169.146.180]:21173 "EHLO mo-p05-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759342Ab0HETui (ORCPT ); Thu, 5 Aug 2010 15:50:38 -0400 X-RZG-AUTH: :IXQkeEW8Yfo/5haL0ckzWIsAYh739YBunhBBa3aNBybZ0RbCJ+OqMF3/rQ== X-RZG-CLASS-ID: mo05 Received: from localhost.localdomain (xdsl-78-34-205-218.netcologne.de [78.34.205.218]) by post.strato.de (fruni mo34) (RZmta 23.4) with (EDH-RSA-DES-CBC3-SHA encrypted) ESMTP id j042e2m75IOCMi ; Thu, 5 Aug 2010 21:50:36 +0200 (MEST) From: Stefan Metzmacher To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 3/7] cifs: implement CIFSQueryMFSymLink() Date: Thu, 5 Aug 2010 21:50:17 +0200 Message-Id: <1281037821-11479-4-git-send-email-metze@samba.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: 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 (demeter.kernel.org [140.211.167.41]); Thu, 05 Aug 2010 19:50:39 +0000 (UTC) diff --git a/fs/cifs/link.c b/fs/cifs/link.c index c0aebdb..a8dcc27 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -91,6 +91,56 @@ CIFSParseMFSymlink(const u8 *buf, return 0; } +static int +CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon, + const unsigned char *searchName, char **symlinkinfo, + const struct nls_table *nls_codepage, int remap) +{ + int rc; + int oplock = 0; + __u16 netfid = 0; + u8 *buf; + char *pbuf; + unsigned int bytes_read = 0; + int buf_type = CIFS_NO_BUFFER; + unsigned int link_len = 0; + FILE_ALL_INFO file_info; + + rc = CIFSSMBOpen(xid, tcon, searchName, FILE_OPEN, GENERIC_READ, + CREATE_NOT_DIR, &netfid, &oplock, &file_info, + nls_codepage, remap); + if (rc != 0) + return rc; + + if (file_info.EndOfFile != CIFS_MF_SYMLINK_FILE_SIZE) { + CIFSSMBClose(xid, tcon, netfid); + /* it's not a symlink */ + return -EINVAL; + } + + buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + pbuf = buf; + + rc = CIFSSMBRead(xid, tcon, netfid, + CIFS_MF_SYMLINK_FILE_SIZE /* length */, + 0 /* offset */, + &bytes_read, &pbuf, &buf_type); + CIFSSMBClose(xid, tcon, netfid); + if (rc != 0) { + kfree(buf); + return rc; + } + + rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, symlinkinfo); + kfree(buf); + if (rc != 0) + return rc; + + return 0; +} + int CIFSCheckMFSymlink(struct cifs_fattr *fattr, const unsigned char *path,