Skip to content

Instantly share code, notes, and snippets.

@mhansen
Created October 22, 2009 22:54
Show Gist options
  • Select an option

  • Save mhansen/216429 to your computer and use it in GitHub Desktop.

Select an option

Save mhansen/216429 to your computer and use it in GitHub Desktop.
/* Prototypes for functions called upon a read to a /proc file
These functions all fill the buffer parameter with a string,
which is returned to the process calling read() */
#define NR_DEVS 6 /* number of minor devices */
_PROTOTYPE( void get_uptime, (char *buffer, int bufSize) );
_PROTOTYPE( void get_Hz, (char *buffer, int bufSize) );
_PROTOTYPE( void get_bootenv, (char *buffer, int bufSize) );
_PROTOTYPE( void get_cpuinfo, (char *buffer, int bufSize) );
_PROTOTYPE( void get_processes, (char *buffer, int bufSize) );
_PROTOTYPE( void get_bootimage, (char *buffer, int bufSize) );
/* call vector of functions to retrieve file contents, indexed by minor no. */
void (*pr_vec[NR_DEVS]) (char *buffer, int bufSize) = {
/* function minor file */
get_Hz, /* 0 = /proc/hz */
get_uptime, /* 1 = /proc/uptime */
get_bootenv, /* 2 = /proc/bootenv */
get_cpuinfo, /* 3 = /proc/cpuinfo */
get_processes,/*4 = /proc/processes */
get_bootimage,/*5 = /proc/bootimage */
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment