Ok. I didn't make 2.4.0 in 2000. Tough. I tried, but we had some
[davej-history.git] / fs / proc / root.c
blobc54369a320cf81e0014187791abe40612790eeaa
1 /*
2 * linux/fs/proc/root.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
6 * proc root directory handling functions
7 */
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;
21 #ifdef CONFIG_SYSCTL
22 struct proc_dir_entry *proc_sys_root;
23 #endif
25 void __init proc_root_init(void)
27 proc_misc_init();
28 proc_net = proc_mkdir("net", 0);
29 #ifdef CONFIG_SYSVIPC
30 proc_mkdir("sysvipc", 0);
31 #endif
32 #ifdef CONFIG_SYSCTL
33 proc_sys_root = proc_mkdir("sys", 0);
34 #endif
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);
40 #endif
41 proc_tty_init();
42 #ifdef CONFIG_PROC_DEVICETREE
43 proc_device_tree_init();
44 #endif
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;
53 nlink += nr_threads;
55 dir->i_nlink = nlink;
58 if (!proc_lookup(dir, dentry))
59 return NULL;
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);
71 if (error <= 0)
72 return error;
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,
101 namelen: 5,
102 name: "/proc",
103 mode: S_IFDIR | S_IRUGO | S_IXUGO,
104 nlink: 2,
105 proc_iops: &proc_root_inode_operations,
106 proc_fops: &proc_root_operations,
107 parent: &proc_root,