root/fs/proc/base.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. proc_pid_fill_inode
  2. proc_base_init

   1 /*
   2  *  linux/fs/proc/base.c
   3  *
   4  *  Copyright (C) 1991, 1992 Linus Torvalds
   5  *
   6  *  proc base directory handling functions
   7  */
   8 
   9 #include <asm/segment.h>
  10 
  11 #include <linux/errno.h>
  12 #include <linux/sched.h>
  13 #include <linux/proc_fs.h>
  14 #include <linux/stat.h>
  15 
  16 static struct file_operations proc_base_operations = {
  17         NULL,                   /* lseek - default */
  18         NULL,                   /* read - bad */
  19         NULL,                   /* write - bad */
  20         proc_readdir,           /* readdir */
  21         NULL,                   /* select - default */
  22         NULL,                   /* ioctl - default */
  23         NULL,                   /* mmap */
  24         NULL,                   /* no special open code */
  25         NULL,                   /* no special release code */
  26         NULL                    /* can't fsync */
  27 };
  28 
  29 /*
  30  * proc directories can do almost nothing..
  31  */
  32 static struct inode_operations proc_base_inode_operations = {
  33         &proc_base_operations,  /* default base directory file-ops */
  34         NULL,                   /* create */
  35         proc_lookup,            /* lookup */
  36         NULL,                   /* link */
  37         NULL,                   /* unlink */
  38         NULL,                   /* symlink */
  39         NULL,                   /* mkdir */
  40         NULL,                   /* rmdir */
  41         NULL,                   /* mknod */
  42         NULL,                   /* rename */
  43         NULL,                   /* readlink */
  44         NULL,                   /* follow_link */
  45         NULL,                   /* bmap */
  46         NULL,                   /* truncate */
  47         NULL                    /* permission */
  48 };
  49 
  50 static void proc_pid_fill_inode(struct inode * inode)
     /* [previous][next][first][last][top][bottom][index][help] */
  51 {
  52         struct task_struct * p;
  53         int pid = inode->i_ino >> 16;
  54         int ino = inode->i_ino & 0xffff;
  55 
  56         for_each_task(p) {
  57                 if (p->pid == pid) {
  58                         if (p->dumpable || ino == PROC_PID_INO) {
  59                                 inode->i_uid = p->euid;
  60                                 inode->i_gid = p->gid;
  61                         }
  62                         return;
  63                 }
  64         }
  65 }
  66 
  67 /*
  68  * This is really a pseudo-entry, and only links
  69  * backwards to the parent with no link from the
  70  * root directory to this. This way we can have just
  71  * one entry for every /proc/<pid>/ directory.
  72  */
  73 struct proc_dir_entry proc_pid = {
  74         PROC_PID_INO, 5, "<pid>",
  75         S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0,
  76         0, &proc_base_inode_operations,
  77         NULL, proc_pid_fill_inode,
  78         NULL, &proc_root, NULL
  79 };
  80 
  81 void proc_base_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  82 {
  83         proc_register(&proc_pid, &(struct proc_dir_entry) {
  84                 PROC_PID_MEM, 3, "mem",
  85                 S_IFREG | S_IRUSR | S_IWUSR, 1, 0, 0,
  86                 0, &proc_mem_inode_operations,
  87                 NULL, proc_pid_fill_inode,
  88         });
  89         proc_register(&proc_pid, &(struct proc_dir_entry) {
  90                 PROC_PID_CWD, 3, "cwd",
  91                 S_IFLNK | S_IRWXU, 1, 0, 0,
  92                 0, &proc_link_inode_operations,
  93                 NULL, proc_pid_fill_inode,
  94         });
  95         proc_register(&proc_pid, &(struct proc_dir_entry) {
  96                 PROC_PID_ROOT, 4, "root",
  97                 S_IFLNK | S_IRWXU, 1, 0, 0,
  98                 0, &proc_link_inode_operations,
  99                 NULL, proc_pid_fill_inode,
 100         });
 101         proc_register(&proc_pid, &(struct proc_dir_entry) {
 102                 PROC_PID_EXE, 3, "exe",
 103                 S_IFLNK | S_IRWXU, 1, 0, 0,
 104                 0, &proc_link_inode_operations,
 105                 NULL, proc_pid_fill_inode,
 106         });
 107         proc_register(&proc_pid, &(struct proc_dir_entry) {
 108                 PROC_PID_FD, 2, "fd",
 109                 S_IFDIR | S_IRUSR | S_IXUSR, 1, 0, 0,
 110                 0, &proc_fd_inode_operations,
 111                 NULL, proc_pid_fill_inode,
 112         });
 113         proc_register(&proc_pid, &(struct proc_dir_entry) {
 114                 PROC_PID_ENVIRON, 7, "environ",
 115                 S_IFREG | S_IRUSR, 1, 0, 0,
 116                 0, &proc_array_inode_operations,
 117                 NULL, proc_pid_fill_inode,
 118         });
 119         proc_register(&proc_pid, &(struct proc_dir_entry) {
 120                 PROC_PID_CMDLINE, 7, "cmdline",
 121                 S_IFREG | S_IRUGO, 1, 0, 0,
 122                 0, &proc_array_inode_operations,
 123                 NULL, proc_pid_fill_inode,
 124         });
 125         proc_register(&proc_pid, &(struct proc_dir_entry) {
 126                 PROC_PID_STAT, 4, "stat",
 127                 S_IFREG | S_IRUGO, 1, 0, 0,
 128                 0, &proc_array_inode_operations,
 129                 NULL, proc_pid_fill_inode,
 130         });
 131         proc_register(&proc_pid, &(struct proc_dir_entry) {
 132                 PROC_PID_STATM, 5, "statm",
 133                 S_IFREG | S_IRUGO, 1, 0, 0,
 134                 0, &proc_array_inode_operations,
 135                 NULL, proc_pid_fill_inode,
 136         });
 137         proc_register(&proc_pid, &(struct proc_dir_entry) {
 138                 PROC_PID_MAPS, 4, "maps",
 139                 S_IFIFO | S_IRUGO, 1, 0, 0,
 140                 0, &proc_arraylong_inode_operations,
 141                 NULL, proc_pid_fill_inode,
 142         });
 143 };

/* [previous][next][first][last][top][bottom][index][help] */