Annotation of xinu/sys/LSI/dfdsrch.c, revision 1.1

1.1     ! root        1: /* dfdsrch.c - dfdsrch */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <disk.h>
        !             6: #include <lfile.h>
        !             7: #include <dir.h>
        !             8: 
        !             9: /*------------------------------------------------------------------------
        !            10:  *  dfdsrch  --  search disk directory for position of given file name
        !            11:  *------------------------------------------------------------------------
        !            12:  */
        !            13: struct fdes    *dfdsrch(dsptr, filenam, mbits)
        !            14: struct dsblk   *dsptr;
        !            15: char   *filenam;
        !            16: int    mbits;
        !            17: {
        !            18:        struct  dir     *dirptr;
        !            19:        struct  fdes    *fdptr;
        !            20:        int     len;
        !            21:        int     i;
        !            22:        int     inum;
        !            23: 
        !            24:        if ( (len=strlen(filenam))<=0 || len>=FDNLEN)
        !            25:                return((struct fdes *)SYSERR);
        !            26:        dirptr = dsdirec(dsptr->dnum);
        !            27:        for (i=0 ; i<dirptr->d_nfiles ; i++)
        !            28:                if (strcmp(filenam, dirptr->d_files[i].fdname) == 0)
        !            29:                        if ( (mbits&FLNEW) != 0)
        !            30:                                return((struct fdes *)SYSERR);
        !            31:                        else
        !            32:                                return(&dirptr->d_files[i]);
        !            33:        wait(dsptr->ddirsem);
        !            34:        if ( (mbits&FLOLD) || dirptr->d_nfiles >= NFDES) {
        !            35:                signal(dsptr->ddirsem);
        !            36:                return((struct fdes *)SYSERR);
        !            37:        }
        !            38:        inum = ibnew(dsptr->dnum, IBNWDIR);
        !            39:        fdptr = &(dirptr->d_files[dirptr->d_nfiles++]);
        !            40:        fdptr->fdlen = 0L;
        !            41:        strcpy(fdptr->fdname, filenam);
        !            42:        fdptr->fdiba = inum;
        !            43:        write(dsptr->dnum, dskbcpy(dirptr), DIRBLK);
        !            44:        signal(dsptr->ddirsem);
        !            45:        return(fdptr);
        !            46: }

unix.superglobalmegacorp.com

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