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 <asm/bitops.h>
19 struct proc_dir_entry
*proc_net
, *proc_bus
, *proc_root_fs
, *proc_root_driver
;
22 struct proc_dir_entry
*proc_sys_root
;
25 void __init
proc_root_init(void)
28 proc_net
= proc_mkdir("net", 0);
30 proc_mkdir("sysvipc", 0);
33 proc_sys_root
= proc_mkdir("sys", 0);
35 proc_root_fs
= proc_mkdir("fs", 0);
36 proc_root_driver
= proc_mkdir("driver", 0);
37 #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE)
38 /* just give it a mountpoint */
39 proc_mkdir("openprom", 0);
42 #ifdef CONFIG_PROC_DEVICETREE
43 proc_device_tree_init();
45 proc_bus
= proc_mkdir("bus", 0);
48 static struct dentry
*proc_root_lookup(struct inode
* dir
, struct dentry
* dentry
)
50 if (dir
->i_ino
== PROC_ROOT_INO
) { /* check for safety... */
51 int nlink
= proc_root
.nlink
;
58 if (!proc_lookup(dir
, dentry
))
61 return proc_pid_lookup(dir
, dentry
);
64 static int proc_root_readdir(struct file
* filp
,
65 void * dirent
, filldir_t filldir
)
67 unsigned int nr
= filp
->f_pos
;
69 if (nr
< FIRST_PROCESS_ENTRY
) {
70 int error
= proc_readdir(filp
, dirent
, filldir
);
73 filp
->f_pos
= FIRST_PROCESS_ENTRY
;
76 return proc_pid_readdir(filp
, dirent
, filldir
);
80 * The root /proc directory is special, as it has the
81 * <pid> directories. Thus we don't use the generic
82 * directory handling functions for that..
84 static struct file_operations proc_root_operations
= {
85 read
: generic_read_dir
,
86 readdir
: proc_root_readdir
,
90 * proc root can do almost nothing..
92 static struct inode_operations proc_root_inode_operations
= {
93 lookup
: proc_root_lookup
,
97 * This is the root "inode" in the /proc tree..
99 struct proc_dir_entry proc_root
= {
100 low_ino
: PROC_ROOT_INO
,
103 mode
: S_IFDIR
| S_IRUGO
| S_IXUGO
,
105 proc_iops
: &proc_root_inode_operations
,
106 proc_fops
: &proc_root_operations
,