next up previous
Next: create_proc_read_entry Up: General proc functions Previous: General proc functions

create_proc_entry

The function


struct proc_dir_entry *create_proc_entry(
   const char            *name,
   mode_t                 mode,
   struct proc_dir_entry *parent);

creates an entry in the proc file system with the string in the first field as file name. Generally it is a bad idea to have blanks in a filename; it is not forbidden but most UNIX-users don't expect blanks in file names. Thus, file_name is to be preferred over file name. For the mode bits see stat.h, for a description of the flags see man stat. The last argument is the directory in which the proc file is to appear, the value &proc_root is /proc itself.

After having created the entry in /proc the file operations for this file must be assigned by assigning the functions to the appropriate function pointers in the proc_dir_entry structure returned by the call to proc_dir_entry. Example:


struct proc_dir_entry *proc_file;

   proc_file = create_proc_entry(
      "file_name",
      S_IFREG | S_IWUSR, 
      &proc_root);

   proc_top->read_proc=list_tasks;

Predefined directories in proc are proc_root ( /proc), proc_root_driver ( proc/drivers), proc_root_fs ( /proc/fs), proc_net ( /proc/net), proc_bus ( /proc/bus).



Der Herr Hofrat
2003-03-26