Add mfsymlinks support for SMB2.1/SMB3. Part 1 create symlink
[firefly-linux-kernel-4.4.55.git] / fs / cifs / link.c
1 /*
2  *   fs/cifs/link.c
3  *
4  *   Copyright (C) International Business Machines  Corp., 2002,2008
5  *   Author(s): Steve French (sfrench@us.ibm.com)
6  *
7  *   This library is free software; you can redistribute it and/or modify
8  *   it under the terms of the GNU Lesser General Public License as published
9  *   by the Free Software Foundation; either version 2.1 of the License, or
10  *   (at your option) any later version.
11  *
12  *   This library is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
15  *   the GNU Lesser General Public License for more details.
16  *
17  *   You should have received a copy of the GNU Lesser General Public License
18  *   along with this library; if not, write to the Free Software
19  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 #include <linux/fs.h>
22 #include <linux/stat.h>
23 #include <linux/slab.h>
24 #include <linux/namei.h>
25 #include "cifsfs.h"
26 #include "cifspdu.h"
27 #include "cifsglob.h"
28 #include "cifsproto.h"
29 #include "cifs_debug.h"
30 #include "cifs_fs_sb.h"
31 #include "smb2proto.h"
32
33 /*
34  * M-F Symlink Functions - Begin
35  */
36
37 #define CIFS_MF_SYMLINK_LEN_OFFSET (4+1)
38 #define CIFS_MF_SYMLINK_MD5_OFFSET (CIFS_MF_SYMLINK_LEN_OFFSET+(4+1))
39 #define CIFS_MF_SYMLINK_LINK_OFFSET (CIFS_MF_SYMLINK_MD5_OFFSET+(32+1))
40 #define CIFS_MF_SYMLINK_LINK_MAXLEN (1024)
41 #define CIFS_MF_SYMLINK_FILE_SIZE \
42         (CIFS_MF_SYMLINK_LINK_OFFSET + CIFS_MF_SYMLINK_LINK_MAXLEN)
43
44 #define CIFS_MF_SYMLINK_LEN_FORMAT "XSym\n%04u\n"
45 #define CIFS_MF_SYMLINK_MD5_FORMAT \
46         "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n"
47 #define CIFS_MF_SYMLINK_MD5_ARGS(md5_hash) \
48         md5_hash[0],  md5_hash[1],  md5_hash[2],  md5_hash[3], \
49         md5_hash[4],  md5_hash[5],  md5_hash[6],  md5_hash[7], \
50         md5_hash[8],  md5_hash[9],  md5_hash[10], md5_hash[11],\
51         md5_hash[12], md5_hash[13], md5_hash[14], md5_hash[15]
52
53 static int
54 symlink_hash(unsigned int link_len, const char *link_str, u8 *md5_hash)
55 {
56         int rc;
57         unsigned int size;
58         struct crypto_shash *md5;
59         struct sdesc *sdescmd5;
60
61         md5 = crypto_alloc_shash("md5", 0, 0);
62         if (IS_ERR(md5)) {
63                 rc = PTR_ERR(md5);
64                 cifs_dbg(VFS, "%s: Crypto md5 allocation error %d\n",
65                          __func__, rc);
66                 return rc;
67         }
68         size = sizeof(struct shash_desc) + crypto_shash_descsize(md5);
69         sdescmd5 = kmalloc(size, GFP_KERNEL);
70         if (!sdescmd5) {
71                 rc = -ENOMEM;
72                 goto symlink_hash_err;
73         }
74         sdescmd5->shash.tfm = md5;
75         sdescmd5->shash.flags = 0x0;
76
77         rc = crypto_shash_init(&sdescmd5->shash);
78         if (rc) {
79                 cifs_dbg(VFS, "%s: Could not init md5 shash\n", __func__);
80                 goto symlink_hash_err;
81         }
82         rc = crypto_shash_update(&sdescmd5->shash, link_str, link_len);
83         if (rc) {
84                 cifs_dbg(VFS, "%s: Could not update with link_str\n", __func__);
85                 goto symlink_hash_err;
86         }
87         rc = crypto_shash_final(&sdescmd5->shash, md5_hash);
88         if (rc)
89                 cifs_dbg(VFS, "%s: Could not generate md5 hash\n", __func__);
90
91 symlink_hash_err:
92         crypto_free_shash(md5);
93         kfree(sdescmd5);
94
95         return rc;
96 }
97
98 static int
99 parse_mf_symlink(const u8 *buf, unsigned int buf_len, unsigned int *_link_len,
100                  char **_link_str)
101 {
102         int rc;
103         unsigned int link_len;
104         const char *md5_str1;
105         const char *link_str;
106         u8 md5_hash[16];
107         char md5_str2[34];
108
109         if (buf_len != CIFS_MF_SYMLINK_FILE_SIZE)
110                 return -EINVAL;
111
112         md5_str1 = (const char *)&buf[CIFS_MF_SYMLINK_MD5_OFFSET];
113         link_str = (const char *)&buf[CIFS_MF_SYMLINK_LINK_OFFSET];
114
115         rc = sscanf(buf, CIFS_MF_SYMLINK_LEN_FORMAT, &link_len);
116         if (rc != 1)
117                 return -EINVAL;
118
119         rc = symlink_hash(link_len, link_str, md5_hash);
120         if (rc) {
121                 cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __func__, rc);
122                 return rc;
123         }
124
125         snprintf(md5_str2, sizeof(md5_str2),
126                  CIFS_MF_SYMLINK_MD5_FORMAT,
127                  CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
128
129         if (strncmp(md5_str1, md5_str2, 17) != 0)
130                 return -EINVAL;
131
132         if (_link_str) {
133                 *_link_str = kstrndup(link_str, link_len, GFP_KERNEL);
134                 if (!*_link_str)
135                         return -ENOMEM;
136         }
137
138         *_link_len = link_len;
139         return 0;
140 }
141
142 static int
143 format_mf_symlink(u8 *buf, unsigned int buf_len, const char *link_str)
144 {
145         int rc;
146         unsigned int link_len;
147         unsigned int ofs;
148         u8 md5_hash[16];
149
150         if (buf_len != CIFS_MF_SYMLINK_FILE_SIZE)
151                 return -EINVAL;
152
153         link_len = strlen(link_str);
154
155         if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN)
156                 return -ENAMETOOLONG;
157
158         rc = symlink_hash(link_len, link_str, md5_hash);
159         if (rc) {
160                 cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __func__, rc);
161                 return rc;
162         }
163
164         snprintf(buf, buf_len,
165                  CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT,
166                  link_len,
167                  CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
168
169         ofs = CIFS_MF_SYMLINK_LINK_OFFSET;
170         memcpy(buf + ofs, link_str, link_len);
171
172         ofs += link_len;
173         if (ofs < CIFS_MF_SYMLINK_FILE_SIZE) {
174                 buf[ofs] = '\n';
175                 ofs++;
176         }
177
178         while (ofs < CIFS_MF_SYMLINK_FILE_SIZE) {
179                 buf[ofs] = ' ';
180                 ofs++;
181         }
182
183         return 0;
184 }
185
186 bool
187 couldbe_mf_symlink(const struct cifs_fattr *fattr)
188 {
189         if (!S_ISREG(fattr->cf_mode))
190                 /* it's not a symlink */
191                 return false;
192
193         if (fattr->cf_eof != CIFS_MF_SYMLINK_FILE_SIZE)
194                 /* it's not a symlink */
195                 return false;
196
197         return true;
198 }
199
200 static int
201 create_mf_symlink(const unsigned int xid, struct cifs_tcon *tcon,
202                   struct cifs_sb_info *cifs_sb, const char *fromName,
203                   const char *toName)
204 {
205         int rc;
206         u8 *buf;
207         unsigned int bytes_written = 0;
208
209         buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
210         if (!buf)
211                 return -ENOMEM;
212
213         rc = format_mf_symlink(buf, CIFS_MF_SYMLINK_FILE_SIZE, toName);
214         if (rc)
215                 goto out;
216
217         if (tcon->ses->server->ops->create_mf_symlink)
218                 rc = tcon->ses->server->ops->create_mf_symlink(xid, tcon,
219                                         cifs_sb, fromName, buf, &bytes_written);
220         else
221                 rc = -EOPNOTSUPP;
222
223         if (rc)
224                 goto out;
225
226         if (bytes_written != CIFS_MF_SYMLINK_FILE_SIZE)
227                 rc = -EIO;
228 out:
229         kfree(buf);
230         return rc;
231 }
232
233 static int
234 query_mf_symlink(const unsigned int xid, struct cifs_tcon *tcon,
235                  struct cifs_sb_info *cifs_sb, const unsigned char *path,
236                  char **symlinkinfo)
237 {
238         int rc;
239         u8 *buf = NULL;
240         unsigned int link_len = 0;
241         unsigned int bytes_read = 0;
242
243         buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
244         if (!buf)
245                 return -ENOMEM;
246
247         if (tcon->ses->server->ops->query_mf_symlink)
248                 rc = tcon->ses->server->ops->query_mf_symlink(xid, tcon,
249                                               cifs_sb, path, buf, &bytes_read);
250         else
251                 rc = -ENOSYS;
252
253         if (rc)
254                 goto out;
255
256         if (bytes_read == 0) { /* not a symlink */
257                 rc = -EINVAL;
258                 goto out;
259         }
260
261         rc = parse_mf_symlink(buf, bytes_read, &link_len, symlinkinfo);
262 out:
263         kfree(buf);
264         return rc;
265 }
266
267 int
268 check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
269                  struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
270                  const unsigned char *path)
271 {
272         int rc;
273         u8 *buf = NULL;
274         unsigned int link_len = 0;
275         unsigned int bytes_read = 0;
276
277         if (!couldbe_mf_symlink(fattr))
278                 /* it's not a symlink */
279                 return 0;
280
281         buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
282         if (!buf)
283                 return -ENOMEM;
284
285         if (tcon->ses->server->ops->query_mf_symlink)
286                 rc = tcon->ses->server->ops->query_mf_symlink(xid, tcon,
287                                               cifs_sb, path, buf, &bytes_read);
288         else
289                 rc = -ENOSYS;
290
291         if (rc)
292                 goto out;
293
294         if (bytes_read == 0) /* not a symlink */
295                 goto out;
296
297         rc = parse_mf_symlink(buf, bytes_read, &link_len, NULL);
298         if (rc == -EINVAL) {
299                 /* it's not a symlink */
300                 rc = 0;
301                 goto out;
302         }
303
304         if (rc != 0)
305                 goto out;
306
307         /* it is a symlink */
308         fattr->cf_eof = link_len;
309         fattr->cf_mode &= ~S_IFMT;
310         fattr->cf_mode |= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
311         fattr->cf_dtype = DT_LNK;
312 out:
313         kfree(buf);
314         return rc;
315 }
316
317 /*
318  * SMB 1.0 Protocol specific functions
319  */
320
321 int
322 cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
323                       struct cifs_sb_info *cifs_sb, const unsigned char *path,
324                       char *pbuf, unsigned int *pbytes_read)
325 {
326         int rc;
327         int oplock = 0;
328         struct cifs_fid fid;
329         struct cifs_open_parms oparms;
330         struct cifs_io_parms io_parms;
331         int buf_type = CIFS_NO_BUFFER;
332         FILE_ALL_INFO file_info;
333
334         oparms.tcon = tcon;
335         oparms.cifs_sb = cifs_sb;
336         oparms.desired_access = GENERIC_READ;
337         oparms.create_options = CREATE_NOT_DIR;
338         oparms.disposition = FILE_OPEN;
339         oparms.path = path;
340         oparms.fid = &fid;
341         oparms.reconnect = false;
342
343         rc = CIFS_open(xid, &oparms, &oplock, &file_info);
344         if (rc)
345                 return rc;
346
347         if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
348                 rc = -ENOENT;
349                 /* it's not a symlink */
350                 goto out;
351         }
352
353         io_parms.netfid = fid.netfid;
354         io_parms.pid = current->tgid;
355         io_parms.tcon = tcon;
356         io_parms.offset = 0;
357         io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
358
359         rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type);
360 out:
361         CIFSSMBClose(xid, tcon, fid.netfid);
362         return rc;
363 }
364
365 int
366 cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
367                        struct cifs_sb_info *cifs_sb, const unsigned char *path,
368                        char *pbuf, unsigned int *pbytes_written)
369 {
370         int rc;
371         int oplock = 0;
372         struct cifs_fid fid;
373         struct cifs_open_parms oparms;
374         struct cifs_io_parms io_parms;
375         int create_options = CREATE_NOT_DIR;
376
377         if (backup_cred(cifs_sb))
378                 create_options |= CREATE_OPEN_BACKUP_INTENT;
379
380         oparms.tcon = tcon;
381         oparms.cifs_sb = cifs_sb;
382         oparms.desired_access = GENERIC_WRITE;
383         oparms.create_options = create_options;
384         oparms.disposition = FILE_CREATE;
385         oparms.path = path;
386         oparms.fid = &fid;
387         oparms.reconnect = false;
388
389         rc = CIFS_open(xid, &oparms, &oplock, NULL);
390         if (rc)
391                 return rc;
392
393         io_parms.netfid = fid.netfid;
394         io_parms.pid = current->tgid;
395         io_parms.tcon = tcon;
396         io_parms.offset = 0;
397         io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
398
399         rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf, NULL, 0);
400         CIFSSMBClose(xid, tcon, fid.netfid);
401         return rc;
402 }
403
404 int
405 smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
406                        struct cifs_sb_info *cifs_sb, const unsigned char *path,
407                        char *pbuf, unsigned int *pbytes_written)
408 {
409         int rc;
410         struct cifs_fid fid;
411         struct cifs_open_parms oparms;
412         struct cifs_io_parms io_parms;
413         int create_options = CREATE_NOT_DIR;
414         __le16 *utf16_path;
415         __u8 oplock = SMB2_OPLOCK_LEVEL_EXCLUSIVE;
416         struct kvec iov[2];
417
418         if (backup_cred(cifs_sb))
419                 create_options |= CREATE_OPEN_BACKUP_INTENT;
420
421         cifs_dbg(FYI, "%s: path: %s\n", __func__, path);
422
423         utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
424         if (!utf16_path)
425                 return -ENOMEM;
426
427         oparms.tcon = tcon;
428         oparms.cifs_sb = cifs_sb;
429         oparms.desired_access = GENERIC_WRITE;
430         oparms.create_options = create_options;
431         oparms.disposition = FILE_CREATE;
432         oparms.fid = &fid;
433         oparms.reconnect = false;
434
435         rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
436         if (rc) {
437                 kfree(utf16_path);
438                 return rc;
439         }
440
441         io_parms.netfid = fid.netfid;
442         io_parms.pid = current->tgid;
443         io_parms.tcon = tcon;
444         io_parms.offset = 0;
445         io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
446         io_parms.persistent_fid = fid.persistent_fid;
447         io_parms.volatile_fid = fid.volatile_fid;
448
449         /* iov[0] is reserved for smb header */
450         iov[1].iov_base = pbuf;
451         iov[1].iov_len = CIFS_MF_SYMLINK_FILE_SIZE;
452
453         rc = SMB2_write(xid, &io_parms, pbytes_written, iov, 1);
454
455         /* Make sure we wrote all of the symlink data */
456         if ((rc == 0) && (*pbytes_written != CIFS_MF_SYMLINK_FILE_SIZE))
457                 rc = -EIO;
458
459         SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
460
461         kfree(utf16_path);
462         return rc;
463 }
464
465
466 /*
467  * M-F Symlink Functions - End
468  */
469
470 int
471 cifs_hardlink(struct dentry *old_file, struct inode *inode,
472               struct dentry *direntry)
473 {
474         int rc = -EACCES;
475         unsigned int xid;
476         char *from_name = NULL;
477         char *to_name = NULL;
478         struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
479         struct tcon_link *tlink;
480         struct cifs_tcon *tcon;
481         struct TCP_Server_Info *server;
482         struct cifsInodeInfo *cifsInode;
483
484         tlink = cifs_sb_tlink(cifs_sb);
485         if (IS_ERR(tlink))
486                 return PTR_ERR(tlink);
487         tcon = tlink_tcon(tlink);
488
489         xid = get_xid();
490
491         from_name = build_path_from_dentry(old_file);
492         to_name = build_path_from_dentry(direntry);
493         if ((from_name == NULL) || (to_name == NULL)) {
494                 rc = -ENOMEM;
495                 goto cifs_hl_exit;
496         }
497
498         if (tcon->unix_ext)
499                 rc = CIFSUnixCreateHardLink(xid, tcon, from_name, to_name,
500                                             cifs_sb->local_nls,
501                                             cifs_sb->mnt_cifs_flags &
502                                                 CIFS_MOUNT_MAP_SPECIAL_CHR);
503         else {
504                 server = tcon->ses->server;
505                 if (!server->ops->create_hardlink) {
506                         rc = -ENOSYS;
507                         goto cifs_hl_exit;
508                 }
509                 rc = server->ops->create_hardlink(xid, tcon, from_name, to_name,
510                                                   cifs_sb);
511                 if ((rc == -EIO) || (rc == -EINVAL))
512                         rc = -EOPNOTSUPP;
513         }
514
515         d_drop(direntry);       /* force new lookup from server of target */
516
517         /*
518          * if source file is cached (oplocked) revalidate will not go to server
519          * until the file is closed or oplock broken so update nlinks locally
520          */
521         if (old_file->d_inode) {
522                 cifsInode = CIFS_I(old_file->d_inode);
523                 if (rc == 0) {
524                         spin_lock(&old_file->d_inode->i_lock);
525                         inc_nlink(old_file->d_inode);
526                         spin_unlock(&old_file->d_inode->i_lock);
527                         /*
528                          * BB should we make this contingent on superblock flag
529                          * NOATIME?
530                          */
531                         /* old_file->d_inode->i_ctime = CURRENT_TIME; */
532                         /*
533                          * parent dir timestamps will update from srv within a
534                          * second, would it really be worth it to set the parent
535                          * dir cifs inode time to zero to force revalidate
536                          * (faster) for it too?
537                          */
538                 }
539                 /*
540                  * if not oplocked will force revalidate to get info on source
541                  * file from srv
542                  */
543                 cifsInode->time = 0;
544
545                 /*
546                  * Will update parent dir timestamps from srv within a second.
547                  * Would it really be worth it to set the parent dir (cifs
548                  * inode) time field to zero to force revalidate on parent
549                  * directory faster ie
550                  *
551                  * CIFS_I(inode)->time = 0;
552                  */
553         }
554
555 cifs_hl_exit:
556         kfree(from_name);
557         kfree(to_name);
558         free_xid(xid);
559         cifs_put_tlink(tlink);
560         return rc;
561 }
562
563 void *
564 cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
565 {
566         struct inode *inode = direntry->d_inode;
567         int rc = -ENOMEM;
568         unsigned int xid;
569         char *full_path = NULL;
570         char *target_path = NULL;
571         struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
572         struct tcon_link *tlink = NULL;
573         struct cifs_tcon *tcon;
574         struct TCP_Server_Info *server;
575
576         xid = get_xid();
577
578         tlink = cifs_sb_tlink(cifs_sb);
579         if (IS_ERR(tlink)) {
580                 rc = PTR_ERR(tlink);
581                 tlink = NULL;
582                 goto out;
583         }
584         tcon = tlink_tcon(tlink);
585         server = tcon->ses->server;
586
587         full_path = build_path_from_dentry(direntry);
588         if (!full_path)
589                 goto out;
590
591         cifs_dbg(FYI, "Full path: %s inode = 0x%p\n", full_path, inode);
592
593         rc = -EACCES;
594         /*
595          * First try Minshall+French Symlinks, if configured
596          * and fallback to UNIX Extensions Symlinks.
597          */
598         if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
599                 rc = query_mf_symlink(xid, tcon, cifs_sb, full_path,
600                                       &target_path);
601
602         if (rc != 0 && server->ops->query_symlink)
603                 rc = server->ops->query_symlink(xid, tcon, full_path,
604                                                 &target_path, cifs_sb);
605
606         kfree(full_path);
607 out:
608         if (rc != 0) {
609                 kfree(target_path);
610                 target_path = ERR_PTR(rc);
611         }
612
613         free_xid(xid);
614         if (tlink)
615                 cifs_put_tlink(tlink);
616         nd_set_link(nd, target_path);
617         return NULL;
618 }
619
620 int
621 cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
622 {
623         int rc = -EOPNOTSUPP;
624         unsigned int xid;
625         struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
626         struct tcon_link *tlink;
627         struct cifs_tcon *pTcon;
628         char *full_path = NULL;
629         struct inode *newinode = NULL;
630
631         xid = get_xid();
632
633         tlink = cifs_sb_tlink(cifs_sb);
634         if (IS_ERR(tlink)) {
635                 rc = PTR_ERR(tlink);
636                 goto symlink_exit;
637         }
638         pTcon = tlink_tcon(tlink);
639
640         full_path = build_path_from_dentry(direntry);
641         if (full_path == NULL) {
642                 rc = -ENOMEM;
643                 goto symlink_exit;
644         }
645
646         cifs_dbg(FYI, "Full path: %s\n", full_path);
647         cifs_dbg(FYI, "symname is %s\n", symname);
648
649         /* BB what if DFS and this volume is on different share? BB */
650         if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
651                 rc = create_mf_symlink(xid, pTcon, cifs_sb, full_path, symname);
652         else if (pTcon->unix_ext)
653                 rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname,
654                                            cifs_sb->local_nls);
655         /* else
656            rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,
657                                         cifs_sb_target->local_nls); */
658
659         if (rc == 0) {
660                 if (pTcon->unix_ext)
661                         rc = cifs_get_inode_info_unix(&newinode, full_path,
662                                                       inode->i_sb, xid);
663                 else
664                         rc = cifs_get_inode_info(&newinode, full_path, NULL,
665                                                  inode->i_sb, xid, NULL);
666
667                 if (rc != 0) {
668                         cifs_dbg(FYI, "Create symlink ok, getinodeinfo fail rc = %d\n",
669                                  rc);
670                 } else {
671                         d_instantiate(direntry, newinode);
672                 }
673         }
674 symlink_exit:
675         kfree(full_path);
676         cifs_put_tlink(tlink);
677         free_xid(xid);
678         return rc;
679 }