Re: RFC: /proc/module namespace

Jeff Garzik (jgarzik@pobox.com)
Thu, 02 Sep 1999 14:56:29 -0400


This is a multi-part message in MIME format.
--------------8424E419739CD10469B0B723
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

In response to feedback the patch has been updated. Now a
/proc/driver/$NAME directory is created upon request from the driver.

Note this is for driver-specific information that does not go elsewhere
in /proc.

This patch is against 2.3.16, and has been tested with my audio driver.

Jeff

-- 
Americans' greatest fear is that America will turn out to have been a
phenomenon, not a civilization.
                -- Shirley Hazzard, "Transit of Venus"
--------------8424E419739CD10469B0B723
Content-Type: text/plain; charset=us-ascii;
 name="patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch"

diff -urN /g/vanilla/v2.3.16/linux/include/linux/proc_fs.h linux/include/linux/proc_fs.h --- /g/vanilla/v2.3.16/linux/include/linux/proc_fs.h Tue Aug 31 19:12:14 1999 +++ linux/include/linux/proc_fs.h Thu Sep 2 14:48:30 1999 @@ -54,7 +54,8 @@ PROC_SOUND, PROC_MTRR, /* whether enabled or not */ PROC_FS, - PROC_SYSVIPC + PROC_SYSVIPC, + PROC_DRIVER, }; enum pid_directory_inos { @@ -479,5 +480,40 @@ extern inline void proc_tty_unregister_driver(struct tty_driver *driver) {}; -#endif +#endif /* CONFIG_PROC_FS */ + +extern struct proc_dir_entry proc_root_driver; + +static inline +struct proc_dir_entry *proc_driver_find (const char *module_name) +{ + struct proc_dir_entry *p; + + p = proc_root_driver.subdir; + while (p != NULL) { + if (strcmp (p->name, module_name) == 0) + return p; + + p = p->next; + } + return NULL; +} + +static inline int proc_driver_unregister(const char *module_name) +{ + remove_proc_entry (module_name, &proc_root_driver); + return 0; +} + +static inline int proc_driver_register(const char *module_name) +{ + struct proc_dir_entry *p; + + p = create_proc_entry (module_name, S_IFDIR, &proc_root_driver); + + return (p == NULL) ? -1 : 0; +} + + + #endif /* _LINUX_PROC_FS_H */ diff -urN /g/vanilla/v2.3.16/linux/fs/proc/root.c linux/fs/proc/root.c --- /g/vanilla/v2.3.16/linux/fs/proc/root.c Thu Aug 26 17:18:06 1999 +++ linux/fs/proc/root.c Thu Sep 2 14:48:30 1999 @@ -641,6 +641,14 @@ NULL, NULL, NULL }; +struct proc_dir_entry proc_root_driver = { + PROC_DRIVER, 6, "driver", + S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0, + 0, &proc_dir_inode_operations, + NULL, NULL, + NULL, + NULL, NULL +}; static struct proc_dir_entry proc_root_dma = { PROC_DMA, 3, "dma", S_IFREG | S_IRUGO, 1, 0, 0, @@ -738,6 +746,7 @@ #endif proc_register(&proc_root, &proc_root_stat); proc_register(&proc_root, &proc_root_devices); + proc_register(&proc_root, &proc_root_driver); proc_register(&proc_root, &proc_root_partitions); proc_register(&proc_root, &proc_root_interrupts); proc_register(&proc_root, &proc_root_filesystems);

--------------8424E419739CD10469B0B723--

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