+ *
+ * We may need to upto 2 usecounts on vnodes before starting the translation
+ * We need to have a usecount on the root directory for the process
+ * for the entire duration of the lookup. This is because symlink
+ * translation can restart translation at / if a symlink is encountered.
+ *
+ * For the duration of this lookup at rootdir for this lookup is the one
+ * we fetch now under the proc_fdlock even the if the proc rootdir changes
+ * once we let go of the proc_fdlock.
+ *
+ * In the future we may consider holding off a chroot till we complete
+ * in progress lookups.
+ *
+ * If the starting directory is not the process rootdir then we need
+ * a usecount on the starting directory as well for the duration of the
+ * lookup.
+ *
+ * Getting an addtional usecount involves first getting an iocount under
+ * the lock that ensures that a usecount is on the directory. Once we
+ * get an iocount we can release the lock and we will be free to get a
+ * usecount without the vnode getting recycled. Once we get the usecount
+ * we can release the icoount which we used to get our usecount.
+ */
+ proc_fdlock(p);
+ if (!(fdp->fd_flags & FD_CHROOT)) {
+ ndp->ni_rootdir = rootvnode;
+ } else {
+ ndp->ni_rootdir = fdp->fd_rdir;
+ }
+
+ if (!ndp->ni_rootdir) {
+ if (!(fdp->fd_flags & FD_CHROOT)) {
+ proc_fdunlock(p);
+ printf("rootvnode is not set\n");
+ } else {
+ proc_fdunlock(p);
+ /* This should be a panic */
+ printf("fdp->fd_rdir is not set\n");
+ }
+ error = ENOENT;
+ goto error_out;
+ }
+
+ /*
+ * We have the proc_fdlock here so we still have a usecount
+ * on ndp->ni_rootdir.
+ *
+ * However we need to get our own usecount on it in order to
+ * ensure that the vnode isn't recycled to something else.
+ *
+ * Note : It's fine if the vnode is force reclaimed but with
+ * a usecount it won't be reused until we release the reference.
+ *
+ * In order to get that usecount however, we need to first
+ * get non blocking iocount since we'll be doing this under
+ * the proc_fdlock.