From patchwork Tue Aug 3 15:05:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 116789 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 o73F6Tha013664 for ; Tue, 3 Aug 2010 15:06:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932133Ab0HCPG0 (ORCPT ); Tue, 3 Aug 2010 11:06:26 -0400 Received: from mo-p05-ob.rzone.de ([81.169.146.181]:12214 "EHLO mo-p05-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932123Ab0HCPG0 (ORCPT ); Tue, 3 Aug 2010 11:06:26 -0400 X-RZG-AUTH: :IXQkeEW8Yfo/5haL0ckzWIsAYh739YBunhBBa3aCCCbZv/tD854XGrpZ X-RZG-CLASS-ID: mo05 Received: from localhost.localdomain (xdsl-87-79-184-42.netcologne.de [87.79.184.42]) by post.strato.de (jimi mo39) (RZmta 23.4) with (DHE-RSA-AES256-SHA encrypted) ESMTP id q0292dm73DmAJa ; Tue, 3 Aug 2010 17:06:23 +0200 (MEST) From: Stefan Metzmacher To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 6/8] cifs: implement CIFSQueryMFSymLink() Date: Tue, 3 Aug 2010 17:05:58 +0200 Message-Id: <1280847960-16371-7-git-send-email-metze@samba.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280847960-16371-1-git-send-email-metze@samba.org> References: <1280847960-16371-1-git-send-email-metze@samba.org> 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]); Tue, 03 Aug 2010 15:06:30 +0000 (UTC) diff --git a/fs/cifs/link.c b/fs/cifs/link.c index f7636f9..77f5a40 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -102,10 +102,46 @@ CIFSCreateMFSymLink(const int xid, struct cifsTconInfo *tcon, static int CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon, const unsigned char *searchName, char **symlinkinfo, - const struct nls_table *nls_codepage) + const struct nls_table *nls_codepage, int remap) { - int rc = -EOPNOTSUPP; - return rc; + int rc; + int oplock = 0; + __u16 netfid = 0; + u8 buf[CIFS_MF_SYMLINK_FILE_SIZE]; + char *pbuf = buf; + 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; + } + + 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) { + return rc; + } + + rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, symlinkinfo); + if (rc != 0) { + return rc; + } + + return 0; } int @@ -291,7 +327,9 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) rc = CIFSQueryMFSymLink(xid, tcon, full_path, &target_path, - cifs_sb->local_nls); + cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags & + CIFS_MOUNT_MAP_SPECIAL_CHR); else rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, &target_path, cifs_sb->local_nls);