Annotation of researchv9/sys.vax/sys/nami.c, revision 1.1

1.1     ! root        1: #include "../h/param.h"
        !             2: #include "../h/systm.h"
        !             3: #include "../h/inode.h"
        !             4: #include "../h/dir.h"
        !             5: #include "../h/user.h"
        !             6: #include "../h/buf.h"
        !             7: #include "../h/conf.h"
        !             8: 
        !             9: /*
        !            10:  * Convert a pathname into a pointer to
        !            11:  * a locked inode.
        !            12:  *
        !            13:  * func = function called to get next char of name
        !            14:  *     &uchar if name is in user space
        !            15:  *     &schar if name is in system space
        !            16:  *     length guaranteed <= BUFSIZE if func != uchar
        !            17:  * flagp
        !            18:        0 for ordinary searches
        !            19:        else ->flag structure with more parameters
        !            20:  * follow = 1 if links are to be followed at the end of the name
        !            21:  */
        !            22: 
        !            23: struct inode *
        !            24: namei(func, flagp, follow)
        !            25: int            (*func)();
        !            26: struct argnamei        *flagp;
        !            27: int            follow;
        !            28: {
        !            29:        register int    i;
        !            30:        register char   *cp;
        !            31:        struct nx       p;
        !            32: 
        !            33:        p.nbp = geteblk();
        !            34:        if(func == uchar) {
        !            35:                if((i = fustrlen(u.u_dirp)) < 0) {
        !            36:                        u.u_error = EFAULT;
        !            37:                        brelse(p.nbp);
        !            38:                        return NULL;
        !            39:                }
        !            40:                if(i > BUFSIZE) {
        !            41:                        u.u_error = ENOENT;
        !            42:                        brelse(p.nbp);
        !            43:                        return NULL;
        !            44:                }
        !            45:                bcopy(u.u_dirp, p.nbp->b_un.b_addr, i);
        !            46: #ifdef CHAOS
        !            47:                u.u_dirp += i;
        !            48: #endif
        !            49:        } else {
        !            50:                cp = p.nbp->b_un.b_addr;
        !            51:                do; while(*cp++ = (*func)());
        !            52:        }
        !            53:        if(flagp != NULL) {
        !            54:                cp = p.nbp->b_un.b_addr;
        !            55:                while(i = *cp++) {
        !            56:                        if(i & 0200) {
        !            57:                                u.u_error = ENOENT;
        !            58:                                brelse(p.nbp);
        !            59:                                return NULL;
        !            60:                        }
        !            61:                }
        !            62:        }
        !            63:        cp = p.nbp->b_un.b_addr;
        !            64:        if(*cp == '/') {
        !            65:                while(*cp == '/')
        !            66:                        cp++;
        !            67:                if((p.dp = u.u_rdir) == NULL)
        !            68:                        p.dp = rootdir;
        !            69:        } else
        !            70:                p.dp = u.u_cdir;
        !            71:        p.nlink = 0;
        !            72:        p.cp = cp;
        !            73:        plock(p.dp);
        !            74:        p.dp->i_count++;
        !            75: 
        !            76:        for (;;) {
        !            77:                switch((*fstypsw[p.dp->i_fstyp].t_nami)(&p, &flagp, follow)) {
        !            78:                case 1:
        !            79:                        iput(p.dp);
        !            80:                        brelse(p.nbp);
        !            81:                        return NULL;
        !            82:                case 2:
        !            83:                        if(*p.cp)
        !            84:                                break;
        !            85:                case 0:
        !            86:                        brelse(p.nbp);
        !            87:                        return p.dp;
        !            88:                default:
        !            89:                        panic("namei ret");
        !            90:                }
        !            91:        }
        !            92: }
        !            93: 
        !            94: /*
        !            95:  * for filesystems without namei code
        !            96:  */
        !            97: 
        !            98: int
        !            99: nullnami()
        !           100: {
        !           101:        u.u_error = ENODEV;
        !           102:        return (1);
        !           103: }
        !           104: 
        !           105: /*
        !           106:  * Return the next character from the
        !           107:  * kernel string pointed at by dirp.
        !           108:  */
        !           109: schar()
        !           110: {
        !           111: 
        !           112:        return(*u.u_dirp++ & 0377);
        !           113: }
        !           114: 
        !           115: /*
        !           116:  * Return the next character from the
        !           117:  * user string pointed at by dirp.
        !           118:  */
        !           119: uchar()
        !           120: {
        !           121:        register c;
        !           122: 
        !           123:        c = fubyte(u.u_dirp++);
        !           124:        if(c == -1) {
        !           125:                u.u_error = EFAULT;
        !           126:                c = 0;
        !           127:        }
        !           128:        return(c);
        !           129: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.