aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 76ddae83daa5..2983dc52ca25 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -42,7 +42,7 @@ static ssize_t
42__proc_file_read(struct file *file, char __user *buf, size_t nbytes, 42__proc_file_read(struct file *file, char __user *buf, size_t nbytes,
43 loff_t *ppos) 43 loff_t *ppos)
44{ 44{
45 struct inode * inode = file->f_path.dentry->d_inode; 45 struct inode * inode = file_inode(file);
46 char *page; 46 char *page;
47 ssize_t retval=0; 47 ssize_t retval=0;
48 int eof=0; 48 int eof=0;
@@ -188,7 +188,7 @@ static ssize_t
188proc_file_read(struct file *file, char __user *buf, size_t nbytes, 188proc_file_read(struct file *file, char __user *buf, size_t nbytes,
189 loff_t *ppos) 189 loff_t *ppos)
190{ 190{
191 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 191 struct proc_dir_entry *pde = PDE(file_inode(file));
192 ssize_t rv = -EIO; 192 ssize_t rv = -EIO;
193 193
194 spin_lock(&pde->pde_unload_lock); 194 spin_lock(&pde->pde_unload_lock);
@@ -209,7 +209,7 @@ static ssize_t
209proc_file_write(struct file *file, const char __user *buffer, 209proc_file_write(struct file *file, const char __user *buffer,
210 size_t count, loff_t *ppos) 210 size_t count, loff_t *ppos)
211{ 211{
212 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 212 struct proc_dir_entry *pde = PDE(file_inode(file));
213 ssize_t rv = -EIO; 213 ssize_t rv = -EIO;
214 214
215 if (pde->write_proc) { 215 if (pde->write_proc) {
@@ -412,8 +412,7 @@ static const struct dentry_operations proc_dentry_operations =
412struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, 412struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
413 struct dentry *dentry) 413 struct dentry *dentry)
414{ 414{
415 struct inode *inode = NULL; 415 struct inode *inode;
416 int error = -ENOENT;
417 416
418 spin_lock(&proc_subdir_lock); 417 spin_lock(&proc_subdir_lock);
419 for (de = de->subdir; de ; de = de->next) { 418 for (de = de->subdir; de ; de = de->next) {
@@ -422,22 +421,16 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
422 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { 421 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
423 pde_get(de); 422 pde_get(de);
424 spin_unlock(&proc_subdir_lock); 423 spin_unlock(&proc_subdir_lock);
425 error = -ENOMEM;
426 inode = proc_get_inode(dir->i_sb, de); 424 inode = proc_get_inode(dir->i_sb, de);
427 goto out_unlock; 425 if (!inode)
426 return ERR_PTR(-ENOMEM);
427 d_set_d_op(dentry, &proc_dentry_operations);
428 d_add(dentry, inode);
429 return NULL;
428 } 430 }
429 } 431 }
430 spin_unlock(&proc_subdir_lock); 432 spin_unlock(&proc_subdir_lock);
431out_unlock: 433 return ERR_PTR(-ENOENT);
432
433 if (inode) {
434 d_set_d_op(dentry, &proc_dentry_operations);
435 d_add(dentry, inode);
436 return NULL;
437 }
438 if (de)
439 pde_put(de);
440 return ERR_PTR(error);
441} 434}
442 435
443struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry, 436struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
@@ -460,7 +453,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
460{ 453{
461 unsigned int ino; 454 unsigned int ino;
462 int i; 455 int i;
463 struct inode *inode = filp->f_path.dentry->d_inode; 456 struct inode *inode = file_inode(filp);
464 int ret = 0; 457 int ret = 0;
465 458
466 ino = inode->i_ino; 459 ino = inode->i_ino;
@@ -522,7 +515,7 @@ out:
522 515
523int proc_readdir(struct file *filp, void *dirent, filldir_t filldir) 516int proc_readdir(struct file *filp, void *dirent, filldir_t filldir)
524{ 517{
525 struct inode *inode = filp->f_path.dentry->d_inode; 518 struct inode *inode = file_inode(filp);
526 519
527 return proc_readdir_de(PDE(inode), filp, dirent, filldir); 520 return proc_readdir_de(PDE(inode), filp, dirent, filldir);
528} 521}