link.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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\n", __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\n", __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\n", __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 iwth link_str\n", __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\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. cFYI(1, "%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. cFYI(1, "%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 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 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, 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. int xid;
  337. char *fromName = NULL;
  338. char *toName = NULL;
  339. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  340. struct tcon_link *tlink;
  341. struct cifs_tcon *pTcon;
  342. struct cifsInodeInfo *cifsInode;
  343. tlink = cifs_sb_tlink(cifs_sb);
  344. if (IS_ERR(tlink))
  345. return PTR_ERR(tlink);
  346. pTcon = tlink_tcon(tlink);
  347. xid = GetXid();
  348. fromName = build_path_from_dentry(old_file);
  349. toName = build_path_from_dentry(direntry);
  350. if ((fromName == NULL) || (toName == NULL)) {
  351. rc = -ENOMEM;
  352. goto cifs_hl_exit;
  353. }
  354. if (pTcon->unix_ext)
  355. rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName,
  356. cifs_sb->local_nls,
  357. cifs_sb->mnt_cifs_flags &
  358. CIFS_MOUNT_MAP_SPECIAL_CHR);
  359. else {
  360. rc = CIFSCreateHardLink(xid, pTcon, fromName, toName,
  361. cifs_sb->local_nls,
  362. cifs_sb->mnt_cifs_flags &
  363. CIFS_MOUNT_MAP_SPECIAL_CHR);
  364. if ((rc == -EIO) || (rc == -EINVAL))
  365. rc = -EOPNOTSUPP;
  366. }
  367. d_drop(direntry); /* force new lookup from server of target */
  368. /* if source file is cached (oplocked) revalidate will not go to server
  369. until the file is closed or oplock broken so update nlinks locally */
  370. if (old_file->d_inode) {
  371. cifsInode = CIFS_I(old_file->d_inode);
  372. if (rc == 0) {
  373. inc_nlink(old_file->d_inode);
  374. /* BB should we make this contingent on superblock flag NOATIME? */
  375. /* old_file->d_inode->i_ctime = CURRENT_TIME;*/
  376. /* parent dir timestamps will update from srv
  377. within a second, would it really be worth it
  378. to set the parent dir cifs inode time to zero
  379. to force revalidate (faster) for it too? */
  380. }
  381. /* if not oplocked will force revalidate to get info
  382. on source file from srv */
  383. cifsInode->time = 0;
  384. /* Will update parent dir timestamps from srv within a second.
  385. Would it really be worth it to set the parent dir (cifs
  386. inode) time field to zero to force revalidate on parent
  387. directory faster ie
  388. CIFS_I(inode)->time = 0; */
  389. }
  390. cifs_hl_exit:
  391. kfree(fromName);
  392. kfree(toName);
  393. FreeXid(xid);
  394. cifs_put_tlink(tlink);
  395. return rc;
  396. }
  397. void *
  398. cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
  399. {
  400. struct inode *inode = direntry->d_inode;
  401. int rc = -ENOMEM;
  402. int xid;
  403. char *full_path = NULL;
  404. char *target_path = NULL;
  405. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  406. struct tcon_link *tlink = NULL;
  407. struct cifs_tcon *tcon;
  408. xid = GetXid();
  409. tlink = cifs_sb_tlink(cifs_sb);
  410. if (IS_ERR(tlink)) {
  411. rc = PTR_ERR(tlink);
  412. tlink = NULL;
  413. goto out;
  414. }
  415. tcon = tlink_tcon(tlink);
  416. /*
  417. * For now, we just handle symlinks with unix extensions enabled.
  418. * Eventually we should handle NTFS reparse points, and MacOS
  419. * symlink support. For instance...
  420. *
  421. * rc = CIFSSMBQueryReparseLinkInfo(...)
  422. *
  423. * For now, just return -EACCES when the server doesn't support posix
  424. * extensions. Note that we still allow querying symlinks when posix
  425. * extensions are manually disabled. We could disable these as well
  426. * but there doesn't seem to be any harm in allowing the client to
  427. * read them.
  428. */
  429. if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
  430. && !(tcon->ses->capabilities & CAP_UNIX)) {
  431. rc = -EACCES;
  432. goto out;
  433. }
  434. full_path = build_path_from_dentry(direntry);
  435. if (!full_path)
  436. goto out;
  437. cFYI(1, "Full path: %s inode = 0x%p", full_path, inode);
  438. rc = -EACCES;
  439. /*
  440. * First try Minshall+French Symlinks, if configured
  441. * and fallback to UNIX Extensions Symlinks.
  442. */
  443. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
  444. rc = CIFSQueryMFSymLink(xid, tcon, full_path, &target_path,
  445. cifs_sb->local_nls,
  446. cifs_sb->mnt_cifs_flags &
  447. CIFS_MOUNT_MAP_SPECIAL_CHR);
  448. if ((rc != 0) && (tcon->ses->capabilities & CAP_UNIX))
  449. rc = CIFSSMBUnixQuerySymLink(xid, tcon, full_path, &target_path,
  450. cifs_sb->local_nls);
  451. kfree(full_path);
  452. out:
  453. if (rc != 0) {
  454. kfree(target_path);
  455. target_path = ERR_PTR(rc);
  456. }
  457. FreeXid(xid);
  458. if (tlink)
  459. cifs_put_tlink(tlink);
  460. nd_set_link(nd, target_path);
  461. return NULL;
  462. }
  463. int
  464. cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
  465. {
  466. int rc = -EOPNOTSUPP;
  467. int xid;
  468. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  469. struct tcon_link *tlink;
  470. struct cifs_tcon *pTcon;
  471. char *full_path = NULL;
  472. struct inode *newinode = NULL;
  473. xid = GetXid();
  474. tlink = cifs_sb_tlink(cifs_sb);
  475. if (IS_ERR(tlink)) {
  476. rc = PTR_ERR(tlink);
  477. goto symlink_exit;
  478. }
  479. pTcon = tlink_tcon(tlink);
  480. full_path = build_path_from_dentry(direntry);
  481. if (full_path == NULL) {
  482. rc = -ENOMEM;
  483. goto symlink_exit;
  484. }
  485. cFYI(1, "Full path: %s", full_path);
  486. cFYI(1, "symname is %s", symname);
  487. /* BB what if DFS and this volume is on different share? BB */
  488. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
  489. rc = CIFSCreateMFSymLink(xid, pTcon, full_path, symname,
  490. cifs_sb);
  491. else if (pTcon->unix_ext)
  492. rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname,
  493. cifs_sb->local_nls);
  494. /* else
  495. rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,
  496. cifs_sb_target->local_nls); */
  497. if (rc == 0) {
  498. if (pTcon->unix_ext)
  499. rc = cifs_get_inode_info_unix(&newinode, full_path,
  500. inode->i_sb, xid);
  501. else
  502. rc = cifs_get_inode_info(&newinode, full_path, NULL,
  503. inode->i_sb, xid, NULL);
  504. if (rc != 0) {
  505. cFYI(1, "Create symlink ok, getinodeinfo fail rc = %d",
  506. rc);
  507. } else {
  508. d_instantiate(direntry, newinode);
  509. }
  510. }
  511. symlink_exit:
  512. kfree(full_path);
  513. cifs_put_tlink(tlink);
  514. FreeXid(xid);
  515. return rc;
  516. }
  517. void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
  518. {
  519. char *p = nd_get_link(nd);
  520. if (!IS_ERR(p))
  521. kfree(p);
  522. }