diff options
author | Jim Meyering <jim@meyering.net> | 2000-11-05 09:52:55 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-11-05 09:52:55 +0000 |
commit | 983cd1114348bd48c7070551da16ff556eafd81d (patch) | |
tree | a59a2575b450cd8931d498390cce6d1dda7f69b2 /lib | |
parent | aea44f3fa0591964735ce3186fcd88f8b5ee224d (diff) | |
download | coreutils-983cd1114348bd48c7070551da16ff556eafd81d.tar.xz |
*** empty log message ***
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tru-knlist-demo.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/tru-knlist-demo.c b/lib/tru-knlist-demo.c new file mode 100644 index 000000000..0b90f0ea5 --- /dev/null +++ b/lib/tru-knlist-demo.c @@ -0,0 +1,39 @@ +/* From the knlist manpage */ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include <nlist.h> +main () +{ + struct nlist nl[3]; + int retval, i; + nl[0].n_name = (char *)malloc(10); + nl[1].n_name = (char *)malloc(10); + nl[2].n_name = ""; + + /*******************************************************/ + /* Store names of kernel symbols in the nl array */ + strcpy (nl[0].n_name, "ncpus"); + strcpy (nl[1].n_name, "lockmode"); + + /*******************************************************/ + /* Call the knlist routine */ + retval = knlist(nl); + + /******************************************************/ + /* Display addresses if returned. Otherwise, display */ + /* the appropriate error message. */ + if (retval < 0) + printf ("No kernel symbol addresses returned.\n"); + else + if (retval >= 0 ) + for (i=0; i<2; i++) + if (nl[i].n_type == 0) + printf ("Unable to return address of symbol %s\n", + nl[i].n_name); + else + printf ("The address of symbol %s is %lx\n", + nl[i].n_name, nl[i].n_value); + free (nl[0].n_name); + free (nl[1].n_name); +} |