From patchwork Mon Aug 9 17:07:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 118430 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 o79H7HtD004237 for ; Mon, 9 Aug 2010 17:07:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757165Ab0HIRHf (ORCPT ); Mon, 9 Aug 2010 13:07:35 -0400 Received: from mo-p05-ob.rzone.de ([81.169.146.180]:64437 "EHLO mo-p05-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757178Ab0HIRHe (ORCPT ); Mon, 9 Aug 2010 13:07:34 -0400 X-RZG-AUTH: :IXQkeEW8Yfo/5haL0ckzWIsAYh739YBunhBBa3aCCCbZv/tK/4QIFiQT X-RZG-CLASS-ID: mo05 Received: from localhost.localdomain (xdsl-87-79-84-185.netcologne.de [87.79.84.185]) by post.strato.de (mrclete mo45) (RZmta 23.4) with (EDH-RSA-DES-CBC3-SHA encrypted) ESMTP id 600304m79Go2DT ; Mon, 9 Aug 2010 19:07:32 +0200 (MEST) From: Stefan Metzmacher To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 5/7] cifs: implement CIFSCreateMFSymLink() Date: Mon, 9 Aug 2010 19:07:13 +0200 Message-Id: <1281373635-16202-6-git-send-email-metze@samba.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1281373635-16202-5-git-send-email-metze@samba.org> References: <1281373635-16202-1-git-send-email-metze@samba.org> <1281373635-16202-2-git-send-email-metze@samba.org> <1281373635-16202-3-git-send-email-metze@samba.org> <1281373635-16202-4-git-send-email-metze@samba.org> <1281373635-16202-5-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]); Mon, 09 Aug 2010 17:07:35 +0000 (UTC) diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 0473a86..1b2a8c9 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -133,6 +133,51 @@ CIFSFormatMFSymlink(u8 *buf, unsigned int buf_len, const char *link_str) return 0; } +static int +CIFSCreateMFSymLink(const int xid, struct cifsTconInfo *tcon, + const char *fromName, const char *toName, + const struct nls_table *nls_codepage, int remap) +{ + int rc; + int oplock = 0; + __u16 netfid = 0; + u8 *buf; + unsigned int bytes_written = 0; + + buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + rc = CIFSFormatMFSymlink(buf, CIFS_MF_SYMLINK_FILE_SIZE, toName); + if (rc != 0) { + kfree(buf); + return rc; + } + + rc = CIFSSMBOpen(xid, tcon, fromName, FILE_CREATE, GENERIC_WRITE, + CREATE_NOT_DIR, &netfid, &oplock, NULL, + nls_codepage, remap); + if (rc != 0) { + kfree(buf); + return rc; + } + + rc = CIFSSMBWrite(xid, tcon, netfid, + CIFS_MF_SYMLINK_FILE_SIZE /* length */, + 0 /* offset */, + &bytes_written, buf, NULL, 0); + CIFSSMBClose(xid, tcon, netfid); + kfree(buf); + if (rc != 0) + return rc; + + if (bytes_written != CIFS_MF_SYMLINK_FILE_SIZE) + return -EIO; + + 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)