MCPcopy Create free account
hub / github.com/F-Stack/f-stack / namei_getpath

Function namei_getpath

freebsd/kern/vfs_lookup.c:439–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

437}
438
439static int
440namei_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.

Callers 1

nameiFunction · 0.85

Calls 4

copystrFunction · 0.85
namei_cleanup_cnpFunction · 0.85
uma_zallocFunction · 0.50
copyinstrFunction · 0.50

Tested by

no test coverage detected