Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
base.c File Reference
#include <asm/uaccess.h>
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/task_io_accounting_ops.h>
#include <linux/init.h>
#include <linux/capability.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/string.h>
#include <linux/seq_file.h>
#include <linux/namei.h>
#include <linux/mnt_namespace.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/rcupdate.h>
#include <linux/kallsyms.h>
#include <linux/stacktrace.h>
#include <linux/resource.h>
#include <linux/module.h>
#include <linux/mount.h>
#include <linux/security.h>
#include <linux/ptrace.h>
#include <linux/tracehook.h>
#include <linux/cgroup.h>
#include <linux/cpuset.h>
#include <linux/audit.h>
#include <linux/poll.h>
#include <linux/nsproxy.h>
#include <linux/oom.h>
#include <linux/elf.h>
#include <linux/pid_namespace.h>
#include <linux/user_namespace.h>
#include <linux/fs_struct.h>
#include <linux/slab.h>
#include <linux/flex_array.h>
#include <trace/events/oom.h>
#include "internal.h"
#include "fd.h"

Go to the source code of this file.

Data Structures

struct  pid_entry
 
struct  limit_names
 
struct  tgid_iter
 

Macros

#define NOD(NAME, MODE, IOP, FOP, OP)
 
#define DIR(NAME, MODE, iops, fops)   NOD(NAME, (S_IFDIR|(MODE)), &iops, &fops, {} )
 
#define LNK(NAME, get_link)
 
#define REG(NAME, MODE, fops)   NOD(NAME, (S_IFREG|(MODE)), NULL, &fops, {})
 
#define INF(NAME, MODE, read)
 
#define ONE(NAME, MODE, show)
 
#define PROC_BLOCK_SIZE   (3*1024) /* 4K page size but our output routines use some slack for overruns */
 
#define TGID_OFFSET   (FIRST_PROCESS_ENTRY + ARRAY_SIZE(proc_base_stuff))
 

Functions

int proc_setattr (struct dentry *dentry, struct iattr *attr)
 
loff_t mem_lseek (struct file *file, loff_t offset, int orig)
 
struct inodeproc_pid_make_inode (struct super_block *sb, struct task_struct *task)
 
int pid_getattr (struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 
int pid_revalidate (struct dentry *dentry, unsigned int flags)
 
int proc_fill_cache (struct file *filp, void *dirent, filldir_t filldir, const char *name, int len, instantiate_t instantiate, struct task_struct *task, const void *ptr)
 
void proc_flush_task (struct task_struct *task)
 
struct dentryproc_pid_lookup (struct inode *dir, struct dentry *dentry, unsigned int flags)
 
int proc_pid_readdir (struct file *filp, void *dirent, filldir_t filldir)
 

Variables

struct inode_operations proc_pid_link_inode_operations
 
struct dentry_operations pid_dentry_operations
 

Macro Definition Documentation

#define DIR (   NAME,
  MODE,
  iops,
  fops 
)    NOD(NAME, (S_IFDIR|(MODE)), &iops, &fops, {} )

Definition at line 123 of file base.c.

#define INF (   NAME,
  MODE,
  read 
)
Value:
NULL, &proc_info_file_operations, \
{ .proc_read = read } )

Definition at line 131 of file base.c.

#define LNK (   NAME,
  get_link 
)
Value:
{ .proc_get_link = get_link } )

Definition at line 125 of file base.c.

#define NOD (   NAME,
  MODE,
  IOP,
  FOP,
  OP 
)
Value:
{ \
.name = (NAME), \
.len = sizeof(NAME) - 1, \
.mode = MODE, \
.iop = IOP, \
.fop = FOP, \
.op = OP, \
}

Definition at line 114 of file base.c.

#define ONE (   NAME,
  MODE,
  show 
)
Value:
NULL, &proc_single_file_operations, \
{ .proc_show = show } )

Definition at line 135 of file base.c.

#define PROC_BLOCK_SIZE   (3*1024) /* 4K page size but our output routines use some slack for overruns */

Definition at line 607 of file base.c.

#define REG (   NAME,
  MODE,
  fops 
)    NOD(NAME, (S_IFREG|(MODE)), NULL, &fops, {})

Definition at line 129 of file base.c.

#define TGID_OFFSET   (FIRST_PROCESS_ENTRY + ARRAY_SIZE(proc_base_stuff))

Definition at line 2950 of file base.c.

Function Documentation

loff_t mem_lseek ( struct file file,
loff_t  offset,
int  orig 
)

Definition at line 776 of file base.c.

int pid_getattr ( struct vfsmount mnt,
struct dentry dentry,
struct kstat stat 
)

Definition at line 1547 of file base.c.

int pid_revalidate ( struct dentry dentry,
unsigned int  flags 
)

Definition at line 1597 of file base.c.

int proc_fill_cache ( struct file filp,
void dirent,
filldir_t  filldir,
const char name,
int  len,
instantiate_t  instantiate,
struct task_struct task,
const void ptr 
)

Definition at line 1650 of file base.c.

void proc_flush_task ( struct task_struct task)

proc_flush_task - Remove dcache entries for from the /proc dcache. : task that should be flushed.

When flushing dentries from proc, one needs to flush them from global proc (proc_mnt) and from all the namespaces' procs this task was seen in. This call is supposed to do all of this job.

Looks in the dcache for /proc/ /proc//task/ if either directory is present flushes it and all of it'ts children from the dcache.

It is safe and reasonable to cache /proc entries for a task until that task exits. After that they just clog up the dcache with useless entries, possibly causing useful dcache entries to be flushed instead. This routine is proved to flush those useless dcache entries at process exit time.

NOTE: This routine is just an optimization so it does not guarantee that no dcache entries will exist at process exit time it just makes it very unlikely that any will persist.

Definition at line 2828 of file base.c.

struct dentry* proc_pid_lookup ( struct inode dir,
struct dentry dentry,
unsigned int  flags 
)
read

Definition at line 2877 of file base.c.

struct inode* proc_pid_make_inode ( struct super_block sb,
struct task_struct task 
)
read

Definition at line 1505 of file base.c.

int proc_pid_readdir ( struct file filp,
void dirent,
filldir_t  filldir 
)

Definition at line 2968 of file base.c.

int proc_setattr ( struct dentry dentry,
struct iattr attr 
)

Definition at line 533 of file base.c.

Variable Documentation

struct dentry_operations pid_dentry_operations
Initial value:
=
{
.d_revalidate = pid_revalidate,
.d_delete = pid_delete_dentry,
}

Definition at line 1630 of file base.c.

struct inode_operations proc_pid_link_inode_operations
Initial value:
= {
.readlink = proc_pid_readlink,
.follow_link = proc_pid_follow_link,
.setattr = proc_setattr,
}

Definition at line 1496 of file base.c.