From patchwork Wed Aug 4 14:11:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 117051 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 o74ECAam020389 for ; Wed, 4 Aug 2010 14:15:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758076Ab0HDOMP (ORCPT ); Wed, 4 Aug 2010 10:12:15 -0400 Received: from mo-p05-ob.rzone.de ([81.169.146.180]:42475 "EHLO mo-p05-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758047Ab0HDOMP (ORCPT ); Wed, 4 Aug 2010 10:12:15 -0400 X-RZG-AUTH: :IXQkeEW8Yfo/5haL0ckzWIsAYh739YBunhBBa3aNBybZ0RbCJO+qMzncuA== X-RZG-CLASS-ID: mo05 Received: from localhost.localdomain (xdsl-78-34-239-115.netcologne.de [78.34.239.115]) by post.strato.de (fruni mo33) (RZmta 23.4) with (EDH-RSA-DES-CBC3-SHA encrypted) ESMTP id c04253m74DdRcs ; Wed, 4 Aug 2010 16:12:12 +0200 (MEST) From: Stefan Metzmacher To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 8/8] cifs: implement CIFSCreateMFSymLink() Date: Wed, 4 Aug 2010 16:11:49 +0200 Message-Id: <1280931109-22380-9-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]); Wed, 04 Aug 2010 14:16:03 +0000 (UTC) diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 89e09da..7fecd4f 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -136,10 +136,45 @@ CIFSFormatMFSymlink(u8 *buf, unsigned int buf_len, const char *link_str) static int CIFSCreateMFSymLink(const int xid, struct cifsTconInfo *tcon, const char *fromName, const char *toName, - 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; + 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 @@ -430,7 +465,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) /* BB what if DFS and this volume is on different share? BB */ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) rc = CIFSCreateMFSymLink(xid, pTcon, full_path, symname, - cifs_sb->local_nls); + cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags & + CIFS_MOUNT_MAP_SPECIAL_CHR); else if (pTcon->unix_ext) rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, cifs_sb->local_nls);