~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/fs/proc/root.c

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  linux/fs/proc/root.c
  3  *
  4  *  Copyright (C) 1991, 1992 Linus Torvalds
  5  *
  6  *  proc root directory handling functions
  7  */
  8 
  9 #include <asm/uaccess.h>
 10 
 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>
 18 
 19 struct proc_dir_entry *proc_net, *proc_bus, *proc_root_fs, *proc_root_driver;
 20 
 21 #ifdef CONFIG_SYSCTL
 22 struct proc_dir_entry *proc_sys_root;
 23 #endif
 24 
 25 void __init proc_root_init(void)
 26 {
 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);
 46 }
 47 
 48 static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry)
 49 {
 50         if (dir->i_ino == PROC_ROOT_INO) { /* check for safety... */
 51                 int nlink = proc_root.nlink;
 52 
 53                 nlink += nr_threads;
 54 
 55                 dir->i_nlink = nlink;
 56         }
 57 
 58         if (!proc_lookup(dir, dentry))
 59                 return NULL;
 60         
 61         return proc_pid_lookup(dir, dentry);
 62 }
 63 
 64 static int proc_root_readdir(struct file * filp,
 65         void * dirent, filldir_t filldir)
 66 {
 67         unsigned int nr = filp->f_pos;
 68 
 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;
 74         }
 75 
 76         return proc_pid_readdir(filp, dirent, filldir);
 77 }
 78 
 79 /*
 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..
 83  */
 84 static struct file_operations proc_root_operations = {
 85         read:            generic_read_dir,
 86         readdir:         proc_root_readdir,
 87 };
 88 
 89 /*
 90  * proc root can do almost nothing..
 91  */
 92 static struct inode_operations proc_root_inode_operations = {
 93         lookup:         proc_root_lookup,
 94 };
 95 
 96 /*
 97  * This is the root "inode" in the /proc tree..
 98  */
 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,
108 };
109 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.