Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!sun-barr!newstop!sun!nerdy.Eng.Sun.COM!varun From: varun@nerdy.Eng.Sun.COM (Varun Mehta) Newsgroups: comp.unix.aix Subject: How does knlist() work on AIX3.1/RS6000? Keywords: nlist kernel aix RS6000 Message-ID: <140607@sun.Eng.Sun.COM> Date: 14 Aug 90 05:39:43 GMT Sender: news@sun.Eng.Sun.COM Lines: 65 I'm trying to read disk info from the kernel using the knlist command and it keeps returning with an Invalid argument error. I've read the man page and I think I got everything right except maybe the Size argument. i.e: int knlist(NList, NumberOfElements, Size) struct nlist *NList; int NumberOfElements; int Size; Parameters NList Points to an array of nlist structures. NumberOfElements Specifies the number of structures in the ar- ray of nlist structures. Size Specifies the size of each structure. ^^^^^^^^^^^^^^ How does one pass the size of each structure in one int?? I'm also uncertain how to follow the iostat.dkstatp pointer in /dev/mem. I'm including the program below. I'd appreciate any help with it, Thanks, Varun Mehta Sun Microsystems, Inc. #include #include #include #include #include #include struct nlist nl[] = { #define X_DKSTAT 0 { "iostat" }, }; #define NUM_ELEMENTS 1 struct stats { struct iostat iostat; struct dkstat dkstat; } s1, s2; main() { int fd, i; fd = open("/dev/mem", O_RDONLY); i = knlist(nl, NUM_ELEMENTS, sizeof(struct iostat)); if( i == -1) { perror("knlist error"); exit(1); } for(i = 0; i < NUM_ELEMENTS; i++) { if(nl[i].n_value == 0) { printf("%s not found\n", nl[i]._n._n_name); exit(2); } } lseek(fd, nl[X_DKSTAT].n_value, SEEK_SET); read(fd, &(s1.iostat), sizeof(struct iostat)); lseek(fd, s1.iostat.dkstatp, SEEK_SET); read(fd, &(s1.dkstat), sizeof(struct dkstat)); printf("Disk name %32c\n", s1.dkstat.diskname); printf("Disk busy time %d\n", s1.dkstat.dk_time); }