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;
......
This diff is collapsed.
...@@ -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