Commit 4b64f8f0 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] (2/2) inode trimming

	procfs switched to alloc_inode/destroy_inode.
parent 628561a6
...@@ -876,7 +876,7 @@ static int comx_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -876,7 +876,7 @@ static int comx_mkdir(struct inode *dir, struct dentry *dentry, int mode)
static int comx_rmdir(struct inode *dir, struct dentry *dentry) static int comx_rmdir(struct inode *dir, struct dentry *dentry)
{ {
struct proc_dir_entry *entry = dentry->d_inode->u.generic_ip; struct proc_dir_entry *entry = PDE(dentry->d_inode);
struct net_device *dev = entry->data; struct net_device *dev = entry->data;
struct comx_channel *ch = dev->priv; struct comx_channel *ch = dev->priv;
int ret; int ret;
...@@ -928,7 +928,7 @@ static struct dentry *comx_lookup(struct inode *dir, struct dentry *dentry) ...@@ -928,7 +928,7 @@ static struct dentry *comx_lookup(struct inode *dir, struct dentry *dentry)
struct proc_dir_entry *de; struct proc_dir_entry *de;
struct inode *inode = NULL; struct inode *inode = NULL;
if ((de = (struct proc_dir_entry *) dir->u.generic_ip) != NULL) { if ((de = PDE(dir)) != NULL) {
for (de = de->subdir ; de ; de = de->next) { for (de = de->subdir ; de ; de = de->next) {
if ((de && de->low_ino) && if ((de && de->low_ino) &&
(de->namelen == dentry->d_name.len) && (de->namelen == dentry->d_name.len) &&
......
...@@ -2280,7 +2280,7 @@ static ssize_t proc_write( struct file *file, ...@@ -2280,7 +2280,7 @@ static ssize_t proc_write( struct file *file,
static int proc_status_open( struct inode *inode, struct file *file ) { static int proc_status_open( struct inode *inode, struct file *file ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *apriv = (struct airo_info *)dev->priv; struct airo_info *apriv = (struct airo_info *)dev->priv;
CapabilityRid cap_rid; CapabilityRid cap_rid;
...@@ -2289,8 +2289,6 @@ static int proc_status_open( struct inode *inode, struct file *file ) { ...@@ -2289,8 +2289,6 @@ static int proc_status_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
dp = inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data)); memset(file->private_data, 0, sizeof(struct proc_data));
...@@ -2364,7 +2362,7 @@ static int proc_stats_rid_open( struct inode *inode, ...@@ -2364,7 +2362,7 @@ static int proc_stats_rid_open( struct inode *inode,
struct file *file, struct file *file,
u16 rid ) { u16 rid ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *apriv = (struct airo_info *)dev->priv; struct airo_info *apriv = (struct airo_info *)dev->priv;
StatsRid stats; StatsRid stats;
...@@ -2372,9 +2370,6 @@ static int proc_stats_rid_open( struct inode *inode, ...@@ -2372,9 +2370,6 @@ static int proc_stats_rid_open( struct inode *inode,
int *vals = stats.vals; int *vals = stats.vals;
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
dp = inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data)); memset(file->private_data, 0, sizeof(struct proc_data));
...@@ -2433,7 +2428,7 @@ static void checkThrottle(ConfigRid *config) { ...@@ -2433,7 +2428,7 @@ static void checkThrottle(ConfigRid *config) {
static void proc_config_on_close( struct inode *inode, struct file *file ) { static void proc_config_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data = file->private_data; struct proc_data *data = file->private_data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
ConfigRid config; ConfigRid config;
...@@ -2442,7 +2437,6 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) { ...@@ -2442,7 +2437,6 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
int need_reset = 0; int need_reset = 0;
if ( !data->writelen ) return; if ( !data->writelen ) return;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
disable_MAC(ai); disable_MAC(ai);
readConfigRid(ai, &config); readConfigRid(ai, &config);
...@@ -2629,7 +2623,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) { ...@@ -2629,7 +2623,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
static int proc_config_open( struct inode *inode, struct file *file ) { static int proc_config_open( struct inode *inode, struct file *file ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
ConfigRid config; ConfigRid config;
...@@ -2637,8 +2631,6 @@ static int proc_config_open( struct inode *inode, struct file *file ) { ...@@ -2637,8 +2631,6 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data)); memset(file->private_data, 0, sizeof(struct proc_data));
...@@ -2723,7 +2715,7 @@ static int proc_config_open( struct inode *inode, struct file *file ) { ...@@ -2723,7 +2715,7 @@ static int proc_config_open( struct inode *inode, struct file *file ) {
static void proc_SSID_on_close( struct inode *inode, struct file *file ) { static void proc_SSID_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data = (struct proc_data *)file->private_data; struct proc_data *data = (struct proc_data *)file->private_data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
SsidRid SSID_rid; SsidRid SSID_rid;
...@@ -2759,7 +2751,7 @@ inline static u8 hexVal(char c) { ...@@ -2759,7 +2751,7 @@ inline static u8 hexVal(char c) {
static void proc_APList_on_close( struct inode *inode, struct file *file ) { static void proc_APList_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data = (struct proc_data *)file->private_data; struct proc_data *data = (struct proc_data *)file->private_data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
APListRid APList_rid; APListRid APList_rid;
...@@ -2852,7 +2844,7 @@ static int set_wep_key(struct airo_info *ai, u16 index, ...@@ -2852,7 +2844,7 @@ static int set_wep_key(struct airo_info *ai, u16 index,
static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
int i; int i;
...@@ -2862,7 +2854,6 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { ...@@ -2862,7 +2854,6 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
memset(key, 0, sizeof(key)); memset(key, 0, sizeof(key));
dp = (struct proc_dir_entry *) inode->u.generic_ip;
data = (struct proc_data *)file->private_data; data = (struct proc_data *)file->private_data;
if ( !data->writelen ) return; if ( !data->writelen ) return;
...@@ -2894,7 +2885,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) { ...@@ -2894,7 +2885,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
static int proc_wepkey_open( struct inode *inode, struct file *file ) { static int proc_wepkey_open( struct inode *inode, struct file *file ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
char *ptr; char *ptr;
...@@ -2905,8 +2896,6 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) { ...@@ -2905,8 +2896,6 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data)); memset(file->private_data, 0, sizeof(struct proc_data));
...@@ -2948,7 +2937,7 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) { ...@@ -2948,7 +2937,7 @@ static int proc_wepkey_open( struct inode *inode, struct file *file ) {
static int proc_SSID_open( struct inode *inode, struct file *file ) { static int proc_SSID_open( struct inode *inode, struct file *file ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
int i; int i;
...@@ -2957,8 +2946,6 @@ static int proc_SSID_open( struct inode *inode, struct file *file ) { ...@@ -2957,8 +2946,6 @@ static int proc_SSID_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data)); memset(file->private_data, 0, sizeof(struct proc_data));
...@@ -2996,7 +2983,7 @@ static int proc_SSID_open( struct inode *inode, struct file *file ) { ...@@ -2996,7 +2983,7 @@ static int proc_SSID_open( struct inode *inode, struct file *file ) {
static int proc_APList_open( struct inode *inode, struct file *file ) { static int proc_APList_open( struct inode *inode, struct file *file ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
int i; int i;
...@@ -3005,8 +2992,6 @@ static int proc_APList_open( struct inode *inode, struct file *file ) { ...@@ -3005,8 +2992,6 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data)); memset(file->private_data, 0, sizeof(struct proc_data));
...@@ -3048,7 +3033,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) { ...@@ -3048,7 +3033,7 @@ static int proc_APList_open( struct inode *inode, struct file *file ) {
static int proc_BSSList_open( struct inode *inode, struct file *file ) { static int proc_BSSList_open( struct inode *inode, struct file *file ) {
struct proc_data *data; struct proc_data *data;
struct proc_dir_entry *dp = inode->u.generic_ip; struct proc_dir_entry *dp = PDE(inode);
struct net_device *dev = dp->data; struct net_device *dev = dp->data;
struct airo_info *ai = (struct airo_info*)dev->priv; struct airo_info *ai = (struct airo_info*)dev->priv;
char *ptr; char *ptr;
...@@ -3059,8 +3044,6 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) { ...@@ -3059,8 +3044,6 @@ static int proc_BSSList_open( struct inode *inode, struct file *file ) {
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
dp = (struct proc_dir_entry *) inode->u.generic_ip;
if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) if ((file->private_data = kmalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(file->private_data, 0, sizeof(struct proc_data)); memset(file->private_data, 0, sizeof(struct proc_data));
......
...@@ -45,7 +45,7 @@ static ssize_t ...@@ -45,7 +45,7 @@ static ssize_t
proc_bus_pci_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos) proc_bus_pci_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
{ {
const struct inode *ino = file->f_dentry->d_inode; const struct inode *ino = file->f_dentry->d_inode;
const struct proc_dir_entry *dp = ino->u.generic_ip; const struct proc_dir_entry *dp = PDE(ino);
struct pci_dev *dev = dp->data; struct pci_dev *dev = dp->data;
unsigned int pos = *ppos; unsigned int pos = *ppos;
unsigned int cnt, size; unsigned int cnt, size;
...@@ -127,7 +127,7 @@ static ssize_t ...@@ -127,7 +127,7 @@ static ssize_t
proc_bus_pci_write(struct file *file, const char *buf, size_t nbytes, loff_t *ppos) proc_bus_pci_write(struct file *file, const char *buf, size_t nbytes, loff_t *ppos)
{ {
const struct inode *ino = file->f_dentry->d_inode; const struct inode *ino = file->f_dentry->d_inode;
const struct proc_dir_entry *dp = ino->u.generic_ip; const struct proc_dir_entry *dp = PDE(ino);
struct pci_dev *dev = dp->data; struct pci_dev *dev = dp->data;
int pos = *ppos; int pos = *ppos;
int cnt; int cnt;
...@@ -199,7 +199,7 @@ struct pci_filp_private { ...@@ -199,7 +199,7 @@ struct pci_filp_private {
static int proc_bus_pci_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) static int proc_bus_pci_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{ {
const struct proc_dir_entry *dp = inode->u.generic_ip; const struct proc_dir_entry *dp = PDE(inode);
struct pci_dev *dev = dp->data; struct pci_dev *dev = dp->data;
#ifdef HAVE_PCI_MMAP #ifdef HAVE_PCI_MMAP
struct pci_filp_private *fpriv = file->private_data; struct pci_filp_private *fpriv = file->private_data;
...@@ -241,7 +241,7 @@ static int proc_bus_pci_ioctl(struct inode *inode, struct file *file, unsigned i ...@@ -241,7 +241,7 @@ static int proc_bus_pci_ioctl(struct inode *inode, struct file *file, unsigned i
static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
{ {
struct inode *inode = file->f_dentry->d_inode; struct inode *inode = file->f_dentry->d_inode;
const struct proc_dir_entry *dp = inode->u.generic_ip; const struct proc_dir_entry *dp = PDE(inode);
struct pci_dev *dev = dp->data; struct pci_dev *dev = dp->data;
struct pci_filp_private *fpriv = file->private_data; struct pci_filp_private *fpriv = file->private_data;
int ret; int ret;
......
...@@ -234,7 +234,7 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence) ...@@ -234,7 +234,7 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
static ssize_t isapnp_proc_bus_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos) static ssize_t isapnp_proc_bus_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
{ {
struct inode *ino = file->f_dentry->d_inode; struct inode *ino = file->f_dentry->d_inode;
struct proc_dir_entry *dp = ino->u.generic_ip; struct proc_dir_entry *dp = PDE(ino);
struct pci_dev *dev = dp->data; struct pci_dev *dev = dp->data;
int pos = *ppos; int pos = *ppos;
int cnt, size = 256; int cnt, size = 256;
......
...@@ -5618,7 +5618,7 @@ ov511_control_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -5618,7 +5618,7 @@ ov511_control_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
void *arg = (void *) ularg; void *arg = (void *) ularg;
int rc; int rc;
pde = (struct proc_dir_entry *) inode->u.generic_ip; pde = PDE(inode);
if (!pde) if (!pde)
return -ENOENT; return -ENOENT;
......
...@@ -476,7 +476,7 @@ struct uhci_proc { ...@@ -476,7 +476,7 @@ struct uhci_proc {
static int uhci_proc_open(struct inode *inode, struct file *file) static int uhci_proc_open(struct inode *inode, struct file *file)
{ {
const struct proc_dir_entry *dp = inode->u.generic_ip; const struct proc_dir_entry *dp = PDE(inode);
struct uhci *uhci = dp->data; struct uhci *uhci = dp->data;
struct uhci_proc *up; struct uhci_proc *up;
unsigned long flags; unsigned long flags;
......
...@@ -45,7 +45,7 @@ static ssize_t ...@@ -45,7 +45,7 @@ static ssize_t
proc_bus_zorro_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos) proc_bus_zorro_read(struct file *file, char *buf, size_t nbytes, loff_t *ppos)
{ {
struct inode *ino = file->f_dentry->d_inode; struct inode *ino = file->f_dentry->d_inode;
struct proc_dir_entry *dp = ino->u.generic_ip; struct proc_dir_entry *dp = PDE(ino);
struct zorro_dev *dev = dp->data; struct zorro_dev *dev = dp->data;
struct ConfigDev cd; struct ConfigDev cd;
int pos = *ppos; int pos = *ppos;
......
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
#define fake_ino(pid,ino) (((pid)<<16)|(ino)) #define fake_ino(pid,ino) (((pid)<<16)|(ino))
static inline struct task_struct *proc_task(struct inode *inode)
{
return PROC_I(inode)->task;
}
ssize_t proc_pid_read_maps(struct task_struct*,struct file*,char*,size_t,loff_t*); ssize_t proc_pid_read_maps(struct task_struct*,struct file*,char*,size_t,loff_t*);
int proc_pid_stat(struct task_struct*,char*); int proc_pid_stat(struct task_struct*,char*);
int proc_pid_status(struct task_struct*,char*); int proc_pid_status(struct task_struct*,char*);
...@@ -45,9 +50,10 @@ int proc_pid_cpu(struct task_struct*,char*); ...@@ -45,9 +50,10 @@ int proc_pid_cpu(struct task_struct*,char*);
static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) static int proc_fd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt)
{ {
if (inode->u.proc_i.file) { struct file *file = PROC_I(inode)->file;
*mnt = mntget(inode->u.proc_i.file->f_vfsmnt); if (file) {
*dentry = dget(inode->u.proc_i.file->f_dentry); *mnt = mntget(file->f_vfsmnt);
*dentry = dget(file->f_dentry);
return 0; return 0;
} }
return -ENOENT; return -ENOENT;
...@@ -58,7 +64,7 @@ static int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfs ...@@ -58,7 +64,7 @@ static int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfs
struct mm_struct * mm; struct mm_struct * mm;
struct vm_area_struct * vma; struct vm_area_struct * vma;
int result = -ENOENT; int result = -ENOENT;
struct task_struct *task = inode->u.proc_i.task; struct task_struct *task = proc_task(inode);
task_lock(task); task_lock(task);
mm = task->mm; mm = task->mm;
...@@ -89,11 +95,11 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs ...@@ -89,11 +95,11 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs
{ {
struct fs_struct *fs; struct fs_struct *fs;
int result = -ENOENT; int result = -ENOENT;
task_lock(inode->u.proc_i.task); task_lock(proc_task(inode));
fs = inode->u.proc_i.task->fs; fs = proc_task(inode)->fs;
if(fs) if(fs)
atomic_inc(&fs->count); atomic_inc(&fs->count);
task_unlock(inode->u.proc_i.task); task_unlock(proc_task(inode));
if (fs) { if (fs) {
read_lock(&fs->lock); read_lock(&fs->lock);
*mnt = mntget(fs->pwdmnt); *mnt = mntget(fs->pwdmnt);
...@@ -109,11 +115,11 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf ...@@ -109,11 +115,11 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf
{ {
struct fs_struct *fs; struct fs_struct *fs;
int result = -ENOENT; int result = -ENOENT;
task_lock(inode->u.proc_i.task); task_lock(proc_task(inode));
fs = inode->u.proc_i.task->fs; fs = proc_task(inode)->fs;
if(fs) if(fs)
atomic_inc(&fs->count); atomic_inc(&fs->count);
task_unlock(inode->u.proc_i.task); task_unlock(proc_task(inode));
if (fs) { if (fs) {
read_lock(&fs->lock); read_lock(&fs->lock);
*mnt = mntget(fs->rootmnt); *mnt = mntget(fs->rootmnt);
...@@ -238,7 +244,7 @@ static ssize_t pid_maps_read(struct file * file, char * buf, ...@@ -238,7 +244,7 @@ static ssize_t pid_maps_read(struct file * file, char * buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct inode * inode = file->f_dentry->d_inode; struct inode * inode = file->f_dentry->d_inode;
struct task_struct *task = inode->u.proc_i.task; struct task_struct *task = proc_task(inode);
ssize_t res; ssize_t res;
res = proc_pid_read_maps(task, file, buf, count, ppos); res = proc_pid_read_maps(task, file, buf, count, ppos);
...@@ -252,7 +258,7 @@ static struct file_operations proc_maps_operations = { ...@@ -252,7 +258,7 @@ static struct file_operations proc_maps_operations = {
extern struct seq_operations mounts_op; extern struct seq_operations mounts_op;
static int mounts_open(struct inode *inode, struct file *file) static int mounts_open(struct inode *inode, struct file *file)
{ {
struct task_struct *task = inode->u.proc_i.task; struct task_struct *task = proc_task(inode);
int ret = seq_open(file, &mounts_op); int ret = seq_open(file, &mounts_op);
if (!ret) { if (!ret) {
...@@ -298,14 +304,14 @@ static ssize_t proc_info_read(struct file * file, char * buf, ...@@ -298,14 +304,14 @@ static ssize_t proc_info_read(struct file * file, char * buf,
unsigned long page; unsigned long page;
ssize_t length; ssize_t length;
ssize_t end; ssize_t end;
struct task_struct *task = inode->u.proc_i.task; struct task_struct *task = proc_task(inode);
if (count > PROC_BLOCK_SIZE) if (count > PROC_BLOCK_SIZE)
count = PROC_BLOCK_SIZE; count = PROC_BLOCK_SIZE;
if (!(page = __get_free_page(GFP_KERNEL))) if (!(page = __get_free_page(GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
length = inode->u.proc_i.op.proc_read(task, (char*)page); length = PROC_I(inode)->op.proc_read(task, (char*)page);
if (length < 0) { if (length < 0) {
free_page(page); free_page(page);
...@@ -342,7 +348,7 @@ static int mem_open(struct inode* inode, struct file* file) ...@@ -342,7 +348,7 @@ static int mem_open(struct inode* inode, struct file* file)
static ssize_t mem_read(struct file * file, char * buf, static ssize_t mem_read(struct file * file, char * buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct task_struct *task = file->f_dentry->d_inode->u.proc_i.task; struct task_struct *task = proc_task(file->f_dentry->d_inode);
char *page; char *page;
unsigned long src = *ppos; unsigned long src = *ppos;
int copied = 0; int copied = 0;
...@@ -404,7 +410,7 @@ static ssize_t mem_write(struct file * file, const char * buf, ...@@ -404,7 +410,7 @@ static ssize_t mem_write(struct file * file, const char * buf,
{ {
int copied = 0; int copied = 0;
char *page; char *page;
struct task_struct *task = file->f_dentry->d_inode->u.proc_i.task; struct task_struct *task = proc_task(file->f_dentry->d_inode);
unsigned long dst = *ppos; unsigned long dst = *ppos;
if (!MAY_PTRACE(task)) if (!MAY_PTRACE(task))
...@@ -463,7 +469,7 @@ static int proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) ...@@ -463,7 +469,7 @@ static int proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
if (error) if (error)
goto out; goto out;
error = inode->u.proc_i.op.proc_get_link(inode, &nd->dentry, &nd->mnt); error = PROC_I(inode)->op.proc_get_link(inode, &nd->dentry, &nd->mnt);
nd->last_type = LAST_BIND; nd->last_type = LAST_BIND;
out: out:
return error; return error;
...@@ -503,7 +509,7 @@ static int proc_pid_readlink(struct dentry * dentry, char * buffer, int buflen) ...@@ -503,7 +509,7 @@ static int proc_pid_readlink(struct dentry * dentry, char * buffer, int buflen)
if (error) if (error)
goto out; goto out;
error = inode->u.proc_i.op.proc_get_link(inode, &de, &mnt); error = PROC_I(inode)->op.proc_get_link(inode, &de, &mnt);
if (error) if (error)
goto out; goto out;
...@@ -570,7 +576,7 @@ static struct pid_entry base_stuff[] = { ...@@ -570,7 +576,7 @@ static struct pid_entry base_stuff[] = {
static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir)
{ {
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = filp->f_dentry->d_inode;
struct task_struct *p = inode->u.proc_i.task; struct task_struct *p = proc_task(inode);
unsigned int fd, pid, ino; unsigned int fd, pid, ino;
int retval; int retval;
char buf[NUMBUF]; char buf[NUMBUF];
...@@ -598,6 +604,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) ...@@ -598,6 +604,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir)
task_unlock(p); task_unlock(p);
if (!files) if (!files)
goto out; goto out;
read_lock(&files->file_lock);
for (fd = filp->f_pos-2; for (fd = filp->f_pos-2;
fd < files->max_fds; fd < files->max_fds;
fd++, filp->f_pos++) { fd++, filp->f_pos++) {
...@@ -605,6 +612,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) ...@@ -605,6 +612,7 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir)
if (!fcheck_files(files, fd)) if (!fcheck_files(files, fd))
continue; continue;
read_unlock(&files->file_lock);
j = NUMBUF; j = NUMBUF;
i = fd; i = fd;
...@@ -617,7 +625,9 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir) ...@@ -617,7 +625,9 @@ static int proc_readfd(struct file * filp, void * dirent, filldir_t filldir)
ino = fake_ino(pid, PROC_PID_FD_DIR + fd); ino = fake_ino(pid, PROC_PID_FD_DIR + fd);
if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0) if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0)
break; break;
read_lock(&files->file_lock);
} }
read_unlock(&files->file_lock);
put_files_struct(files); put_files_struct(files);
} }
out: out:
...@@ -632,7 +642,7 @@ static int proc_base_readdir(struct file * filp, ...@@ -632,7 +642,7 @@ static int proc_base_readdir(struct file * filp,
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = filp->f_dentry->d_inode;
struct pid_entry *p; struct pid_entry *p;
pid = inode->u.proc_i.task->pid; pid = proc_task(inode)->pid;
if (!pid) if (!pid)
return -ENOENT; return -ENOENT;
i = filp->f_pos; i = filp->f_pos;
...@@ -684,6 +694,7 @@ static int task_dumpable(struct task_struct *task) ...@@ -684,6 +694,7 @@ static int task_dumpable(struct task_struct *task)
static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *task, int ino) static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *task, int ino)
{ {
struct inode * inode; struct inode * inode;
struct proc_inode *ei;
/* We need a new inode */ /* We need a new inode */
...@@ -692,7 +703,9 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st ...@@ -692,7 +703,9 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
goto out; goto out;
/* Common stuff */ /* Common stuff */
ei = PROC_I(inode);
ei->task = NULL;
ei->file = NULL;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_ino = fake_ino(task->pid, ino); inode->i_ino = fake_ino(task->pid, ino);
...@@ -703,7 +716,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st ...@@ -703,7 +716,7 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
* grab the reference to task. * grab the reference to task.
*/ */
get_task_struct(task); get_task_struct(task);
inode->u.proc_i.task = task; ei->task = task;
inode->i_uid = 0; inode->i_uid = 0;
inode->i_gid = 0; inode->i_gid = 0;
if (ino == PROC_PID_INO || task_dumpable(task)) { if (ino == PROC_PID_INO || task_dumpable(task)) {
...@@ -733,7 +746,7 @@ static int pid_fd_revalidate(struct dentry * dentry, int flags) ...@@ -733,7 +746,7 @@ static int pid_fd_revalidate(struct dentry * dentry, int flags)
*/ */
static int pid_base_revalidate(struct dentry * dentry, int flags) static int pid_base_revalidate(struct dentry * dentry, int flags)
{ {
if (dentry->d_inode->u.proc_i.task->pid) if (proc_task(dentry->d_inode)->pid)
return 1; return 1;
d_drop(dentry); d_drop(dentry);
return 0; return 0;
...@@ -767,10 +780,11 @@ static struct dentry_operations pid_base_dentry_operations = ...@@ -767,10 +780,11 @@ static struct dentry_operations pid_base_dentry_operations =
static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry) static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry)
{ {
unsigned int fd, c; unsigned int fd, c;
struct task_struct *task = dir->u.proc_i.task; struct task_struct *task = proc_task(dir);
struct file * file; struct file * file;
struct files_struct * files; struct files_struct * files;
struct inode *inode; struct inode *inode;
struct proc_inode *ei;
const char *name; const char *name;
int len; int len;
...@@ -792,6 +806,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry) ...@@ -792,6 +806,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry)
inode = proc_pid_make_inode(dir->i_sb, task, PROC_PID_FD_DIR+fd); inode = proc_pid_make_inode(dir->i_sb, task, PROC_PID_FD_DIR+fd);
if (!inode) if (!inode)
goto out; goto out;
ei = PROC_I(inode);
task_lock(task); task_lock(task);
files = task->files; files = task->files;
if (files) if (files)
...@@ -800,7 +815,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry) ...@@ -800,7 +815,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry)
if (!files) if (!files)
goto out_unlock; goto out_unlock;
read_lock(&files->file_lock); read_lock(&files->file_lock);
file = inode->u.proc_i.file = fcheck_files(files, fd); file = ei->file = fcheck_files(files, fd);
if (!file) if (!file)
goto out_unlock2; goto out_unlock2;
get_file(file); get_file(file);
...@@ -809,7 +824,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry) ...@@ -809,7 +824,7 @@ static struct dentry *proc_lookupfd(struct inode * dir, struct dentry * dentry)
inode->i_op = &proc_pid_link_inode_operations; inode->i_op = &proc_pid_link_inode_operations;
inode->i_size = 64; inode->i_size = 64;
inode->i_mode = S_IFLNK; inode->i_mode = S_IFLNK;
inode->u.proc_i.op.proc_get_link = proc_fd_link; ei->op.proc_get_link = proc_fd_link;
if (file->f_mode & 1) if (file->f_mode & 1)
inode->i_mode |= S_IRUSR | S_IXUSR; inode->i_mode |= S_IRUSR | S_IXUSR;
if (file->f_mode & 2) if (file->f_mode & 2)
...@@ -844,8 +859,9 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry) ...@@ -844,8 +859,9 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
{ {
struct inode *inode; struct inode *inode;
int error; int error;
struct task_struct *task = dir->u.proc_i.task; struct task_struct *task = proc_task(dir);
struct pid_entry *p; struct pid_entry *p;
struct proc_inode *ei;
error = -ENOENT; error = -ENOENT;
inode = NULL; inode = NULL;
...@@ -864,6 +880,7 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry) ...@@ -864,6 +880,7 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
if (!inode) if (!inode)
goto out; goto out;
ei = PROC_I(inode);
inode->i_mode = p->mode; inode->i_mode = p->mode;
/* /*
* Yes, it does not scale. And it should not. Don't add * Yes, it does not scale. And it should not. Don't add
...@@ -877,35 +894,35 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry) ...@@ -877,35 +894,35 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
break; break;
case PROC_PID_EXE: case PROC_PID_EXE:
inode->i_op = &proc_pid_link_inode_operations; inode->i_op = &proc_pid_link_inode_operations;
inode->u.proc_i.op.proc_get_link = proc_exe_link; ei->op.proc_get_link = proc_exe_link;
break; break;
case PROC_PID_CWD: case PROC_PID_CWD:
inode->i_op = &proc_pid_link_inode_operations; inode->i_op = &proc_pid_link_inode_operations;
inode->u.proc_i.op.proc_get_link = proc_cwd_link; ei->op.proc_get_link = proc_cwd_link;
break; break;
case PROC_PID_ROOT: case PROC_PID_ROOT:
inode->i_op = &proc_pid_link_inode_operations; inode->i_op = &proc_pid_link_inode_operations;
inode->u.proc_i.op.proc_get_link = proc_root_link; ei->op.proc_get_link = proc_root_link;
break; break;
case PROC_PID_ENVIRON: case PROC_PID_ENVIRON:
inode->i_fop = &proc_info_file_operations; inode->i_fop = &proc_info_file_operations;
inode->u.proc_i.op.proc_read = proc_pid_environ; ei->op.proc_read = proc_pid_environ;
break; break;
case PROC_PID_STATUS: case PROC_PID_STATUS:
inode->i_fop = &proc_info_file_operations; inode->i_fop = &proc_info_file_operations;
inode->u.proc_i.op.proc_read = proc_pid_status; ei->op.proc_read = proc_pid_status;
break; break;
case PROC_PID_STAT: case PROC_PID_STAT:
inode->i_fop = &proc_info_file_operations; inode->i_fop = &proc_info_file_operations;
inode->u.proc_i.op.proc_read = proc_pid_stat; ei->op.proc_read = proc_pid_stat;
break; break;
case PROC_PID_CMDLINE: case PROC_PID_CMDLINE:
inode->i_fop = &proc_info_file_operations; inode->i_fop = &proc_info_file_operations;
inode->u.proc_i.op.proc_read = proc_pid_cmdline; ei->op.proc_read = proc_pid_cmdline;
break; break;
case PROC_PID_STATM: case PROC_PID_STATM:
inode->i_fop = &proc_info_file_operations; inode->i_fop = &proc_info_file_operations;
inode->u.proc_i.op.proc_read = proc_pid_statm; ei->op.proc_read = proc_pid_statm;
break; break;
case PROC_PID_MAPS: case PROC_PID_MAPS:
inode->i_fop = &proc_maps_operations; inode->i_fop = &proc_maps_operations;
...@@ -913,7 +930,7 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry) ...@@ -913,7 +930,7 @@ static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
case PROC_PID_CPU: case PROC_PID_CPU:
inode->i_fop = &proc_info_file_operations; inode->i_fop = &proc_info_file_operations;
inode->u.proc_i.op.proc_read = proc_pid_cpu; ei->op.proc_read = proc_pid_cpu;
break; break;
#endif #endif
case PROC_PID_MEM: case PROC_PID_MEM:
...@@ -973,6 +990,7 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry) ...@@ -973,6 +990,7 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry)
struct task_struct *task; struct task_struct *task;
const char *name; const char *name;
struct inode *inode; struct inode *inode;
struct proc_inode *ei;
int len; int len;
pid = 0; pid = 0;
...@@ -982,10 +1000,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry) ...@@ -982,10 +1000,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry)
inode = new_inode(dir->i_sb); inode = new_inode(dir->i_sb);
if (!inode) if (!inode)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ei = PROC_I(inode);
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_ino = fake_ino(0, PROC_PID_INO); inode->i_ino = fake_ino(0, PROC_PID_INO);
inode->u.proc_i.file = NULL; ei->file = NULL;
inode->u.proc_i.task = NULL; ei->task = NULL;
inode->i_mode = S_IFLNK|S_IRWXUGO; inode->i_mode = S_IFLNK|S_IRWXUGO;
inode->i_uid = inode->i_gid = 0; inode->i_uid = inode->i_gid = 0;
inode->i_size = 64; inode->i_size = 64;
...@@ -1035,10 +1054,10 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry) ...@@ -1035,10 +1054,10 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry)
void proc_pid_delete_inode(struct inode *inode) void proc_pid_delete_inode(struct inode *inode)
{ {
if (inode->u.proc_i.file) if (PROC_I(inode)->file)
fput(inode->u.proc_i.file); fput(PROC_I(inode)->file);
if (inode->u.proc_i.task) if (proc_task(inode))
free_task_struct(inode->u.proc_i.task); free_task_struct(proc_task(inode));
} }
#define PROC_NUMBUF 10 #define PROC_NUMBUF 10
......
...@@ -58,7 +58,7 @@ proc_file_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos) ...@@ -58,7 +58,7 @@ proc_file_read(struct file * file, char * buf, size_t nbytes, loff_t *ppos)
char *start; char *start;
struct proc_dir_entry * dp; struct proc_dir_entry * dp;
dp = (struct proc_dir_entry *) inode->u.generic_ip; dp = PDE(inode);
if (!(page = (char*) __get_free_page(GFP_KERNEL))) if (!(page = (char*) __get_free_page(GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
...@@ -128,7 +128,7 @@ proc_file_write(struct file * file, const char * buffer, ...@@ -128,7 +128,7 @@ proc_file_write(struct file * file, const char * buffer,
struct inode *inode = file->f_dentry->d_inode; struct inode *inode = file->f_dentry->d_inode;
struct proc_dir_entry * dp; struct proc_dir_entry * dp;
dp = (struct proc_dir_entry *) inode->u.generic_ip; dp = PDE(inode);
if (!dp->write_proc) if (!dp->write_proc)
return -EIO; return -EIO;
...@@ -221,13 +221,13 @@ static int make_inode_number(void) ...@@ -221,13 +221,13 @@ static int make_inode_number(void)
static int proc_readlink(struct dentry *dentry, char *buffer, int buflen) static int proc_readlink(struct dentry *dentry, char *buffer, int buflen)
{ {
char *s=((struct proc_dir_entry *)dentry->d_inode->u.generic_ip)->data; char *s=PDE(dentry->d_inode)->data;
return vfs_readlink(dentry, buffer, buflen, s); return vfs_readlink(dentry, buffer, buflen, s);
} }
static int proc_follow_link(struct dentry *dentry, struct nameidata *nd) static int proc_follow_link(struct dentry *dentry, struct nameidata *nd)
{ {
char *s=((struct proc_dir_entry *)dentry->d_inode->u.generic_ip)->data; char *s=PDE(dentry->d_inode)->data;
return vfs_follow_link(nd, s); return vfs_follow_link(nd, s);
} }
...@@ -264,7 +264,7 @@ struct dentry *proc_lookup(struct inode * dir, struct dentry *dentry) ...@@ -264,7 +264,7 @@ struct dentry *proc_lookup(struct inode * dir, struct dentry *dentry)
error = -ENOENT; error = -ENOENT;
inode = NULL; inode = NULL;
de = (struct proc_dir_entry *) dir->u.generic_ip; de = PDE(dir);
if (de) { if (de) {
for (de = de->subdir; de ; de = de->next) { for (de = de->subdir; de ; de = de->next) {
if (!de || !de->low_ino) if (!de || !de->low_ino)
...@@ -306,7 +306,7 @@ int proc_readdir(struct file * filp, ...@@ -306,7 +306,7 @@ int proc_readdir(struct file * filp,
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = filp->f_dentry->d_inode;
ino = inode->i_ino; ino = inode->i_ino;
de = (struct proc_dir_entry *) inode->u.generic_ip; de = PDE(inode);
if (!de) if (!de)
return -EINVAL; return -EINVAL;
i = filp->f_pos; i = filp->f_pos;
...@@ -413,7 +413,7 @@ static void proc_kill_inodes(struct proc_dir_entry *de) ...@@ -413,7 +413,7 @@ static void proc_kill_inodes(struct proc_dir_entry *de)
if (dentry->d_op != &proc_dentry_operations) if (dentry->d_op != &proc_dentry_operations)
continue; continue;
inode = dentry->d_inode; inode = dentry->d_inode;
if (inode->u.generic_ip != de) if (PDE(inode) != de)
continue; continue;
fops = filp->f_op; fops = filp->f_op;
filp->f_op = NULL; filp->f_op = NULL;
......
...@@ -58,7 +58,7 @@ void de_put(struct proc_dir_entry *de) ...@@ -58,7 +58,7 @@ void de_put(struct proc_dir_entry *de)
*/ */
static void proc_delete_inode(struct inode *inode) static void proc_delete_inode(struct inode *inode)
{ {
struct proc_dir_entry *de = inode->u.generic_ip; struct proc_dir_entry *de = PDE(inode);
inode->i_state = I_CLEAR; inode->i_state = I_CLEAR;
...@@ -91,14 +91,51 @@ static int proc_statfs(struct super_block *sb, struct statfs *buf) ...@@ -91,14 +91,51 @@ static int proc_statfs(struct super_block *sb, struct statfs *buf)
return 0; return 0;
} }
static kmem_cache_t * proc_inode_cachep;
static struct inode *proc_alloc_inode(struct super_block *sb)
{
struct proc_inode *ei;
ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, SLAB_KERNEL);
if (!ei)
return NULL;
return &ei->vfs_inode;
}
static void proc_destroy_inode(struct inode *inode)
{
kmem_cache_free(proc_inode_cachep, PROC_I(inode));
}
static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
{
struct proc_inode *ei = (struct proc_inode *) foo;
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR)
inode_init_once(&ei->vfs_inode);
}
int __init proc_init_inodecache(void)
{
proc_inode_cachep = kmem_cache_create("proc_inode_cache",
sizeof(struct proc_inode),
0, SLAB_HWCACHE_ALIGN,
init_once, NULL);
if (proc_inode_cachep == NULL)
return -ENOMEM;
return 0;
}
static struct super_operations proc_sops = { static struct super_operations proc_sops = {
alloc_inode: proc_alloc_inode,
destroy_inode: proc_destroy_inode,
read_inode: proc_read_inode, read_inode: proc_read_inode,
put_inode: force_delete, put_inode: force_delete,
delete_inode: proc_delete_inode, delete_inode: proc_delete_inode,
statfs: proc_statfs, statfs: proc_statfs,
}; };
static int parse_options(char *options,uid_t *uid,gid_t *gid) static int parse_options(char *options,uid_t *uid,gid_t *gid)
{ {
char *this_char,*value; char *this_char,*value;
...@@ -147,7 +184,7 @@ printk("proc_iget: using deleted entry %s, count=%d\n", de->name, atomic_read(&d ...@@ -147,7 +184,7 @@ printk("proc_iget: using deleted entry %s, count=%d\n", de->name, atomic_read(&d
if (!inode) if (!inode)
goto out_fail; goto out_fail;
inode->u.generic_ip = (void *) de; PROC_I(inode)->pde = de;
if (de) { if (de) {
if (de->mode) { if (de->mode) {
inode->i_mode = de->mode; inode->i_mode = de->mode;
......
...@@ -25,9 +25,13 @@ struct proc_dir_entry *proc_sys_root; ...@@ -25,9 +25,13 @@ struct proc_dir_entry *proc_sys_root;
static DECLARE_FSTYPE(proc_fs_type, "proc", proc_read_super, FS_SINGLE); static DECLARE_FSTYPE(proc_fs_type, "proc", proc_read_super, FS_SINGLE);
extern int __init proc_init_inodecache(void);
void __init proc_root_init(void) void __init proc_root_init(void)
{ {
int err = register_filesystem(&proc_fs_type); int err = proc_init_inodecache();
if (err)
return;
err = register_filesystem(&proc_fs_type);
if (err) if (err)
return; return;
proc_mnt = kern_mount(&proc_fs_type); proc_mnt = kern_mount(&proc_fs_type);
......
...@@ -289,7 +289,6 @@ extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long ...@@ -289,7 +289,6 @@ extern void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long
#include <linux/pipe_fs_i.h> #include <linux/pipe_fs_i.h>
/* #include <linux/umsdos_fs_i.h> */ /* #include <linux/umsdos_fs_i.h> */
#include <linux/romfs_fs_i.h> #include <linux/romfs_fs_i.h>
#include <linux/proc_fs_i.h>
#include <linux/cramfs_fs_sb.h> #include <linux/cramfs_fs_sb.h>
/* /*
...@@ -455,7 +454,6 @@ struct inode { ...@@ -455,7 +454,6 @@ struct inode {
union { union {
/* struct umsdos_inode_info umsdos_i; */ /* struct umsdos_inode_info umsdos_i; */
struct romfs_inode_info romfs_i; struct romfs_inode_info romfs_i;
struct proc_inode_info proc_i;
void *generic_ip; void *generic_ip;
} u; } u;
}; };
......
...@@ -205,4 +205,26 @@ extern struct proc_dir_entry proc_root; ...@@ -205,4 +205,26 @@ extern struct proc_dir_entry proc_root;
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
struct proc_inode {
struct task_struct *task;
int type;
union {
int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
int (*proc_read)(struct task_struct *task, char *page);
} op;
struct file *file;
struct proc_dir_entry *pde;
struct inode vfs_inode;
};
static inline struct proc_inode *PROC_I(struct inode *inode)
{
return list_entry(inode, struct proc_inode, vfs_inode);
}
static inline struct proc_dir_entry *PDE(struct inode *inode)
{
return PROC_I(inode)->pde;
}
#endif /* _LINUX_PROC_FS_H */ #endif /* _LINUX_PROC_FS_H */
...@@ -677,7 +677,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char * buf, ...@@ -677,7 +677,7 @@ static ssize_t do_rw_proc(int write, struct file * file, char * buf,
size_t res; size_t res;
ssize_t error; ssize_t error;
de = (struct proc_dir_entry*) file->f_dentry->d_inode->u.generic_ip; de = PDE(file->f_dentry->d_inode);
if (!de || !de->data) if (!de || !de->data)
return -ENOTDIR; return -ENOTDIR;
table = (struct ctl_table *) de->data; table = (struct ctl_table *) de->data;
......
...@@ -236,7 +236,7 @@ static ssize_t vlan_proc_read(struct file *file, char *buf, ...@@ -236,7 +236,7 @@ static ssize_t vlan_proc_read(struct file *file, char *buf,
if (count <= 0) if (count <= 0)
return 0; return 0;
dent = inode->u.generic_ip; dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL)) if ((dent == NULL) || (dent->get_info == NULL))
return 0; return 0;
......
...@@ -498,8 +498,7 @@ static ssize_t proc_dev_atm_read(struct file *file,char *buf,size_t count, ...@@ -498,8 +498,7 @@ static ssize_t proc_dev_atm_read(struct file *file,char *buf,size_t count,
if (count == 0) return 0; if (count == 0) return 0;
page = get_free_page(GFP_KERNEL); page = get_free_page(GFP_KERNEL);
if (!page) return -ENOMEM; if (!page) return -ENOMEM;
dev = ((struct proc_dir_entry *) file->f_dentry->d_inode->u.generic_ip) dev = PDE(file->f_dentry->d_inode)->data;
->data;
if (!dev->ops->proc_read) if (!dev->ops->proc_read)
length = -EINVAL; length = -EINVAL;
else { else {
...@@ -521,8 +520,7 @@ static ssize_t proc_spec_atm_read(struct file *file,char *buf,size_t count, ...@@ -521,8 +520,7 @@ static ssize_t proc_spec_atm_read(struct file *file,char *buf,size_t count,
unsigned long page; unsigned long page;
int length; int length;
int (*info)(loff_t,char *); int (*info)(loff_t,char *);
info = ((struct proc_dir_entry *) file->f_dentry->d_inode->u.generic_ip) info = PDE(file->f_dentry->d_inode)->data;
->data;
if (count == 0) return 0; if (count == 0) return 0;
page = get_free_page(GFP_KERNEL); page = get_free_page(GFP_KERNEL);
......
...@@ -500,7 +500,7 @@ int wanrouter_ioctl(struct inode *inode, struct file *file, ...@@ -500,7 +500,7 @@ int wanrouter_ioctl(struct inode *inode, struct file *file,
if ((cmd >> 8) != ROUTER_IOCTL) if ((cmd >> 8) != ROUTER_IOCTL)
return -EINVAL; return -EINVAL;
dent = inode->u.generic_ip; dent = PDE(inode);
if ((dent == NULL) || (dent->data == NULL)) if ((dent == NULL) || (dent->data == NULL))
return -EINVAL; return -EINVAL;
......
...@@ -248,7 +248,7 @@ typedef struct wan_stat_entry ...@@ -248,7 +248,7 @@ typedef struct wan_stat_entry
if (count <= 0) if (count <= 0)
return 0; return 0;
dent = inode->u.generic_ip; dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL)) if ((dent == NULL) || (dent->get_info == NULL))
return 0; return 0;
...@@ -794,7 +794,7 @@ typedef struct wan_stat_entry ...@@ -794,7 +794,7 @@ typedef struct wan_stat_entry
if (count <= 0) if (count <= 0)
return 0; return 0;
dent = inode->u.generic_ip; dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL)) if ((dent == NULL) || (dent->get_info == NULL))
return 0; return 0;
...@@ -828,7 +828,7 @@ typedef struct wan_stat_entry ...@@ -828,7 +828,7 @@ typedef struct wan_stat_entry
if (count <= 0) if (count <= 0)
return 0; return 0;
dent = inode->u.generic_ip; dent = PDE(inode);
if ((dent == NULL) || (dent->get_info == NULL)) if ((dent == NULL) || (dent->get_info == NULL))
return -ENODATA; return -ENODATA;
err = verify_area(VERIFY_WRITE, buf, count); err = verify_area(VERIFY_WRITE, buf, count);
...@@ -1068,7 +1068,7 @@ static int device_write( ...@@ -1068,7 +1068,7 @@ static int device_write(
if (err) return err; if (err) return err;
dent = inode->u.generic_ip; dent = PDE(inode);
if ((dent == NULL) || (dent->data == NULL)) if ((dent == NULL) || (dent->data == NULL))
return -ENODATA; return -ENODATA;
......
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