+ /*
+ * Note first empty directory slot
+ * in eo for possible creat.
+ * String compare the directory entry
+ * and the current component.
+ */
+ if (ep->d_ino == 0) {
+ if (eo < 0)
+ eo = u.u_offset;
+ continue;
+ }
+ if (strncmp(u.u_dbuf, ep->d_name, DIRSIZ) != 0)
+ continue;
+ /*
+ * Here a component matched in a directory.
+ * If there is more pathname, go back to
+ * dirloop, otherwise return.
+ */
+ bcopy((caddr_t)ep, (caddr_t)&u.u_dent, sizeof(struct direct));
+ brelse(bp);
+ if (flag==2 && *cp=='\0') {
+ if (access(dp, IWRITE))
+ goto out;
+ /* should fix unlink */
+ u.u_offset += sizeof(struct direct);
+ goto out1;
+ }
+ /*
+ * Special handling for ".."
+ */
+ if (u.u_dent.d_name[0]=='.' && u.u_dent.d_name[1]=='.' &&
+ u.u_dent.d_name[2]=='\0') {
+ if (dp == u.u_rdir)
+ u.u_dent.d_ino = dp->i_number;
+ else if (u.u_dent.d_ino==ROOTINO &&
+ dp->i_number == ROOTINO) {
+ for(i=1; i<NMOUNT; i++)
+ if (mount[i].m_bufp != NULL &&
+ mount[i].m_dev == dp->i_dev) {
+ iput(dp);
+ dp = mount[i].m_inodp;
+ ilock(dp);
+ dp->i_count++;
+ cp -= 2; /* back over .. */
+ goto dirloop;
+ }
+ }
+ }
+ d = dp->i_dev;
+ ino = dp->i_number;
+ irele(dp);
+ pdp = dp;
+ dp = iget(d, u.u_dent.d_ino);
+ if (dp == NULL) {
+ iput(pdp);
+ goto out1;
+ }
+ /*
+ * Check for symbolic link
+ */
+ if ((dp->i_mode&IFMT)==IFLNK && (follow || *cp=='/')) {
+ char *ocp;