4 * Copyright (C) 1991, 1992 Linus Torvalds
6 * proc root directory handling functions
9 #include <asm/uaccess.h>
11 #include <linux/errno.h>
12 #include <linux/sched.h>
13 #include <linux/proc_fs.h>
14 #include <linux/stat.h>
15 #include <linux/config.h>
16 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <asm/bitops.h>
20 struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
23 struct proc_dir_entry *proc_sys_root;
26 static DECLARE_FSTYPE(proc_fs_type, "proc", proc_read_super, FS_SINGLE);
28 void __init proc_root_init(void)
30 int err = register_filesystem(&proc_fs_type);
33 proc_mnt = kern_mount(&proc_fs_type);
34 err = PTR_ERR(proc_mnt);
35 if (IS_ERR(proc_mnt)) {
36 unregister_filesystem(&proc_fs_type);
40 proc_net = proc_mkdir("net", 0);
41 proc_net_stat = proc_mkdir("net/stat", NULL);
44 proc_mkdir("sysvipc", 0);
47 proc_sys_root = proc_mkdir("sys", 0);
49 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
50 proc_mkdir("sys/fs", 0);
51 proc_mkdir("sys/fs/binfmt_misc", 0);
53 proc_root_fs = proc_mkdir("fs", 0);
54 proc_root_driver = proc_mkdir("driver", 0);
55 #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE)
56 /* just give it a mountpoint */
57 proc_mkdir("openprom", 0);
60 #ifdef CONFIG_PROC_DEVICETREE
61 proc_device_tree_init();
63 #ifdef CONFIG_PPC_ISERIES
64 iSeries_proc_create();
69 #ifdef CONFIG_PPC_RTAS
72 proc_bus = proc_mkdir("bus", 0);
75 static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry)
77 if (dir->i_ino == PROC_ROOT_INO) { /* check for safety... */
78 int nlink = proc_root.nlink;
85 if (!proc_lookup(dir, dentry))
88 return proc_pid_lookup(dir, dentry);
91 static int proc_root_readdir(struct file * filp,
92 void * dirent, filldir_t filldir)
94 unsigned int nr = filp->f_pos;
96 if (nr < FIRST_PROCESS_ENTRY) {
97 int error = proc_readdir(filp, dirent, filldir);
100 filp->f_pos = FIRST_PROCESS_ENTRY;
103 return proc_pid_readdir(filp, dirent, filldir);
107 * The root /proc directory is special, as it has the
108 * <pid> directories. Thus we don't use the generic
109 * directory handling functions for that..
111 static struct file_operations proc_root_operations = {
112 read: generic_read_dir,
113 readdir: proc_root_readdir,
117 * proc root can do almost nothing..
119 static struct inode_operations proc_root_inode_operations = {
120 lookup: proc_root_lookup,
124 * This is the root "inode" in the /proc tree..
126 struct proc_dir_entry proc_root = {
127 low_ino: PROC_ROOT_INO,
130 mode: S_IFDIR | S_IRUGO | S_IXUGO,
132 proc_iops: &proc_root_inode_operations,
133 proc_fops: &proc_root_operations,
138 EXPORT_SYMBOL(proc_sys_root);
140 EXPORT_SYMBOL(proc_symlink);
141 EXPORT_SYMBOL(proc_mknod);
142 EXPORT_SYMBOL(proc_mkdir);
143 EXPORT_SYMBOL(create_proc_entry);
144 EXPORT_SYMBOL(remove_proc_entry);
145 EXPORT_SYMBOL(proc_root);
146 EXPORT_SYMBOL(proc_root_fs);
147 EXPORT_SYMBOL(proc_net);
148 EXPORT_SYMBOL(proc_net_stat);
149 EXPORT_SYMBOL(proc_bus);
150 EXPORT_SYMBOL(proc_root_driver);