Help Reading /dev/kmem

Johnny Hamilton hamilton at thorin.cs.unc.edu
Sat Feb 18 08:18:47 AEST 1989


HELP READING /dev/kmem:

  This semester I am taking a software development class, Comp145.
  My project requires that I read from /dev/kmem (i.e. kernel memory).
 
  My problem is that I can't figure out what string variable I
  should assign to nl[0].n_name, or if that is the source of my
  problem.
 
  Here is a segment of my source:
 
*****************************************************************************
        long    pos,offset;
        int     desc;
        off_t   off__set;
        int     x;
 
 
        struct proc  process;
        struct nlist nl[2];   /**  Structure w/ n_name and n_value  **/
 
        nl[0].n_name = "_qs";  /**  String to search for and get offset**/
                               /**  Not sure what value this should be **/
                               /**  Pulled qs out of proc.h where it is **/
                               /**  commented as being an array of struct- **/
                               /**  ures containg bi-directional pointers  **/
                               /**  to type proc (i.e. process structure) **/
 
        nl[1].n_name = "";
 
        nlist("/vmunix",nl);   /** Call nlist function to obtain offset **/
                               /** in nl[0].n_value                     **/
 
        if(desc = open("/dev/kmem",O_RDONLY) == -1 )
        {
            perror("  Error opening kmem ...  ");

        }
 
 
        off__set = nl[0].n_value;
 
        for(x=0;x<10;++x)   /** ??? not sure where to get value of x **/
        {
            lseek(desc, (long) off__set,L_SET);  /** move to offset for read **/            read(desc, &process, sizeof(process));
 
*******************************************************************************
 
  Any answers, suggestions, advice and/or references to sources would be
  greatly appreciated.
 
  Thanks,
  Johnny D. Hamilton
 
 



More information about the Comp.unix.questions mailing list