get rid of #ifdef CHAOS stuff
[unix-history] / usr / src / sys / ufs / ffs / ufs_lookup.c
index 9636579..97ec351 100644 (file)
@@ -1,4 +1,4 @@
-/*     ufs_lookup.c    3.1     %H%     */
+/*     ufs_lookup.c    4.4     %G%     */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
@@ -7,6 +7,7 @@
 #include "../h/dir.h"
 #include "../h/user.h"
 #include "../h/buf.h"
 #include "../h/dir.h"
 #include "../h/user.h"
 #include "../h/buf.h"
+#include "../h/conf.h"
 
 /*
  * Convert a pathname into a pointer to
 
 /*
  * Convert a pathname into a pointer to
@@ -27,6 +28,7 @@ int (*func)();
        register c;
        register char *cp;
        struct buf *bp;
        register c;
        register char *cp;
        struct buf *bp;
+       register struct direct *ep;
        int i;
        dev_t d;
        off_t eo;
        int i;
        dev_t d;
        off_t eo;
@@ -40,7 +42,7 @@ int (*func)();
        if((c=(*func)()) == '/')
                if ((dp = u.u_rdir) == NULL)
                        dp = rootdir;
        if((c=(*func)()) == '/')
                if ((dp = u.u_rdir) == NULL)
                        dp = rootdir;
-       VOID iget(dp->i_dev, dp->i_number);
+       (void) iget(dp->i_dev, dp->i_number);
        while(c == '/')
                c = (*func)();
        if(c == '\0' && flag != 0)
        while(c == '/')
                c = (*func)();
        if(c == '\0' && flag != 0)
@@ -67,7 +69,11 @@ cloop:
        while (c != '/' && c != '\0' && u.u_error == 0 ) {
                if (mpxip!=NULL && c=='!')
                        break;
        while (c != '/' && c != '\0' && u.u_error == 0 ) {
                if (mpxip!=NULL && c=='!')
                        break;
-               if(cp < &u.u_dbuf[DIRSIZ])
+               if (flag==1 && c == ('/'|0200)) {
+                       u.u_error = ENOENT;
+                       goto out;
+               }
+               if (cp < &u.u_dbuf[DIRSIZ])
                        *cp++ = c;
                c = (*func)();
        }
                        *cp++ = c;
                c = (*func)();
        }
@@ -90,7 +96,7 @@ seloop:
 
        if((dp->i_mode&IFMT) != IFDIR)
                u.u_error = ENOTDIR;
 
        if((dp->i_mode&IFMT) != IFDIR)
                u.u_error = ENOTDIR;
-       VOID access(dp, IEXEC);
+       (void) access(dp, IEXEC);
        if(u.u_error)
                goto out;
 
        if(u.u_error)
                goto out;
 
@@ -113,7 +119,7 @@ eloop:
        if(u.u_offset >= dp->i_size) {
                if(bp != NULL)
                        brelse(bp);
        if(u.u_offset >= dp->i_size) {
                if(bp != NULL)
                        brelse(bp);
-               if(flag==1 && c=='\0') {
+               if(flag==1 && c=='\0' && dp->i_nlink) {
                        if(access(dp, IWRITE))
                                goto out;
                        u.u_pdir = dp;
                        if(access(dp, IWRITE))
                                goto out;
                        u.u_pdir = dp;
@@ -142,7 +148,9 @@ eloop:
                        brelse(bp);
                        goto out;
                }
                        brelse(bp);
                        goto out;
                }
-       }
+               ep = (struct direct *)bp->b_un.b_addr;
+       } else
+               ep++;
 
        /*
         * Note first empty directory slot
 
        /*
         * Note first empty directory slot
@@ -152,16 +160,14 @@ eloop:
         * If they do not match, go back to eloop.
         */
 
         * If they do not match, go back to eloop.
         */
 
-       bcopy(bp->b_un.b_addr+(u.u_offset&BMASK), (caddr_t)&u.u_dent,
-               sizeof(struct direct));
        u.u_offset += sizeof(struct direct);
        u.u_offset += sizeof(struct direct);
-       if(u.u_dent.d_ino == 0) {
+       if(ep->d_ino == 0) {
                if(eo == 0)
                        eo = u.u_offset;
                goto eloop;
        }
        for(i=0; i<DIRSIZ; i++) {
                if(eo == 0)
                        eo = u.u_offset;
                goto eloop;
        }
        for(i=0; i<DIRSIZ; i++) {
-               if(u.u_dbuf[i] != u.u_dent.d_name[i])
+               if(u.u_dbuf[i] != ep->d_name[i])
                        goto eloop;
                if(u.u_dbuf[i] == 0)
                        break;
                        goto eloop;
                if(u.u_dbuf[i] == 0)
                        break;
@@ -172,7 +178,7 @@ eloop:
         * If there is more pathname, go back to
         * cloop, otherwise return.
         */
         * If there is more pathname, go back to
         * cloop, otherwise return.
         */
-
+       bcopy((caddr_t)ep, (caddr_t)&u.u_dent, sizeof(struct direct));
        if(bp != NULL)
                brelse(bp);
        if(flag==2 && c=='\0') {
        if(bp != NULL)
                brelse(bp);
        if(flag==2 && c=='\0') {