Annotation of researchv9/jerq/sgs/inc/sdpsrc/lo/readpage.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * static char ID_rdpagc[] = "@(#) readpage.c: 1.2 11/10/82";
        !             3:  */
        !             4: 
        !             5: readpage(itemid, framenbr)
        !             6: int framenbr;
        !             7: ITEMID itemid;
        !             8: {
        !             9: 
        !            10:        register int index;
        !            11:        register HEADER *gframe;
        !            12:        int spacenbr, bytesread;
        !            13:        char file_name[NAMELENG];
        !            14:        long offset, pagenbr;
        !            15: 
        !            16:        pagenbr  = XTRCTPN(itemid);
        !            17:        spacenbr = XTRCTSP(itemid);
        !            18: 
        !            19:        gframe = &global_frames[spacenbr];
        !            20:        
        !            21:        offset = 0L;
        !            22:        for( index = 0; index < gframe->numbfiles; index++ ) {
        !            23:                if( pagenbr < (offset + gframe->filesize[index]) )
        !            24:                        break;
        !            25:                offset += gframe->filesize[index];
        !            26:                }
        !            27:        if( index == gframe->numbfiles )
        !            28:                return( fatal("attempt to read page outside of address space") );
        !            29:        
        !            30:        offset = pagenbr - offset;
        !            31:        
        !            32:        if( gframe->filedes[index] == NOTMADE )
        !            33:                return( fatal("attempt to read from nonexistant file") );
        !            34:        
        !            35:        if( gframe->filedes[index] == CLOSED ) {
        !            36:                sprintf(file_name, "%s/%s%d", direct_names[spacenbr], TEMPLATE, index);
        !            37:                if( (gframe->filedes[index] = open(file_name,RW)) < 0 )
        !            38:                        return( fatal("unable to open SDP file for read") );
        !            39:                }
        !            40:        
        !            41:        if( lseek(gframe->filedes[index], offset*PAGESIZE, 0) < 0 )
        !            42:                return( fatal("lseek failure on SDP file") );
        !            43:        
        !            44:        SDP_read++;
        !            45:        if( dflag > 15 )
        !            46:                fprintf( stderr, " r%02d ", framenbr );
        !            47: 
        !            48:        if( (bytesread =
        !            49:                read(gframe->filedes[index], manager[framenbr].frame_pntr, PAGESIZE)) < 0 )
        !            50:                return( fatal("read feilure on SDP file") );
        !            51: 
        !            52:        manager[framenbr].page_id = itemid;
        !            53:        
        !            54:        partusage[manager[framenbr].partition]++;
        !            55: #if DPARTRESET == -1
        !            56:        partusage[num_partitions]++;
        !            57: #else
        !            58:        if( ++partusage[num_partitions] >= partreset )
        !            59:                repartition();
        !            60: #endif
        !            61: 
        !            62:        return( bytesread );
        !            63: }

unix.superglobalmegacorp.com

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