link.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. #define CIFS_MF_SYMLINK_LEN_OFFSET (4+1)
  32. #define CIFS_MF_SYMLINK_MD5_OFFSET (CIFS_MF_SYMLINK_LEN_OFFSET+(4+1))
  33. #define CIFS_MF_SYMLINK_LINK_OFFSET (CIFS_MF_SYMLINK_MD5_OFFSET+(32+1))
  34. #define CIFS_MF_SYMLINK_LINK_MAXLEN (1024)
  35. #define CIFS_MF_SYMLINK_FILE_SIZE \
  36. (CIFS_MF_SYMLINK_LINK_OFFSET + CIFS_MF_SYMLINK_LINK_MAXLEN)
  37. #define CIFS_MF_SYMLINK_LEN_FORMAT "XSym\n%04u\n"
  38. #define CIFS_MF_SYMLINK_MD5_FORMAT \
  39. "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n"
  40. #define CIFS_MF_SYMLINK_MD5_ARGS(md5_hash) \
  41. md5_hash[0], md5_hash[1], md5_hash[2], md5_hash[3], \
  42. md5_hash[4], md5_hash[5], md5_hash[6], md5_hash[7], \
  43. md5_hash[8], md5_hash[9], md5_hash[10], md5_hash[11],\
  44. md5_hash[12], md5_hash[13], md5_hash[14], md5_hash[15]
  45. static int
  46. symlink_hash(unsigned int link_len, const char *link_str, u8 *md5_hash)
  47. {
  48. int rc;
  49. unsigned int size;
  50. struct crypto_shash *md5;
  51. struct sdesc *sdescmd5;
  52. md5 = crypto_alloc_shash("md5", 0, 0);
  53. if (IS_ERR(md5)) {
  54. rc = PTR_ERR(md5);
  55. cERROR(1, "%s: Crypto md5 allocation error %d", __func__, rc);
  56. return rc;
  57. }
  58. size = sizeof(struct shash_desc) + crypto_shash_descsize(md5);
  59. sdescmd5 = kmalloc(size, GFP_KERNEL);
  60. if (!sdescmd5) {
  61. rc = -ENOMEM;
  62. cERROR(1, "%s: Memory allocation failure", __func__);
  63. goto symlink_hash_err;
  64. }
  65. sdescmd5->shash.tfm = md5;
  66. sdescmd5->shash.flags = 0x0;
  67. rc = crypto_shash_init(&sdescmd5->shash);
  68. if (rc) {
  69. cERROR(1, "%s: Could not init md5 shash", __func__);
  70. goto symlink_hash_err;
  71. }
  72. rc = crypto_shash_update(&sdescmd5->shash, link_str, link_len);
  73. if (rc) {
  74. cERROR(1, "%s: Could not update with link_str", __func__);
  75. goto symlink_hash_err;
  76. }
  77. rc = crypto_shash_final(&sdescmd5->shash, md5_hash);
  78. if (rc)
  79. cERROR(1, "%s: Could not generate md5 hash", __func__);
  80. symlink_hash_err:
  81. crypto_free_shash(md5);
  82. kfree(sdescmd5);
  83. return rc;
  84. }
  85. static int
  86. CIFSParseMFSymlink(const u8 *buf,
  87. unsigned int buf_len,
  88. unsigned int *_link_len,
  89. char **_link_str)
  90. {
  91. int rc;
  92. unsigned int link_len;
  93. const char *md5_str1;
  94. const char *link_str;
  95. u8 md5_hash[16];
  96. char md5_str2[34];
  97. if (buf_len != CIFS_MF_SYMLINK_FILE_SIZE)
  98. return -EINVAL;
  99. md5_str1 = (const char *)&buf[CIFS_MF_SYMLINK_MD5_OFFSET];
  100. link_str = (const char *)&buf[CIFS_MF_SYMLINK_LINK_OFFSET];
  101. rc = sscanf(buf, CIFS_MF_SYMLINK_LEN_FORMAT, &link_len);
  102. if (rc != 1)
  103. return -EINVAL;
  104. rc = symlink_hash(link_len, link_str, md5_hash);
  105. if (rc) {
  106. cFYI(1, "%s: MD5 hash failure: %d", __func__, rc);
  107. return rc;
  108. }
  109. snprintf(md5_str2, sizeof(md5_str2),
  110. CIFS_MF_SYMLINK_MD5_FORMAT,
  111. CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
  112. if (strncmp(md5_str1, md5_str2, 17) != 0)
  113. return -EINVAL;
  114. if (_link_str) {
  115. *_link_str = kstrndup(link_str, link_len, GFP_KERNEL);
  116. if (!*_link_str)
  117. return -ENOMEM;
  118. }
  119. *_link_len = link_len;
  120. return 0;
  121. }
  122. static int
  123. CIFSFormatMFSymlink(u8 *buf, unsigned int buf_len, const char *link_str)
  124. {
  125. int rc;
  126. unsigned int link_len;
  127. unsigned int ofs;
  128. u8 md5_hash[16];
  129. if (buf_len != CIFS_MF_SYMLINK_FILE_SIZE)
  130. return -EINVAL;
  131. link_len = strlen(link_str);
  132. if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN)
  133. return -ENAMETOOLONG;
  134. rc = symlink_hash(link_len, link_str, md5_hash);
  135. if (rc) {
  136. cFYI(1, "%s: MD5 hash failure: %d", __func__, rc);
  137. return rc;
  138. }
  139. snprintf(buf, buf_len,
  140. CIFS_MF_SYMLINK_LEN_FORMAT CIFS_MF_SYMLINK_MD5_FORMAT,
  141. link_len,
  142. CIFS_MF_SYMLINK_MD5_ARGS(md5_hash));
  143. ofs = CIFS_MF_SYMLINK_LINK_OFFSET;
  144. memcpy(buf + ofs, link_str, link_len);
  145. ofs += link_len;
  146. if (ofs < CIFS_MF_SYMLINK_FILE_SIZE) {
  147. buf[ofs] = '\n';
  148. ofs++;
  149. }
  150. while (ofs < CIFS_MF_SYMLINK_FILE_SIZE) {
  151. buf[ofs] = ' ';
  152. ofs++;
  153. }
  154. return 0;
  155. }
  156. static int
  157. CIFSCreateMFSymLink(const unsigned int xid, struct cifs_tcon *tcon,
  158. const char *fromName, const char *toName,
  159. struct cifs_sb_info *cifs_sb)
  160. {
  161. int rc;
  162. int oplock = 0;
  163. int remap;
  164. int create_options = CREATE_NOT_DIR;
  165. __u16 netfid = 0;
  166. u8 *buf;
  167. unsigned int bytes_written = 0;
  168. struct cifs_io_parms io_parms;
  169. struct nls_table *nls_codepage;
  170. nls_codepage = cifs_sb->local_nls;
  171. remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR;
  172. buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
  173. if (!buf)
  174. return -ENOMEM;
  175. rc = CIFSFormatMFSymlink(buf, CIFS_MF_SYMLINK_FILE_SIZE, toName);
  176. if (rc != 0) {
  177. kfree(buf);
  178. return rc;
  179. }
  180. if (backup_cred(cifs_sb))
  181. create_options |= CREATE_OPEN_BACKUP_INTENT;
  182. rc = CIFSSMBOpen(xid, tcon, fromName, FILE_CREATE, GENERIC_WRITE,
  183. create_options, &netfid, &oplock, NULL,
  184. nls_codepage, remap);
  185. if (rc != 0) {
  186. kfree(buf);
  187. return rc;
  188. }
  189. io_parms.netfid = netfid;
  190. io_parms.pid = current->tgid;
  191. io_parms.tcon = tcon;
  192. io_parms.offset = 0;
  193. io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
  194. rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, buf, NULL, 0);
  195. CIFSSMBClose(xid, tcon, netfid);
  196. kfree(buf);
  197. if (rc != 0)
  198. return rc;
  199. if (bytes_written != CIFS_MF_SYMLINK_FILE_SIZE)
  200. return -EIO;
  201. return 0;
  202. }
  203. static int
  204. CIFSQueryMFSymLink(const unsigned int xid, struct cifs_tcon *tcon,
  205. const unsigned char *searchName, char **symlinkinfo,
  206. const struct nls_table *nls_codepage, int remap)
  207. {
  208. int rc;
  209. int oplock = 0;
  210. __u16 netfid = 0;
  211. u8 *buf;
  212. char *pbuf;
  213. unsigned int bytes_read = 0;
  214. int buf_type = CIFS_NO_BUFFER;
  215. unsigned int link_len = 0;
  216. struct cifs_io_parms io_parms;
  217. FILE_ALL_INFO file_info;
  218. rc = CIFSSMBOpen(xid, tcon, searchName, FILE_OPEN, GENERIC_READ,
  219. CREATE_NOT_DIR, &netfid, &oplock, &file_info,
  220. nls_codepage, remap);
  221. if (rc != 0)
  222. return rc;
  223. if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
  224. CIFSSMBClose(xid, tcon, netfid);
  225. /* it's not a symlink */
  226. return -EINVAL;
  227. }
  228. buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
  229. if (!buf)
  230. return -ENOMEM;
  231. pbuf = buf;
  232. io_parms.netfid = netfid;
  233. io_parms.pid = current->tgid;
  234. io_parms.tcon = tcon;
  235. io_parms.offset = 0;
  236. io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
  237. rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type);
  238. CIFSSMBClose(xid, tcon, netfid);
  239. if (rc != 0) {
  240. kfree(buf);
  241. return rc;
  242. }
  243. rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, symlinkinfo);
  244. kfree(buf);
  245. if (rc != 0)
  246. return rc;
  247. return 0;
  248. }
  249. bool
  250. CIFSCouldBeMFSymlink(const struct cifs_fattr *fattr)
  251. {
  252. if (!(fattr->cf_mode & S_IFREG))
  253. /* it's not a symlink */
  254. return false;
  255. if (fattr->cf_eof != CIFS_MF_SYMLINK_FILE_SIZE)
  256. /* it's not a symlink */
  257. return false;
  258. return true;
  259. }
  260. int
  261. CIFSCheckMFSymlink(struct cifs_fattr *fattr,
  262. const unsigned char *path,
  263. struct cifs_sb_info *cifs_sb, unsigned int xid)
  264. {
  265. int rc;
  266. int oplock = 0;
  267. __u16 netfid = 0;
  268. struct tcon_link *tlink;
  269. struct cifs_tcon *pTcon;
  270. struct cifs_io_parms io_parms;
  271. u8 *buf;
  272. char *pbuf;
  273. unsigned int bytes_read = 0;
  274. int buf_type = CIFS_NO_BUFFER;
  275. unsigned int link_len = 0;
  276. FILE_ALL_INFO file_info;
  277. if (!CIFSCouldBeMFSymlink(fattr))
  278. /* it's not a symlink */
  279. return 0;
  280. tlink = cifs_sb_tlink(cifs_sb);
  281. if (IS_ERR(tlink))
  282. return PTR_ERR(tlink);
  283. pTcon = tlink_tcon(tlink);
  284. rc = CIFSSMBOpen(xid, pTcon, path, FILE_OPEN, GENERIC_READ,
  285. CREATE_NOT_DIR, &netfid, &oplock, &file_info,
  286. cifs_sb->local_nls,
  287. cifs_sb->mnt_cifs_flags &
  288. CIFS_MOUNT_MAP_SPECIAL_CHR);
  289. if (rc != 0)
  290. goto out;
  291. if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
  292. CIFSSMBClose(xid, pTcon, netfid);
  293. /* it's not a symlink */
  294. goto out;
  295. }
  296. buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
  297. if (!buf) {
  298. rc = -ENOMEM;
  299. goto out;
  300. }
  301. pbuf = buf;
  302. io_parms.netfid = netfid;
  303. io_parms.pid = current->tgid;
  304. io_parms.tcon = pTcon;
  305. io_parms.offset = 0;
  306. io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
  307. rc = CIFSSMBRead(xid, &io_parms, &bytes_read, &pbuf, &buf_type);
  308. CIFSSMBClose(xid, pTcon, netfid);
  309. if (rc != 0) {
  310. kfree(buf);
  311. goto out;
  312. }
  313. rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, NULL);
  314. kfree(buf);
  315. if (rc == -EINVAL) {
  316. /* it's not a symlink */
  317. rc = 0;
  318. goto out;
  319. }
  320. if (rc != 0)
  321. goto out;
  322. /* it is a symlink */
  323. fattr->cf_eof = link_len;
  324. fattr->cf_mode &= ~S_IFMT;
  325. fattr->cf_mode |= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
  326. fattr->cf_dtype = DT_LNK;
  327. out:
  328. cifs_put_tlink(tlink);
  329. return rc;
  330. }
  331. int
  332. cifs_hardlink(struct dentry *old_file, struct inode *inode,
  333. struct dentry *direntry)
  334. {
  335. int rc = -EACCES;
  336. unsigned int xid;
  337. char *from_name = NULL;
  338. char *to_name = NULL;
  339. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  340. struct tcon_link *tlink;
  341. struct cifs_tcon *tcon;
  342. struct TCP_Server_Info *server;
  343. struct cifsInodeInfo *cifsInode;
  344. tlink = cifs_sb_tlink(cifs_sb);
  345. if (IS_ERR(tlink))
  346. return PTR_ERR(tlink);
  347. tcon = tlink_tcon(tlink);
  348. xid = get_xid();
  349. from_name = build_path_from_dentry(old_file);
  350. to_name = build_path_from_dentry(direntry);
  351. if ((from_name == NULL) || (to_name == NULL)) {
  352. rc = -ENOMEM;
  353. goto cifs_hl_exit;
  354. }
  355. if (tcon->unix_ext)
  356. rc = CIFSUnixCreateHardLink(xid, tcon, from_name, to_name,
  357. cifs_sb->local_nls,
  358. cifs_sb->mnt_cifs_flags &
  359. CIFS_MOUNT_MAP_SPECIAL_CHR);
  360. else {
  361. server = tcon->ses->server;
  362. if (!server->ops->create_hardlink)
  363. return -ENOSYS;
  364. rc = server->ops->create_hardlink(xid, tcon, from_name, to_name,
  365. cifs_sb);
  366. if ((rc == -EIO) || (rc == -EINVAL))
  367. rc = -EOPNOTSUPP;
  368. }
  369. d_drop(direntry); /* force new lookup from server of target */
  370. /*
  371. * if source file is cached (oplocked) revalidate will not go to server
  372. * until the file is closed or oplock broken so update nlinks locally
  373. */
  374. if (old_file->d_inode) {
  375. cifsInode = CIFS_I(old_file->d_inode);
  376. if (rc == 0) {
  377. spin_lock(&old_file->d_inode->i_lock);
  378. inc_nlink(old_file->d_inode);
  379. spin_unlock(&old_file->d_inode->i_lock);
  380. /*
  381. * BB should we make this contingent on superblock flag
  382. * NOATIME?
  383. */
  384. /* old_file->d_inode->i_ctime = CURRENT_TIME; */
  385. /*
  386. * parent dir timestamps will update from srv within a
  387. * second, would it really be worth it to set the parent
  388. * dir cifs inode time to zero to force revalidate
  389. * (faster) for it too?
  390. */
  391. }
  392. /*
  393. * if not oplocked will force revalidate to get info on source
  394. * file from srv
  395. */
  396. cifsInode->time = 0;
  397. /*
  398. * Will update parent dir timestamps from srv within a second.
  399. * Would it really be worth it to set the parent dir (cifs
  400. * inode) time field to zero to force revalidate on parent
  401. * directory faster ie
  402. *
  403. * CIFS_I(inode)->time = 0;
  404. */
  405. }
  406. cifs_hl_exit:
  407. kfree(from_name);
  408. kfree(to_name);
  409. free_xid(xid);
  410. cifs_put_tlink(tlink);
  411. return rc;
  412. }
  413. void *
  414. cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
  415. {
  416. struct inode *inode = direntry->d_inode;
  417. int rc = -ENOMEM;
  418. unsigned int xid;
  419. char *full_path = NULL;
  420. char *target_path = NULL;
  421. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  422. struct tcon_link *tlink = NULL;
  423. struct cifs_tcon *tcon;
  424. xid = get_xid();
  425. tlink = cifs_sb_tlink(cifs_sb);
  426. if (IS_ERR(tlink)) {
  427. rc = PTR_ERR(tlink);
  428. tlink = NULL;
  429. goto out;
  430. }
  431. tcon = tlink_tcon(tlink);
  432. /*
  433. * For now, we just handle symlinks with unix extensions enabled.
  434. * Eventually we should handle NTFS reparse points, and MacOS
  435. * symlink support. For instance...
  436. *
  437. * rc = CIFSSMBQueryReparseLinkInfo(...)
  438. *
  439. * For now, just return -EACCES when the server doesn't support posix
  440. * extensions. Note that we still allow querying symlinks when posix
  441. * extensions are manually disabled. We could disable these as well
  442. * but there doesn't seem to be any harm in allowing the client to
  443. * read them.
  444. */
  445. if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) &&
  446. !cap_unix(tcon->ses)) {
  447. rc = -EACCES;
  448. goto out;
  449. }
  450. full_path = build_path_from_dentry(direntry);
  451. if (!full_path)
  452. goto out;
  453. cFYI(1, "Full path: %s inode = 0x%p", full_path, inode);
  454. rc = -EACCES;
  455. /*
  456. * First try Minshall+French Symlinks, if configured
  457. * and fallback to UNIX Extensions Symlinks.
  458. */
  459. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
  460. rc = CIFSQueryMFSymLink(xid, tcon, full_path, &target_path,
  461. cifs_sb->local_nls,
  462. cifs_sb->mnt_cifs_flags &
  463. CIFS_MOUNT_MAP_SPECIAL_CHR);
  464. if ((rc != 0) && cap_unix(tcon->ses))
  465. rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, &target_path,
  466. cifs_sb->local_nls);
  467. kfree(full_path);
  468. out:
  469. if (rc != 0) {
  470. kfree(target_path);
  471. target_path = ERR_PTR(rc);
  472. }
  473. free_xid(xid);
  474. if (tlink)
  475. cifs_put_tlink(tlink);
  476. nd_set_link(nd, target_path);
  477. return NULL;
  478. }
  479. int
  480. cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
  481. {
  482. int rc = -EOPNOTSUPP;
  483. unsigned int xid;
  484. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  485. struct tcon_link *tlink;
  486. struct cifs_tcon *pTcon;
  487. char *full_path = NULL;
  488. struct inode *newinode = NULL;
  489. xid = get_xid();
  490. tlink = cifs_sb_tlink(cifs_sb);
  491. if (IS_ERR(tlink)) {
  492. rc = PTR_ERR(tlink);
  493. goto symlink_exit;
  494. }
  495. pTcon = tlink_tcon(tlink);
  496. full_path = build_path_from_dentry(direntry);
  497. if (full_path == NULL) {
  498. rc = -ENOMEM;
  499. goto symlink_exit;
  500. }
  501. cFYI(1, "Full path: %s", full_path);
  502. cFYI(1, "symname is %s", symname);
  503. /* BB what if DFS and this volume is on different share? BB */
  504. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
  505. rc = CIFSCreateMFSymLink(xid, pTcon, full_path, symname,
  506. cifs_sb);
  507. else if (pTcon->unix_ext)
  508. rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname,
  509. cifs_sb->local_nls);
  510. /* else
  511. rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,
  512. cifs_sb_target->local_nls); */
  513. if (rc == 0) {
  514. if (pTcon->unix_ext)
  515. rc = cifs_get_inode_info_unix(&newinode, full_path,
  516. inode->i_sb, xid);
  517. else
  518. rc = cifs_get_inode_info(&newinode, full_path, NULL,
  519. inode->i_sb, xid, NULL);
  520. if (rc != 0) {
  521. cFYI(1, "Create symlink ok, getinodeinfo fail rc = %d",
  522. rc);
  523. } else {
  524. d_instantiate(direntry, newinode);
  525. }
  526. }
  527. symlink_exit:
  528. kfree(full_path);
  529. cifs_put_tlink(tlink);
  530. free_xid(xid);
  531. return rc;
  532. }
  533. void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
  534. {
  535. char *p = nd_get_link(nd);
  536. if (!IS_ERR(p))
  537. kfree(p);
  538. }