Commit 59d8053f authored by David Howells's avatar David Howells Committed by Al Viro

proc: Move non-public stuff from linux/proc_fs.h to fs/proc/internal.h

Move non-public declarations and definitions from linux/proc_fs.h to
fs/proc/internal.h.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c30480b9
/* internal.h: internal procfs definitions /* Internal procfs definitions
* *
* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com) * Written by David Howells (dhowells@redhat.com)
...@@ -9,81 +9,66 @@ ...@@ -9,81 +9,66 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#include <linux/sched.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/proc_ns.h>
#include <linux/spinlock.h>
#include <linux/atomic.h>
#include <linux/binfmts.h> #include <linux/binfmts.h>
struct ctl_table_header;
struct mempolicy;
extern struct proc_dir_entry proc_root; struct ctl_table_header;
extern void proc_self_init(void); struct mempolicy;
#ifdef CONFIG_PROC_SYSCTL
extern int proc_sys_init(void);
extern void sysctl_head_put(struct ctl_table_header *head);
#else
static inline void proc_sys_init(void) { }
static inline void sysctl_head_put(struct ctl_table_header *head) { }
#endif
#ifdef CONFIG_NET
extern int proc_net_init(void);
#else
static inline int proc_net_init(void) { return 0; }
#endif
struct vmalloc_info { /*
unsigned long used; * This is not completely implemented yet. The idea is to
unsigned long largest_chunk; * create an in-memory tree (like the actual /proc filesystem
* tree) of these proc_dir_entries, so that we can dynamically
* add new files to /proc.
*
* The "next" pointer creates a linked list of one /proc directory,
* while parent/subdir create the directory structure (every
* /proc file has a parent, but "subdir" is NULL for all
* non-directory entries).
*/
struct proc_dir_entry {
unsigned int low_ino;
umode_t mode;
nlink_t nlink;
kuid_t uid;
kgid_t gid;
loff_t size;
const struct inode_operations *proc_iops;
const struct file_operations *proc_fops;
struct proc_dir_entry *next, *parent, *subdir;
void *data;
atomic_t count; /* use count */
atomic_t in_use; /* number of callers into module in progress; */
/* negative -> it's going away RSN */
struct completion *pde_unload_completion;
struct list_head pde_openers; /* who did ->open, but not ->release */
spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
u8 namelen;
char name[];
}; };
#ifdef CONFIG_MMU union proc_op {
#define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START) int (*proc_get_link)(struct dentry *, struct path *);
extern void get_vmalloc_info(struct vmalloc_info *vmi); int (*proc_read)(struct task_struct *task, char *page);
#else int (*proc_show)(struct seq_file *m,
struct pid_namespace *ns, struct pid *pid,
#define VMALLOC_TOTAL 0UL struct task_struct *task);
#define get_vmalloc_info(vmi) \ };
do { \
(vmi)->used = 0; \
(vmi)->largest_chunk = 0; \
} while(0)
#endif
extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task);
extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task);
extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task);
extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task);
extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
extern const struct file_operations proc_tid_children_operations;
extern const struct file_operations proc_pid_maps_operations;
extern const struct file_operations proc_tid_maps_operations;
extern const struct file_operations proc_pid_numa_maps_operations;
extern const struct file_operations proc_tid_numa_maps_operations;
extern const struct file_operations proc_pid_smaps_operations;
extern const struct file_operations proc_tid_smaps_operations;
extern const struct file_operations proc_clear_refs_operations;
extern const struct file_operations proc_pagemap_operations;
extern const struct file_operations proc_net_operations;
extern const struct inode_operations proc_net_inode_operations;
extern const struct inode_operations proc_pid_link_inode_operations;
struct proc_maps_private { struct proc_inode {
struct pid *pid; struct pid *pid;
struct task_struct *task; int fd;
#ifdef CONFIG_MMU union proc_op op;
struct vm_area_struct *tail_vma; struct proc_dir_entry *pde;
#endif struct ctl_table_header *sysctl;
#ifdef CONFIG_NUMA struct ctl_table *sysctl_entry;
struct mempolicy *task_mempolicy; struct proc_ns ns;
#endif struct inode vfs_inode;
}; };
void proc_init_inodecache(void);
/* /*
* General functions * General functions
*/ */
...@@ -150,79 +135,142 @@ static inline unsigned name_to_int(struct dentry *dentry) ...@@ -150,79 +135,142 @@ static inline unsigned name_to_int(struct dentry *dentry)
} }
/* /*
* base.c * Offset of the first process in the /proc root directory..
*/ */
extern int pid_delete_dentry(const struct dentry *); #define FIRST_PROCESS_ENTRY 256
struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *ino, /* Worst case buffer size needed for holding an integer. */
struct dentry *dentry); #define PROC_NUMBUF 13
int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
filldir_t filldir);
struct pde_opener { /*
struct file *file; * array.c
struct list_head lh; */
int closing; extern const struct file_operations proc_tid_children_operations;
struct completion *c;
}; extern int proc_tid_stat(struct seq_file *, struct pid_namespace *,
struct pid *, struct task_struct *);
extern int proc_tgid_stat(struct seq_file *, struct pid_namespace *,
struct pid *, struct task_struct *);
extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
struct pid *, struct task_struct *);
extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
struct pid *, struct task_struct *);
/*
* base.c
*/
extern const struct dentry_operations pid_dentry_operations;
extern int pid_getattr(struct vfsmount *, struct dentry *, struct kstat *);
extern int proc_setattr(struct dentry *, struct iattr *);
extern struct inode *proc_pid_make_inode(struct super_block *, struct task_struct *);
extern int pid_revalidate(struct dentry *, unsigned int);
extern int pid_delete_dentry(const struct dentry *);
extern int proc_pid_readdir(struct file *, void *, filldir_t);
extern struct dentry *proc_pid_lookup(struct inode *, struct dentry *, unsigned int);
extern loff_t mem_lseek(struct file *, loff_t, int);
void proc_entry_rundown(struct proc_dir_entry *); /* Lookups */
typedef struct dentry *instantiate_t(struct inode *, struct dentry *,
struct task_struct *, const void *);
extern int proc_fill_cache(struct file *, void *, filldir_t, const char *, int,
instantiate_t, struct task_struct *, const void *);
/*
* generic.c
*/
extern spinlock_t proc_subdir_lock; extern spinlock_t proc_subdir_lock;
struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsigned int); extern struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int);
int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir); extern struct dentry *proc_lookup_de(struct proc_dir_entry *, struct inode *,
unsigned long task_vsize(struct mm_struct *); struct dentry *);
unsigned long task_statm(struct mm_struct *, extern int proc_readdir(struct file *, void *, filldir_t);
unsigned long *, unsigned long *, unsigned long *, unsigned long *); extern int proc_readdir_de(struct proc_dir_entry *, struct file *, void *, filldir_t);
void task_mem(struct seq_file *, struct mm_struct *);
static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde) static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
{ {
atomic_inc(&pde->count); atomic_inc(&pde->count);
return pde; return pde;
} }
void pde_put(struct proc_dir_entry *pde); extern void pde_put(struct proc_dir_entry *);
/*
* inode.c
*/
struct pde_opener {
struct file *file;
struct list_head lh;
int closing;
struct completion *c;
};
int proc_fill_super(struct super_block *); extern const struct inode_operations proc_pid_link_inode_operations;
struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *);
int proc_remount(struct super_block *sb, int *flags, char *data); extern void proc_init_inodecache(void);
extern struct inode *proc_get_inode(struct super_block *, struct proc_dir_entry *);
extern int proc_fill_super(struct super_block *);
extern void proc_entry_rundown(struct proc_dir_entry *);
/* /*
* These are generic /proc routines that use the internal * mmu.c
* "struct proc_dir_entry" tree to traverse the filesystem.
*
* The /proc root directory has extended versions to take care
* of the /proc/<pid> subdirectories.
*/ */
int proc_readdir(struct file *, void *, filldir_t); struct vmalloc_info {
struct dentry *proc_lookup(struct inode *, struct dentry *, unsigned int); unsigned long used;
unsigned long largest_chunk;
};
#ifdef CONFIG_MMU
#define VMALLOC_TOTAL (VMALLOC_END - VMALLOC_START)
extern void get_vmalloc_info(struct vmalloc_info *);
#else
#define VMALLOC_TOTAL 0UL
static inline void get_vmalloc_info(struct vmalloc_info *vmi)
{
vmi->used = 0;
vmi->largest_chunk = 0;
}
#endif
/* Lookups */ /*
typedef struct dentry *instantiate_t(struct inode *, struct dentry *, * proc_devtree.c
struct task_struct *, const void *); */
int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir, #ifdef CONFIG_PROC_DEVICETREE
const char *name, int len, extern void proc_device_tree_init(void);
instantiate_t instantiate, struct task_struct *task, const void *ptr); #endif
int pid_revalidate(struct dentry *dentry, unsigned int flags);
struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *task);
extern const struct dentry_operations pid_dentry_operations;
int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
int proc_setattr(struct dentry *dentry, struct iattr *attr);
/*
* proc_namespaces.c
*/
extern const struct inode_operations proc_ns_dir_inode_operations; extern const struct inode_operations proc_ns_dir_inode_operations;
extern const struct file_operations proc_ns_dir_operations; extern const struct file_operations proc_ns_dir_operations;
/*
* proc_net.c
*/
extern const struct file_operations proc_net_operations;
extern const struct inode_operations proc_net_inode_operations;
#ifdef CONFIG_NET
extern int proc_net_init(void);
#else
static inline int proc_net_init(void) { return 0; }
#endif
/*
* proc_self.c
*/
extern int proc_setup_self(struct super_block *); extern int proc_setup_self(struct super_block *);
/* /*
* proc_devtree.c * proc_sysctl.c
*/ */
#ifdef CONFIG_PROC_DEVICETREE #ifdef CONFIG_PROC_SYSCTL
extern void proc_device_tree_init(void); extern int proc_sys_init(void);
#endif /* CONFIG_PROC_DEVICETREE */ extern void sysctl_head_put(struct ctl_table_header *);
#else
static inline void proc_sys_init(void) { }
static inline void sysctl_head_put(struct ctl_table_header *head) { }
#endif
/* /*
* proc_tty.c * proc_tty.c
...@@ -232,3 +280,40 @@ extern void proc_tty_init(void); ...@@ -232,3 +280,40 @@ extern void proc_tty_init(void);
#else #else
static inline void proc_tty_init(void) {} static inline void proc_tty_init(void) {}
#endif #endif
/*
* root.c
*/
extern struct proc_dir_entry proc_root;
extern void proc_self_init(void);
extern int proc_remount(struct super_block *, int *, char *);
/*
* task_[no]mmu.c
*/
struct proc_maps_private {
struct pid *pid;
struct task_struct *task;
#ifdef CONFIG_MMU
struct vm_area_struct *tail_vma;
#endif
#ifdef CONFIG_NUMA
struct mempolicy *task_mempolicy;
#endif
};
extern const struct file_operations proc_pid_maps_operations;
extern const struct file_operations proc_tid_maps_operations;
extern const struct file_operations proc_pid_numa_maps_operations;
extern const struct file_operations proc_tid_numa_maps_operations;
extern const struct file_operations proc_pid_smaps_operations;
extern const struct file_operations proc_tid_smaps_operations;
extern const struct file_operations proc_clear_refs_operations;
extern const struct file_operations proc_pagemap_operations;
extern unsigned long task_vsize(struct mm_struct *);
extern unsigned long task_statm(struct mm_struct *,
unsigned long *, unsigned long *,
unsigned long *, unsigned long *);
extern void task_mem(struct seq_file *, struct mm_struct *);
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/memory.h> #include <linux/memory.h>
#include <asm/sections.h> #include <asm/sections.h>
#include "internal.h"
#define CORE_STR "CORE" #define CORE_STR "CORE"
......
#ifndef _LINUX_PROC_FS_H
#define _LINUX_PROC_FS_H
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/spinlock.h>
#include <linux/magic.h>
#include <linux/atomic.h>
#include <linux/proc_ns.h>
struct net;
struct completion;
struct mm_struct;
/* /*
* The proc filesystem constants/structures * The proc filesystem constants/structures
*/ */
#ifndef _LINUX_PROC_FS_H
#define _LINUX_PROC_FS_H
/* #include <linux/types.h>
* Offset of the first process in the /proc root directory.. #include <linux/fs.h>
*/
#define FIRST_PROCESS_ENTRY 256
/* Worst case buffer size needed for holding an integer. */
#define PROC_NUMBUF 13
/*
* This is not completely implemented yet. The idea is to
* create an in-memory tree (like the actual /proc filesystem
* tree) of these proc_dir_entries, so that we can dynamically
* add new files to /proc.
*
* The "next" pointer creates a linked list of one /proc directory,
* while parent/subdir create the directory structure (every
* /proc file has a parent, but "subdir" is NULL for all
* non-directory entries).
*/
struct proc_dir_entry { struct proc_dir_entry;
unsigned int low_ino;
umode_t mode;
nlink_t nlink;
kuid_t uid;
kgid_t gid;
loff_t size;
const struct inode_operations *proc_iops;
const struct file_operations *proc_fops;
struct proc_dir_entry *next, *parent, *subdir;
void *data;
atomic_t count; /* use count */
atomic_t in_use; /* number of callers into module in progress; */
/* negative -> it's going away RSN */
struct completion *pde_unload_completion;
struct list_head pde_openers; /* who did ->open, but not ->release */
spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
u8 namelen;
char name[];
};
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
extern void proc_root_init(void); extern void proc_root_init(void);
extern void proc_flush_task(struct task_struct *);
void proc_flush_task(struct task_struct *task);
struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
struct proc_dir_entry *parent,
const struct file_operations *proc_fops,
void *data);
extern void proc_remove(struct proc_dir_entry *);
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
extern struct proc_dir_entry *proc_symlink(const char *, extern struct proc_dir_entry *proc_symlink(const char *,
struct proc_dir_entry *, const char *); struct proc_dir_entry *, const char *);
extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *);
extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t, extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
struct proc_dir_entry *, void *); struct proc_dir_entry *, void *);
extern struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode, extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
struct proc_dir_entry *parent); struct proc_dir_entry *);
static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode, extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
struct proc_dir_entry *parent, const struct file_operations *proc_fops) struct proc_dir_entry *,
const struct file_operations *,
void *);
static inline struct proc_dir_entry *proc_create(
const char *name, umode_t mode, struct proc_dir_entry *parent,
const struct file_operations *proc_fops)
{ {
return proc_create_data(name, mode, parent, proc_fops, NULL); return proc_create_data(name, mode, parent, proc_fops, NULL);
} }
extern void proc_set_size(struct proc_dir_entry *, loff_t); extern void proc_set_size(struct proc_dir_entry *, loff_t);
extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
extern void *PDE_DATA(const struct inode *); extern void *PDE_DATA(const struct inode *);
extern void *proc_get_parent_data(const struct inode *); extern void *proc_get_parent_data(const struct inode *);
#else extern void proc_remove(struct proc_dir_entry *);
extern void remove_proc_entry(const char *, struct proc_dir_entry *);
extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
#else /* CONFIG_PROC_FS */
static inline void proc_flush_task(struct task_struct *task) static inline void proc_flush_task(struct task_struct *task)
{ {
} }
#define proc_create(name, mode, parent, fops) ({ (void)(mode), NULL; })
static inline struct proc_dir_entry *proc_create_data(const char *name,
umode_t mode, struct proc_dir_entry *parent,
const struct file_operations *proc_fops, void *data)
{
return NULL;
}
static inline void proc_remove(struct proc_dir_entry *de) {}
#define remove_proc_entry(name, parent) do {} while (0)
#define remove_proc_subtree(name, parent) do {} while (0)
static inline struct proc_dir_entry *proc_symlink(const char *name, static inline struct proc_dir_entry *proc_symlink(const char *name,
struct proc_dir_entry *parent,const char *dest) {return NULL;} struct proc_dir_entry *parent,const char *dest) { return NULL;}
static inline struct proc_dir_entry *proc_mkdir(const char *name, static inline struct proc_dir_entry *proc_mkdir(const char *name,
struct proc_dir_entry *parent) {return NULL;} struct proc_dir_entry *parent) {return NULL;}
static inline struct proc_dir_entry *proc_mkdir_data(const char *name, static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; } umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
umode_t mode, struct proc_dir_entry *parent) { return NULL; } umode_t mode, struct proc_dir_entry *parent) { return NULL; }
#define proc_create(name, mode, parent, proc_fops) ({NULL;})
#define proc_create_data(name, mode, parent, proc_fops, data) ({NULL;})
static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {} static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {} static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;} static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); return NULL; }
#endif /* CONFIG_PROC_FS */ static inline void proc_remove(struct proc_dir_entry *de) {}
#define remove_proc_entry(name, parent) do {} while (0)
static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
union proc_op {
int (*proc_get_link)(struct dentry *, struct path *);
int (*proc_read)(struct task_struct *task, char *page);
int (*proc_show)(struct seq_file *m,
struct pid_namespace *ns, struct pid *pid,
struct task_struct *task);
};
struct ctl_table_header;
struct ctl_table;
struct proc_inode { #endif /* CONFIG_PROC_FS */
struct pid *pid;
int fd;
union proc_op op;
struct proc_dir_entry *pde;
struct ctl_table_header *sysctl;
struct ctl_table *sysctl_entry;
struct proc_ns ns;
struct inode vfs_inode;
};
static inline struct proc_dir_entry *proc_net_mkdir( static inline struct proc_dir_entry *proc_net_mkdir(
struct net *net, const char *name, struct proc_dir_entry *parent) struct net *net, const char *name, struct proc_dir_entry *parent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment