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>
19 #ifdef CONFIG_PPC_ISERIES
20 #include <asm/iSeries/iSeries_proc.h>
23 struct proc_dir_entry *proc_net, *proc_bus, *proc_root_fs, *proc_root_driver;
26 struct proc_dir_entry *proc_sys_root;
29 static DECLARE_FSTYPE(proc_fs_type, "proc", proc_read_super, FS_SINGLE);
31 void __init proc_root_init(void)
33 int err = register_filesystem(&proc_fs_type);
36 proc_mnt = kern_mount(&proc_fs_type);
37 err = PTR_ERR(proc_mnt);
38 if (IS_ERR(proc_mnt)) {
39 unregister_filesystem(&proc_fs_type);
43 proc_net = proc_mkdir("net", 0);
45 proc_mkdir("sysvipc", 0);
48 proc_sys_root = proc_mkdir("sys", 0);
50 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
51 proc_mkdir("sys/fs", 0);
52 proc_mkdir("sys/fs/binfmt_misc", 0);
54 proc_root_fs = proc_mkdir("fs", 0);
55 proc_root_driver = proc_mkdir("driver", 0);
56 #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE)
57 /* just give it a mountpoint */
58 proc_mkdir("openprom", 0);
61 #ifdef CONFIG_PROC_DEVICETREE
62 proc_device_tree_init();
64 #ifdef CONFIG_PPC_ISERIES
65 iSeries_proc_create();
70 #ifdef CONFIG_PPC_RTAS
73 proc_bus = proc_mkdir("bus", 0);
76 static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry)
78 if (dir->i_ino == PROC_ROOT_INO) { /* check for safety... */
79 int nlink = proc_root.nlink;
86 if (!proc_lookup(dir, dentry))
89 return proc_pid_lookup(dir, dentry);
92 static int proc_root_readdir(struct file * filp,
93 void * dirent, filldir_t filldir)
95 unsigned int nr = filp->f_pos;
97 if (nr < FIRST_PROCESS_ENTRY) {
98 int error = proc_readdir(filp, dirent, filldir);
101 filp->f_pos = FIRST_PROCESS_ENTRY;
104 return proc_pid_readdir(filp, dirent, filldir);
108 * The root /proc directory is special, as it has the
109 * <pid> directories. Thus we don't use the generic
110 * directory handling functions for that..
112 static struct file_operations proc_root_operations = {
113 read: generic_read_dir,
114 readdir: proc_root_readdir,
118 * proc root can do almost nothing..
120 static struct inode_operations proc_root_inode_operations = {
121 lookup: proc_root_lookup,
125 * This is the root "inode" in the /proc tree..
127 struct proc_dir_entry proc_root = {
128 low_ino: PROC_ROOT_INO,
131 mode: S_IFDIR | S_IRUGO | S_IXUGO,
133 proc_iops: &proc_root_inode_operations,
134 proc_fops: &proc_root_operations,
139 EXPORT_SYMBOL(proc_sys_root);
141 EXPORT_SYMBOL(proc_symlink);
142 EXPORT_SYMBOL(proc_mknod);
143 EXPORT_SYMBOL(proc_mkdir);
144 EXPORT_SYMBOL(create_proc_entry);
145 EXPORT_SYMBOL(remove_proc_entry);
146 EXPORT_SYMBOL(proc_root);
147 EXPORT_SYMBOL(proc_root_fs);
148 EXPORT_SYMBOL(proc_net);
149 EXPORT_SYMBOL(proc_bus);
150 EXPORT_SYMBOL(proc_root_driver);