aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/link.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-08-03 05:24:22 -0400
committerSteve French <sfrench@us.ibm.com>2010-09-29 15:04:30 -0400
commit18bddd1059c5d1e17ad6e49c514c95484aa80a33 (patch)
tree1c57174579d54d536dd269a22f2458bc500825dd /fs/cifs/link.c
parent0fd43ae4758b2841656afda4439b80e8a3603af2 (diff)
cifs: implement CIFSFormatMFSymlink()
Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/link.c')
-rw-r--r--fs/cifs/link.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 6e4e8957595d..0473a86031a5 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -92,6 +92,47 @@ CIFSParseMFSymlink(const u8 *buf,
92} 92}
93 93
94static int 94static int
95CIFSFormatMFSymlink(u8 *buf, unsigned int buf_len, const char *link_str)
96{
97 unsigned int link_len;
98 unsigned int ofs;
99 struct MD5Context md5_ctx;
100 u8 md5_hash[16];
101
102 if (buf_len != CIFS_MF_SYMLINK_FILE_SIZE)
103 return -EINVAL;
104
105 link_len = strlen(link_str);
106
107 if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN)
108 return -ENAMETOOLONG;
109
110 cifs_MD5_init(&md5_ctx);
111 cifs_MD5_update(&md5_ctx, (const u8 *)link_str, link_len);
112 cifs_MD5_final(md5_hash, &md5_ctx);
113
114 snprintf(buf, buf_len,
115 CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT,
116 link_len,
117 CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
118
119 ofs = CIFS_MF_SYMLINK_LINK_OFFSET;
120 memcpy(buf + ofs, link_str, link_len);
121
122 ofs += link_len;
123 if (ofs < CIFS_MF_SYMLINK_FILE_SIZE) {
124 buf[ofs] = '\n';
125 ofs++;
126 }
127
128 while (ofs < CIFS_MF_SYMLINK_FILE_SIZE) {
129 buf[ofs] = ' ';
130 ofs++;
131 }
132
133 return 0;
134}
135
95CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon, 136CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon,
96 const unsigned char *searchName, char **symlinkinfo, 137 const unsigned char *searchName, char **symlinkinfo,
97 const struct nls_table *nls_codepage, int remap) 138 const struct nls_table *nls_codepage, int remap)