//---------------------------------------------------------------- // showpagedir.cpp // // This program opens the pseudo-file created by the 'gpd.c' // module, reads the current Global Page Directory, and then // displays its directory-entries using hexadecimal format. // // NOTE: written and tested with Linux kernel version 2.4.20. // // programmer: ALLAN CRUSE // written on: 20 FEB 2003 //---------------------------------------------------------------- #include // for printf(), perror() #include // for open(), O_RDONLY #include // for read(), close() #include // for exit() #define FILENAME "/proc/gpd" int main( void ) { int fd = open( FILENAME, O_RDONLY ); if ( fd < 0 ) { perror( "open" ); exit(1); } unsigned long pgdir[ 4096 ] = {0}; int nbytes = read( fd, pgdir, 4096 ); if ( nbytes < 4096 ) { perror( "read" ); exit(1); } printf( "\n\nThe current Global Page Directory appears below:\n" ); for (int i = 0; i < 1024; i++) { if ( ( i % 256 ) == 0 ) printf( "\n" ); if ( ( i % 8 ) == 0 ) printf( "\n%03X: ", i << 2 ); printf( "%08X ", pgdir[ i ] ); } printf( "\n\n" ); close( fd ); }