Re: procfs docs...

From: George Anzinger (george@mvista.com)
Date: Thu Oct 05 2000 - 13:27:13 EST


Great start. To complete it we need some info on the read/write
interface. Is it the same as for other drivers? I have heard that read
is called once after returning an EOF. Is this so? I suppose there are
other interfaces also, e.g. ioctl, etc.

George

Jeff Garzik wrote:
>
> 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/



This archive was generated by hypermail 2b29 : Sat Oct 07 2000 - 21:00:17 EST