X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/10873320393c024743109ef8a8f8a62e92519b1b..65a9722c519915cdfa774cc7295cd11081d72213:/usr/src/sys/ufs/ffs/ufs_lookup.c diff --git a/usr/src/sys/ufs/ffs/ufs_lookup.c b/usr/src/sys/ufs/ffs/ufs_lookup.c index 9636579fca..97ec351def 100644 --- a/usr/src/sys/ufs/ffs/ufs_lookup.c +++ b/usr/src/sys/ufs/ffs/ufs_lookup.c @@ -1,4 +1,4 @@ -/* ufs_lookup.c 3.1 %H% */ +/* ufs_lookup.c 4.4 %G% */ #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/conf.h" /* * Convert a pathname into a pointer to @@ -27,6 +28,7 @@ int (*func)(); register c; register char *cp; struct buf *bp; + register struct direct *ep; 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; - 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) @@ -67,7 +69,11 @@ cloop: 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)(); } @@ -90,7 +96,7 @@ seloop: if((dp->i_mode&IFMT) != IFDIR) u.u_error = ENOTDIR; - VOID access(dp, IEXEC); + (void) access(dp, IEXEC); if(u.u_error) goto out; @@ -113,7 +119,7 @@ eloop: 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; @@ -142,7 +148,9 @@ eloop: brelse(bp); goto out; } - } + ep = (struct direct *)bp->b_un.b_addr; + } else + ep++; /* * Note first empty directory slot @@ -152,16 +160,14 @@ 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); - if(u.u_dent.d_ino == 0) { + if(ep->d_ino == 0) { if(eo == 0) eo = u.u_offset; goto eloop; } for(i=0; id_name[i]) 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. */ - + bcopy((caddr_t)ep, (caddr_t)&u.u_dent, sizeof(struct direct)); if(bp != NULL) brelse(bp); if(flag==2 && c=='\0') {