summaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 23:16:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 23:16:07 -0500
commitd895cb1af15c04c522a25c79cc429076987c089b (patch)
tree895dc9157e28f603d937a58be664e4e440d5530c /fs/proc/generic.c
parent9626357371b519f2b955fef399647181034a77fe (diff)
parentd3d009cb965eae7e002ea5badf603ea8f4c34915 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile (part one) from Al Viro: "Assorted stuff - cleaning namei.c up a bit, fixing ->d_name/->d_parent locking violations, etc. The most visible changes here are death of FS_REVAL_DOT (replaced with "has ->d_weak_revalidate()") and a new helper getting from struct file to inode. Some bits of preparation to xattr method interface changes. Misc patches by various people sent this cycle *and* ocfs2 fixes from several cycles ago that should've been upstream right then. PS: the next vfs pile will be xattr stuff." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits) saner proc_get_inode() calling conventions proc: avoid extra pde_put() in proc_fill_super() fs: change return values from -EACCES to -EPERM fs/exec.c: make bprm_mm_init() static ocfs2/dlm: use GFP_ATOMIC inside a spin_lock ocfs2: fix possible use-after-free with AIO ocfs2: Fix oops in ocfs2_fast_symlink_readpage() code path get_empty_filp()/alloc_file() leave both ->f_pos and ->f_version zero target: writev() on single-element vector is pointless export kernel_write(), convert open-coded instances fs: encode_fh: return FILEID_INVALID if invalid fid_type kill f_vfsmnt vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op nfsd: handle vfs_getattr errors in acl protocol switch vfs_getattr() to struct path default SET_PERSONALITY() in linux/elf.h ceph: prepopulate inodes only when request is aborted d_hash_and_lookup(): export, switch open-coded instances 9p: switch v9fs_set_create_acl() to inode+fid, do it before d_instantiate() 9p: split dropping the acls from v9fs_set_create_acl() ...
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}