From patchwork Wed Aug 4 14:11:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Metzmacher X-Patchwork-Id: 117049 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 o74ECAal020389 for ; Wed, 4 Aug 2010 14:15:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758041Ab0HDOMN (ORCPT ); Wed, 4 Aug 2010 10:12:13 -0400 Received: from mo-p05-ob.rzone.de ([81.169.146.180]:42419 "EHLO mo-p05-ob.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758047Ab0HDOMN (ORCPT ); Wed, 4 Aug 2010 10:12:13 -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 c04253m74DdRcr ; Wed, 4 Aug 2010 16:12:10 +0200 (MEST) From: Stefan Metzmacher To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Stefan Metzmacher Subject: [PATCH 7/8] cifs: implement CIFSFormatMFSymlink() Date: Wed, 4 Aug 2010 16:11:48 +0200 Message-Id: <1280931109-22380-8-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:15:30 +0000 (UTC) diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 6d00712..89e09da 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -92,6 +92,48 @@ CIFSParseMFSymlink(const u8 *buf, } static int +CIFSFormatMFSymlink(u8 *buf, unsigned int buf_len, const char *link_str) +{ + unsigned int link_len; + unsigned int ofs; + struct MD5Context md5_ctx; + u8 md5_hash[16]; + + if (buf_len != CIFS_MF_SYMLINK_FILE_SIZE) + return -EINVAL; + + link_len = strlen(link_str); + + if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN) + return -ENAMETOOLONG; + + cifs_MD5_init(&md5_ctx); + cifs_MD5_update(&md5_ctx, (const u8 *)link_str, link_len); + cifs_MD5_final(md5_hash, &md5_ctx); + + snprintf(buf, buf_len, + CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT, + link_len, + CIFS_MF_SYMLINK_MD5_ARGS(md5_hash)); + + ofs = CIFS_MF_SYMLINK_LINK_OFFSET; + memcpy(buf + ofs, link_str, link_len); + + ofs += link_len; + if (ofs < CIFS_MF_SYMLINK_FILE_SIZE) { + buf[ofs] = '\n'; + ofs++; + } + + while (ofs < CIFS_MF_SYMLINK_FILE_SIZE) { + buf[ofs] = ' '; + ofs++; + } + + return 0; +} + +static int CIFSCreateMFSymLink(const int xid, struct cifsTconInfo *tcon, const char *fromName, const char *toName, const struct nls_table *nls_codepage)