| 437 | } |
| 438 | |
| 439 | static int |
| 440 | namei_getpath(struct nameidata *ndp) |
| 441 | { |
| 442 | struct componentname *cnp; |
| 443 | int error; |
| 444 | |
| 445 | cnp = &ndp->ni_cnd; |
| 446 | |
| 447 | /* |
| 448 | * Get a buffer for the name to be translated, and copy the |
| 449 | * name into the buffer. |
| 450 | */ |
| 451 | cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK); |
| 452 | if (ndp->ni_segflg == UIO_SYSSPACE) { |
| 453 | error = copystr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, |
| 454 | &ndp->ni_pathlen); |
| 455 | } else { |
| 456 | error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, |
| 457 | &ndp->ni_pathlen); |
| 458 | } |
| 459 | |
| 460 | if (__predict_false(error != 0)) { |
| 461 | namei_cleanup_cnp(cnp); |
| 462 | return (error); |
| 463 | } |
| 464 | |
| 465 | /* |
| 466 | * Don't allow empty pathnames. |
| 467 | */ |
| 468 | if (__predict_false(*cnp->cn_pnbuf == '\0')) { |
| 469 | namei_cleanup_cnp(cnp); |
| 470 | return (ENOENT); |
| 471 | } |
| 472 | |
| 473 | cnp->cn_nameptr = cnp->cn_pnbuf; |
| 474 | return (0); |
| 475 | } |
| 476 | |
| 477 | /* |
| 478 | * Convert a pathname into a pointer to a locked vnode. |
no test coverage detected