From 6b2621a4868a7e1b5e66feae50643833cfd3ba66 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 3 Aug 2010 11:24:22 +0200 Subject: [PATCH] --- yaml --- r: 213396 b: refs/heads/master c: 18bddd1059c5d1e17ad6e49c514c95484aa80a33 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/cifs/link.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index ec25f861a20c..7f7c8143fd7c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0fd43ae4758b2841656afda4439b80e8a3603af2 +refs/heads/master: 18bddd1059c5d1e17ad6e49c514c95484aa80a33 diff --git a/trunk/fs/cifs/link.c b/trunk/fs/cifs/link.c index 6e4e8957595d..0473a86031a5 100644 --- a/trunk/fs/cifs/link.c +++ b/trunk/fs/cifs/link.c @@ -92,6 +92,47 @@ 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; +} + CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon, const unsigned char *searchName, char **symlinkinfo, const struct nls_table *nls_codepage, int remap)