Lines Matching defs:ndp

114 boolean_t 	lookup_continue_ok(struct nameidata *ndp);
115 int lookup_traverse_mountpoints(struct nameidata *ndp, struct componentname *cnp, vnode_t dp, int vbusyflags, vfs_context_t ctx);
116 int lookup_handle_symlink(struct nameidata *ndp, vnode_t *new_dp, vfs_context_t ctx);
119 int lookup_handle_rsrc_fork(vnode_t dp, struct nameidata *ndp, struct componentname *cnp, int wantparent, vfs_context_t ctx);
120 int lookup_handle_found_vnode(struct nameidata *ndp, struct componentname *cnp, int rdonly,
123 int lookup_handle_emptyname(struct nameidata *ndp, struct componentname *cnp, int wantparent);
161 namei(struct nameidata *ndp)
165 struct vnode *usedvp = ndp->ni_dvp; /* store pointer to vp in case we must loop due to
167 u_long cnpflags = ndp->ni_cnd.cn_flags; /* store in case we have to restore after loop */
169 struct componentname *cnp = &ndp->ni_cnd;
192 if (ndp->ni_flag & NAMEI_CONTLOOKUP) {
200 ndp->ni_flag &= ~(NAMEI_CONTLOOKUP);
202 error = lookup_handle_found_vnode(ndp, &ndp->ni_cnd, rdonly, vbusyflags,
203 &keep_going, ndp->ni_ncgeneration, wantparent, 0, ctx);
208 panic("We need to keep going on a continued lookup, but for vp type %d (tag %d)\n", ndp->ni_vp->v_type, ndp->ni_vp->v_tag);
224 cnp->cn_pnbuf = ndp->ni_pathbuf;
228 if ((UIO_SEG_IS_USER_SPACE(ndp->ni_segflg) == 0)
229 && (ndp->ni_segflg != UIO_SYSSPACE)
230 && (ndp->ni_segflg != UIO_SYSSPACE32)) {
236 if (UIO_SEG_IS_USER_SPACE(ndp->ni_segflg)) {
237 error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf,
238 cnp->cn_pnlen, (size_t *)&ndp->ni_pathlen);
240 error = copystr(CAST_DOWN(void *, ndp->ni_dirp), cnp->cn_pnbuf,
241 cnp->cn_pnlen, (size_t *)&ndp->ni_pathlen);
265 if (ndp->ni_pathlen >= VOLFS_MIN_PATH_LEN &&
295 ndp->ni_pathlen = strlen(realpath) + 1;
317 ndp->ni_loopcnt = 0;
322 if ((ndp->ni_rootdir = fdp->fd_rdir) == NULLVP) {
324 ndp->ni_rootdir = rootvnode;
328 ndp->ni_usedvp = NULLVP;
333 ndp->ni_pathlen--;
335 dp = ndp->ni_rootdir;
337 dp = ndp->ni_dvp;
338 ndp->ni_usedvp = dp;
346 ndp->ni_dvp = NULLVP;
347 ndp->ni_vp = NULLVP;
350 ndp->ni_startdir = dp;
352 if ( (error = lookup(ndp)) ) {
364 error = lookup_handle_symlink(ndp, &dp, ctx);
376 if (ndp->ni_dvp)
377 vnode_put(ndp->ni_dvp);
378 if (ndp->ni_vp)
379 vnode_put(ndp->ni_vp);
386 ndp->ni_vp = NULLVP;
387 ndp->ni_dvp = NULLVP;
391 ndp->ni_cnd.cn_flags = cnpflags;
392 ndp->ni_dvp = usedvp;
401 namei_compound_available(vnode_t dp, struct nameidata *ndp)
403 if ((ndp->ni_flag & NAMEI_COMPOUNDOPEN) != 0) {
474 lookup_handle_rsrc_fork(vnode_t dp, struct nameidata *ndp, struct componentname *cnp, int wantparent, vfs_context_t ctx)
526 if (ndp->ni_dvp) {
528 if (ndp->ni_cnd.cn_flags & FSNODELOCKHELD) {
529 ndp->ni_cnd.cn_flags &= ~FSNODELOCKHELD;
530 unlock_fsnode(ndp->ni_dvp, NULL);
533 vnode_put(ndp->ni_dvp);
535 ndp->ni_dvp = dp;
539 ndp->ni_vp = svp; /* on create this may be null */
542 if (ndp->ni_pathlen == 1 && ndp->ni_next[0] == '\0') {
543 ndp->ni_next[0] = '/';
568 lookup_handle_found_vnode(struct nameidata *ndp, struct componentname *cnp, int rdonly,
576 dp = ndp->ni_vp;
579 if (ndp->ni_vp == NULLVP) {
589 error = vnode_trigger_resolve(dp, ndp, ctx);
602 ndp->ni_next += cnp->cn_consume;
603 ndp->ni_pathlen -= cnp->cn_consume;
606 lookup_consider_update_cache(ndp->ni_dvp, dp, cnp, nc_generation);
612 * Updates ndp->ni_vp.
614 error = lookup_traverse_mountpoints(ndp, cnp, dp, vbusyflags, ctx);
615 dp = ndp->ni_vp;
632 ((cnp->cn_flags & FOLLOW) || (ndp->ni_flag & NAMEI_TRAILINGSLASH) || *ndp->ni_next == '/')) {
641 if ((ndp->ni_flag & NAMEI_TRAILINGSLASH)) {
646 ndp->ni_flag &= ~(NAMEI_TRAILINGSLASH);
668 if (*ndp->ni_next == '/') {
669 cnp->cn_nameptr = ndp->ni_next + 1;
670 ndp->ni_pathlen--;
673 ndp->ni_pathlen--;
677 vnode_put(ndp->ni_dvp);
678 ndp->ni_dvp = NULLVP;
705 if ( (vnode_get(ndp->ni_dvp)) ) {
709 ndp->ni_startdir = ndp->ni_dvp;
711 if (!wantparent && ndp->ni_dvp) {
712 vnode_put(ndp->ni_dvp);
713 ndp->ni_dvp = NULLVP;
726 error = lookup_handle_rsrc_fork(dp, ndp, cnp, wantparent, ctx);
730 dp = ndp->ni_vp;
739 error = lookup_handle_emptyname(ndp, cnp, wantparent);
753 lookup_handle_emptyname(struct nameidata *ndp, struct componentname *cnp, int wantparent)
758 dp = ndp->ni_vp;
783 ndp->ni_dvp = dp;
787 ndp->ni_next = cnp->cn_nameptr;
788 ndp->ni_vp = dp;
826 * identify next component of name at ndp->ni_ptr
858 lookup(struct nameidata *ndp)
868 struct componentname *cnp = &ndp->ni_cnd;
888 dp = ndp->ni_startdir;
889 ndp->ni_startdir = NULLVP;
901 ndp->ni_vp = dp;
902 error = lookup_handle_emptyname(ndp, cnp, wantparent);
911 ndp->ni_vp = NULLVP;
913 if ( (error = cache_lookup_path(ndp, cnp, dp, ctx, &dp_authorized, last_dp)) ) {
923 dp = ndp->ni_dvp;
925 if (ndp->ni_vp != NULLVP) {
954 if (dp == ndp->ni_rootdir || dp == rootvnode) {
955 ndp->ni_dvp = dp;
956 ndp->ni_vp = dp;
989 ndp->ni_dvp = dp;
998 ndp->ni_vp = NULLVP;
1016 if ((cnp->cn_flags & ISLASTCN) && namei_compound_available(dp, ndp) && !(cnp->cn_flags & CN_WANTSRSRCFORK)) {
1018 if ((cnp->cn_flags & ISLASTCN) && namei_compound_available(dp, ndp)) {
1020 ndp->ni_flag |= NAMEI_UNFINISHED;
1021 ndp->ni_ncgeneration = dp->v_nc_generation;
1027 error = VNOP_LOOKUP(dp, &ndp->ni_vp, cnp, ctx);
1051 ndp->ni_dvp = dp;
1059 if (ndp->ni_vp != NULLVP)
1062 error = lookup_validate_creation_path(ndp);
1068 * referenced directory vnode in ndp->ni_dvp.
1071 if ( (vnode_get(ndp->ni_dvp)) ) {
1075 ndp->ni_startdir = ndp->ni_dvp;
1078 vnode_put(ndp->ni_dvp);
1081 kdebug_lookup(ndp->ni_dvp, cnp);
1086 error = lookup_handle_found_vnode(ndp, cnp, rdonly, vbusyflags, &keep_going, nc_generation, wantparent, atroot, ctx);
1092 dp = ndp->ni_vp;
1096 ((cnp->cn_flags & FOLLOW) || (ndp->ni_flag & NAMEI_TRAILINGSLASH) || *ndp->ni_next == '/')) {
1116 unlock_fsnode(ndp->ni_dvp, NULL);
1119 if (ndp->ni_dvp)
1120 vnode_put(ndp->ni_dvp);
1122 vnode_put(ndp->ni_vp);
1123 ndp->ni_vp = NULLVP;
1133 unlock_fsnode(ndp->ni_dvp, NULL);
1138 ndp->ni_vp = NULLVP;
1146 lookup_validate_creation_path(struct nameidata *ndp)
1148 struct componentname *cnp = &ndp->ni_cnd;
1157 if ((cnp->cn_flags & ISLASTCN) && (ndp->ni_flag & NAMEI_TRAILINGSLASH) && !(cnp->cn_flags & WILLBEDIR)) {
1168 lookup_traverse_mountpoints(struct nameidata *ndp, struct componentname *cnp, vnode_t dp,
1190 (void) vnode_trigger_resolve(dp, ndp, ctx);
1239 ndp->ni_vp = dp = tdp;
1247 error = vnode_trigger_resolve(dp, ndp, ctx);
1283 lookup_handle_symlink(struct nameidata *ndp, vnode_t *new_dp, vfs_context_t ctx)
1291 struct componentname *cnp = &ndp->ni_cnd;
1298 unlock_fsnode(ndp->ni_dvp, NULL);
1302 if (ndp->ni_loopcnt++ >= MAXSYMLINKS) {
1306 if ((error = mac_vnode_check_readlink(ctx, ndp->ni_vp)) != 0)
1309 if (ndp->ni_pathlen > 1 || !(cnp->cn_flags & HASBUF))
1326 error = VNOP_READLINK(ndp->ni_vp, auio, ctx);
1339 if (linklen + ndp->ni_pathlen > MAXPATHLEN) {
1349 bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen);
1360 ndp->ni_pathlen += linklen;
1367 dp = ndp->ni_dvp;
1372 vnode_put(ndp->ni_vp);
1373 vnode_put(ndp->ni_dvp); /* ALWAYS have a dvp for a symlink */
1375 ndp->ni_vp = NULLVP;
1376 ndp->ni_dvp = NULLVP;
1384 ndp->ni_pathlen--;
1386 if ((dp = ndp->ni_rootdir) == NULLVP) {
1472 * (possibly locked) directory inode in ndp->ni_dvp.
1494 /* ASSERT(dvp == ndp->ni_startdir) */
1507 namei_unlock_fsnode(struct nameidata *ndp)
1510 if ((ndp->ni_cnd.cn_flags & FSNODELOCKHELD)) {
1511 ndp->ni_cnd.cn_flags &= ~FSNODELOCKHELD;
1512 unlock_fsnode(ndp->ni_dvp, NULL);
1515 (void)ndp;
1523 nameidone(struct nameidata *ndp)
1525 namei_unlock_fsnode(ndp);
1527 if (ndp->ni_cnd.cn_flags & HASBUF) {
1528 char *tmp = ndp->ni_cnd.cn_pnbuf;
1530 ndp->ni_cnd.cn_pnbuf = NULL;
1531 ndp->ni_cnd.cn_flags &= ~HASBUF;
1532 FREE_ZONE(tmp, ndp->ni_cnd.cn_pnlen, M_NAMEI);
1724 lookup_compound_vnop_post_hook(int error, vnode_t dvp, vnode_t vp, struct nameidata *ndp, int did_create)
1735 if ((ndp->ni_flag & NAMEI_COMPOUND_OP_MASK) == 0) {
1756 if ((error != 0) || (ndp->ni_cnd.cn_flags & MAKEENTRY)) {
1757 lookup_consider_update_cache(dvp, vp, &ndp->ni_cnd, ndp->ni_ncgeneration);
1759 if (ndp->ni_cnd.cn_flags & AUDITVNPATH1)
1761 else if (ndp->ni_cnd.cn_flags & AUDITVNPATH2)
1775 kdebug_lookup(vp ? vp : dvp, &ndp->ni_cnd);