link.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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. cifs_dbg(VFS, "%s: Crypto md5 allocation error %d\n",
  56. __func__, rc);
  57. return rc;
  58. }
  59. size = sizeof(struct shash_desc) + crypto_shash_descsize(md5);
  60. sdescmd5 = kmalloc(size, GFP_KERNEL);
  61. if (!sdescmd5) {
  62. rc = -ENOMEM;
  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. cifs_dbg(VFS, "%s: Could not init md5 shash\n", __func__);
  70. goto symlink_hash_err;
  71. }
  72. rc = crypto_shash_update(&sdescmd5->shash, link_str, link_len);
  73. if (rc) {
  74. cifs_dbg(VFS, "%s: Could not update with link_str\n", __func__);
  75. goto symlink_hash_err;
  76. }
  77. rc = crypto_shash_final(&sdescmd5->shash, md5_hash);
  78. if (rc)
  79. cifs_dbg(VFS, "%s: Could not generate md5 hash\n", __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. cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __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. cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __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. open_query_close_cifs_symlink(const unsigned char *path, char *pbuf,
  262. unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
  263. 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. int buf_type = CIFS_NO_BUFFER;
  272. FILE_ALL_INFO file_info;
  273. tlink = cifs_sb_tlink(cifs_sb);
  274. if (IS_ERR(tlink))
  275. return PTR_ERR(tlink);
  276. ptcon = tlink_tcon(tlink);
  277. rc = CIFSSMBOpen(xid, ptcon, path, FILE_OPEN, GENERIC_READ,
  278. CREATE_NOT_DIR, &netfid, &oplock, &file_info,
  279. cifs_sb->local_nls,
  280. cifs_sb->mnt_cifs_flags &
  281. CIFS_MOUNT_MAP_SPECIAL_CHR);
  282. if (rc != 0) {
  283. cifs_put_tlink(tlink);
  284. return rc;
  285. }
  286. if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
  287. CIFSSMBClose(xid, ptcon, netfid);
  288. cifs_put_tlink(tlink);
  289. /* it's not a symlink */
  290. return rc;
  291. }
  292. io_parms.netfid = netfid;
  293. io_parms.pid = current->tgid;
  294. io_parms.tcon = ptcon;
  295. io_parms.offset = 0;
  296. io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE;
  297. rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type);
  298. CIFSSMBClose(xid, ptcon, netfid);
  299. cifs_put_tlink(tlink);
  300. return rc;
  301. }
  302. int
  303. CIFSCheckMFSymlink(struct cifs_fattr *fattr,
  304. const unsigned char *path,
  305. struct cifs_sb_info *cifs_sb, unsigned int xid)
  306. {
  307. int rc = 0;
  308. u8 *buf = NULL;
  309. unsigned int link_len = 0;
  310. unsigned int bytes_read = 0;
  311. struct cifs_tcon *ptcon;
  312. if (!CIFSCouldBeMFSymlink(fattr))
  313. /* it's not a symlink */
  314. return 0;
  315. buf = kmalloc(CIFS_MF_SYMLINK_FILE_SIZE, GFP_KERNEL);
  316. if (!buf) {
  317. rc = -ENOMEM;
  318. goto out;
  319. }
  320. ptcon = tlink_tcon(cifs_sb_tlink(cifs_sb));
  321. if ((ptcon->ses) && (ptcon->ses->server->ops->query_mf_symlink))
  322. rc = ptcon->ses->server->ops->query_mf_symlink(path, buf,
  323. &bytes_read, cifs_sb, xid);
  324. else
  325. goto out;
  326. if (rc != 0)
  327. goto out;
  328. if (bytes_read == 0) /* not a symlink */
  329. goto out;
  330. rc = CIFSParseMFSymlink(buf, bytes_read, &link_len, NULL);
  331. if (rc == -EINVAL) {
  332. /* it's not a symlink */
  333. rc = 0;
  334. goto out;
  335. }
  336. if (rc != 0)
  337. goto out;
  338. /* it is a symlink */
  339. fattr->cf_eof = link_len;
  340. fattr->cf_mode &= ~S_IFMT;
  341. fattr->cf_mode |= S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
  342. fattr->cf_dtype = DT_LNK;
  343. out:
  344. kfree(buf);
  345. return rc;
  346. }
  347. int
  348. cifs_hardlink(struct dentry *old_file, struct inode *inode,
  349. struct dentry *direntry)
  350. {
  351. int rc = -EACCES;
  352. unsigned int xid;
  353. char *from_name = NULL;
  354. char *to_name = NULL;
  355. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  356. struct tcon_link *tlink;
  357. struct cifs_tcon *tcon;
  358. struct TCP_Server_Info *server;
  359. struct cifsInodeInfo *cifsInode;
  360. tlink = cifs_sb_tlink(cifs_sb);
  361. if (IS_ERR(tlink))
  362. return PTR_ERR(tlink);
  363. tcon = tlink_tcon(tlink);
  364. xid = get_xid();
  365. from_name = build_path_from_dentry(old_file);
  366. to_name = build_path_from_dentry(direntry);
  367. if ((from_name == NULL) || (to_name == NULL)) {
  368. rc = -ENOMEM;
  369. goto cifs_hl_exit;
  370. }
  371. if (tcon->unix_ext)
  372. rc = CIFSUnixCreateHardLink(xid, tcon, from_name, to_name,
  373. cifs_sb->local_nls,
  374. cifs_sb->mnt_cifs_flags &
  375. CIFS_MOUNT_MAP_SPECIAL_CHR);
  376. else {
  377. server = tcon->ses->server;
  378. if (!server->ops->create_hardlink)
  379. return -ENOSYS;
  380. rc = server->ops->create_hardlink(xid, tcon, from_name, to_name,
  381. cifs_sb);
  382. if ((rc == -EIO) || (rc == -EINVAL))
  383. rc = -EOPNOTSUPP;
  384. }
  385. d_drop(direntry); /* force new lookup from server of target */
  386. /*
  387. * if source file is cached (oplocked) revalidate will not go to server
  388. * until the file is closed or oplock broken so update nlinks locally
  389. */
  390. if (old_file->d_inode) {
  391. cifsInode = CIFS_I(old_file->d_inode);
  392. if (rc == 0) {
  393. spin_lock(&old_file->d_inode->i_lock);
  394. inc_nlink(old_file->d_inode);
  395. spin_unlock(&old_file->d_inode->i_lock);
  396. /*
  397. * BB should we make this contingent on superblock flag
  398. * NOATIME?
  399. */
  400. /* old_file->d_inode->i_ctime = CURRENT_TIME; */
  401. /*
  402. * parent dir timestamps will update from srv within a
  403. * second, would it really be worth it to set the parent
  404. * dir cifs inode time to zero to force revalidate
  405. * (faster) for it too?
  406. */
  407. }
  408. /*
  409. * if not oplocked will force revalidate to get info on source
  410. * file from srv
  411. */
  412. cifsInode->time = 0;
  413. /*
  414. * Will update parent dir timestamps from srv within a second.
  415. * Would it really be worth it to set the parent dir (cifs
  416. * inode) time field to zero to force revalidate on parent
  417. * directory faster ie
  418. *
  419. * CIFS_I(inode)->time = 0;
  420. */
  421. }
  422. cifs_hl_exit:
  423. kfree(from_name);
  424. kfree(to_name);
  425. free_xid(xid);
  426. cifs_put_tlink(tlink);
  427. return rc;
  428. }
  429. void *
  430. cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
  431. {
  432. struct inode *inode = direntry->d_inode;
  433. int rc = -ENOMEM;
  434. unsigned int xid;
  435. char *full_path = NULL;
  436. char *target_path = NULL;
  437. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  438. struct tcon_link *tlink = NULL;
  439. struct cifs_tcon *tcon;
  440. struct TCP_Server_Info *server;
  441. xid = get_xid();
  442. tlink = cifs_sb_tlink(cifs_sb);
  443. if (IS_ERR(tlink)) {
  444. rc = PTR_ERR(tlink);
  445. tlink = NULL;
  446. goto out;
  447. }
  448. tcon = tlink_tcon(tlink);
  449. server = tcon->ses->server;
  450. full_path = build_path_from_dentry(direntry);
  451. if (!full_path)
  452. goto out;
  453. cifs_dbg(FYI, "Full path: %s inode = 0x%p\n", 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. else if (rc != 0 && server->ops->query_symlink)
  468. rc = server->ops->query_symlink(xid, tcon, full_path,
  469. &target_path, cifs_sb);
  470. kfree(full_path);
  471. out:
  472. if (rc != 0) {
  473. kfree(target_path);
  474. target_path = ERR_PTR(rc);
  475. }
  476. free_xid(xid);
  477. if (tlink)
  478. cifs_put_tlink(tlink);
  479. nd_set_link(nd, target_path);
  480. return NULL;
  481. }
  482. int
  483. cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
  484. {
  485. int rc = -EOPNOTSUPP;
  486. unsigned int xid;
  487. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  488. struct tcon_link *tlink;
  489. struct cifs_tcon *pTcon;
  490. char *full_path = NULL;
  491. struct inode *newinode = NULL;
  492. xid = get_xid();
  493. tlink = cifs_sb_tlink(cifs_sb);
  494. if (IS_ERR(tlink)) {
  495. rc = PTR_ERR(tlink);
  496. goto symlink_exit;
  497. }
  498. pTcon = tlink_tcon(tlink);
  499. full_path = build_path_from_dentry(direntry);
  500. if (full_path == NULL) {
  501. rc = -ENOMEM;
  502. goto symlink_exit;
  503. }
  504. cifs_dbg(FYI, "Full path: %s\n", full_path);
  505. cifs_dbg(FYI, "symname is %s\n", symname);
  506. /* BB what if DFS and this volume is on different share? BB */
  507. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
  508. rc = CIFSCreateMFSymLink(xid, pTcon, full_path, symname,
  509. cifs_sb);
  510. else if (pTcon->unix_ext)
  511. rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname,
  512. cifs_sb->local_nls);
  513. /* else
  514. rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,
  515. cifs_sb_target->local_nls); */
  516. if (rc == 0) {
  517. if (pTcon->unix_ext)
  518. rc = cifs_get_inode_info_unix(&newinode, full_path,
  519. inode->i_sb, xid);
  520. else
  521. rc = cifs_get_inode_info(&newinode, full_path, NULL,
  522. inode->i_sb, xid, NULL);
  523. if (rc != 0) {
  524. cifs_dbg(FYI, "Create symlink ok, getinodeinfo fail rc = %d\n",
  525. rc);
  526. } else {
  527. d_instantiate(direntry, newinode);
  528. }
  529. }
  530. symlink_exit:
  531. kfree(full_path);
  532. cifs_put_tlink(tlink);
  533. free_xid(xid);
  534. return rc;
  535. }
  536. void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
  537. {
  538. char *p = nd_get_link(nd);
  539. if (!IS_ERR(p))
  540. kfree(p);
  541. }