move copyin() call so if uap->size pointer is null, still return size
[unix-history] / usr / src / sys / kern / vfs_lookup.c
index 50f3b33..9326fbc 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)vfs_lookup.c        7.30 (Berkeley) %G%
+ *     @(#)vfs_lookup.c        7.32 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -60,11 +60,8 @@ namei(ndp, p)
         * Get a buffer for the name to be translated, and copy the
         * name into the buffer.
         */
         * Get a buffer for the name to be translated, and copy the
         * name into the buffer.
         */
-#ifdef DIAGNOSTIC
-       if (ndp->ni_nameiop & HASBUF)
-               panic("namei: reentered");
-#endif
-       MALLOC(ndp->ni_pnbuf, caddr_t, MAXPATHLEN, M_NAMEI, M_WAITOK);
+       if ((ndp->ni_nameiop & HASBUF) == 0)
+               MALLOC(ndp->ni_pnbuf, caddr_t, MAXPATHLEN, M_NAMEI, M_WAITOK);
        if (ndp->ni_segflg == UIO_SYSSPACE)
                error = copystr(ndp->ni_dirp, ndp->ni_pnbuf,
                            MAXPATHLEN, &ndp->ni_pathlen);
        if (ndp->ni_segflg == UIO_SYSSPACE)
                error = copystr(ndp->ni_dirp, ndp->ni_pnbuf,
                            MAXPATHLEN, &ndp->ni_pathlen);
@@ -248,15 +245,8 @@ dirloop:
         * responsibility for freeing the pathname buffer.
         */
        ndp->ni_hash = 0;
         * responsibility for freeing the pathname buffer.
         */
        ndp->ni_hash = 0;
-       for (cp = ndp->ni_ptr; *cp != 0 && *cp != '/'; cp++) {
+       for (cp = ndp->ni_ptr; *cp != 0 && *cp != '/'; cp++)
                ndp->ni_hash += (unsigned char)*cp;
                ndp->ni_hash += (unsigned char)*cp;
-               if ((*cp & 0200) == 0)
-                       continue;
-               if ((*cp & 0377) == ('/' | 0200) || flag != DELETE) {
-                       error = EINVAL;
-                       goto bad;
-               }
-       }
        ndp->ni_namelen = cp - ndp->ni_ptr;
        if (ndp->ni_namelen >= NAME_MAX) {
                error = ENAMETOOLONG;
        ndp->ni_namelen = cp - ndp->ni_ptr;
        if (ndp->ni_namelen >= NAME_MAX) {
                error = ENAMETOOLONG;
@@ -356,6 +346,7 @@ dirloop:
                if (ndp->ni_nameiop & SAVESTART) {
                        ndp->ni_startdir = ndp->ni_dvp;
                        VREF(ndp->ni_startdir);
                if (ndp->ni_nameiop & SAVESTART) {
                        ndp->ni_startdir = ndp->ni_dvp;
                        VREF(ndp->ni_startdir);
+                       p->p_spare[1]++;
                }
                return (0);
        }
                }
                return (0);
        }
@@ -421,6 +412,7 @@ nextname:
        }
        if (ndp->ni_nameiop & SAVESTART) {
                ndp->ni_startdir = ndp->ni_dvp;
        }
        if (ndp->ni_nameiop & SAVESTART) {
                ndp->ni_startdir = ndp->ni_dvp;
+               p->p_spare[1]++;
                VREF(ndp->ni_startdir);
        }
        if (!wantparent)
                VREF(ndp->ni_startdir);
        }
        if (!wantparent)