Annotation of researchv10no/cmd/ps/memrd.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * various memory-reading primitives
                      3:  */
                      4: 
                      5: #include "ps.h"
                      6: 
                      7: /*
                      8:  * read the memory page corresponding to a VAX pte
                      9:  *
                     10:  * trickiness:
                     11:  * the call to memrd assumes memory == /dev/mem, not /dev/kmem
                     12:  * if mode == 0, this is wrong.
                     13:  * but if mode == 0, rdpage is called only when the process is
                     14:  * entirely swapped out, and hence its pages are all in the swap area
                     15:  * this could use some cleaning up
                     16:  */
                     17: rdpage(up, pgno, pte, buf)
                     18: register struct user *up;
                     19: int pgno;
                     20: register struct pte *pte;
                     21: char *buf;
                     22: {
                     23: 
                     24:        if (pte->pg_v   /* in memory */
                     25:        ||  (pte->pg_fod == 0 && pte->pg_pfnum))        /* or unreferenced but in memory */
                     26:                return (memrd(memory, buf, NBPG, ctob(pte->pg_pfnum)));
                     27:        if (pte->pg_fod) {      /* assume fill-zero */
                     28:                memset(buf, 0, NBPG);
                     29:                return (NBPG);
                     30:        }
                     31:        /*
                     32:         * page is in the swap area
                     33:         * assume stack segment
                     34:         */
                     35:        return (memrd(drum, buf, NBPG,
                     36:                ctob(up->u_smap.dm_map[0] + DMMIN - pgno - 1)));
                     37: }
                     38: 
                     39: /*
                     40:  * read a chunk of something at some offset in some file
                     41:  */
                     42: 
                     43: memrd(fd, buf, size, off)
                     44: int fd;
                     45: char *buf;
                     46: int size;
                     47: long off;
                     48: {
                     49: 
                     50:        lseek(fd, off, 0);
                     51:        return (read(fd, buf, size));
                     52: }

unix.superglobalmegacorp.com

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