lkml.org 
[lkml]   [2000]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectprocfs docs...
On Thu, 5 Oct 2000, George Anzinger wrote:
> Where is the internal interface to procfs documented?

There is no documentation for the -exported- procfs interface as far as
I know. As for internal interfaces, who knows what you are asking...

Here's a rough outline: (maybe somebody should clean this up and stick
it into Documentation/*)

* Drivers without MAJOR /proc interfaces should stick their procfs
files/directories into /proc/driver/*

* Use proc_mkdir to create directories. For symlinks, proc_symlink, for
device nodes, proc_mknod. Note that only proc_mknod takes a permission
(mode_t) argument. If you need special permissions on directories, use
create_proc_entry with S_IFDIR in mode_t arg. Otherwise directories
will be mode 0755.

* Use create_proc_read_entry for your procfs "files." For anything more
complex than simply reading, use create_proc_entry. If you pass '0' for
mode_t, it will have mode 0644 (ie. normal file permissions).

* Use remove_proc_entry for removing entries.

* Pass NULL for the parent dir, if you are based off of /proc root.

* You don't need to keep around pointers to your procfs directories and
files. Just call remove_proc_entry with the correct (full) path,
relative, to procfs root, and the right thing will happen.

Cheesy init example:

if (!proc_mkdir("driver/my_driver", NULL))
/* error */
if (!create_proc_read_entry("driver/my_driver/foo", 0, NULL,
foo_read_proc, NULL))
/* error */
if (!create_proc_read_entry("driver/my_driver/bar", 0, NULL,
bar_read_proc, NULL))
/* error */

Cheesy remove example:

remove_proc_entry ("driver/my_driver/bar", NULL);
remove_proc_entry ("driver/my_driver/foo", NULL);
remove_proc_entry ("driver/my_driver", NULL);

In the above examples, I'm pretty sure that the proc_mkdir call,
and final remove_proc_entry, can be skipped, too....

Jeff





-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:39    [W:0.030 / U:1.376 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site