Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139016
b: refs/heads/master
c: 3dec7f5
h: refs/heads/master
v: v3
  • Loading branch information
Alexey Dobriyan committed Mar 30, 2009
1 parent d0e16cc commit 97ee2f7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 09729a9919fdaf137995b0f19cbd401e22229cac
refs/heads/master: 3dec7f59c370c7b58184d63293c3dc984d475840
48 changes: 38 additions & 10 deletions trunk/fs/proc/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int proc_match(int len, const char *name, struct proc_dir_entry *de)
#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)

static ssize_t
proc_file_read(struct file *file, char __user *buf, size_t nbytes,
__proc_file_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{
struct inode * inode = file->f_path.dentry->d_inode;
Expand Down Expand Up @@ -182,20 +182,48 @@ proc_file_read(struct file *file, char __user *buf, size_t nbytes,
return retval;
}

static ssize_t
proc_file_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
ssize_t rv = -EIO;

spin_lock(&pde->pde_unload_lock);
if (!pde->proc_fops) {
spin_unlock(&pde->pde_unload_lock);
return rv;
}
pde->pde_users++;
spin_unlock(&pde->pde_unload_lock);

rv = __proc_file_read(file, buf, nbytes, ppos);

pde_users_dec(pde);
return rv;
}

static ssize_t
proc_file_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
struct inode *inode = file->f_path.dentry->d_inode;
struct proc_dir_entry * dp;

dp = PDE(inode);

if (!dp->write_proc)
return -EIO;
struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode);
ssize_t rv = -EIO;

if (pde->write_proc) {
spin_lock(&pde->pde_unload_lock);
if (!pde->proc_fops) {
spin_unlock(&pde->pde_unload_lock);
return rv;
}
pde->pde_users++;
spin_unlock(&pde->pde_unload_lock);

/* FIXME: does this routine need ppos? probably... */
return dp->write_proc(file, buffer, count, dp->data);
/* FIXME: does this routine need ppos? probably... */
rv = pde->write_proc(file, buffer, count, pde->data);
pde_users_dec(pde);
}
return rv;
}


Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/proc/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static void __pde_users_dec(struct proc_dir_entry *pde)
complete(pde->pde_unload_completion);
}

static void pde_users_dec(struct proc_dir_entry *pde)
void pde_users_dec(struct proc_dir_entry *pde)
{
spin_lock(&pde->pde_unload_lock);
__pde_users_dec(pde);
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/proc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ struct pde_opener {
int (*release)(struct inode *, struct file *);
struct list_head lh;
};
void pde_users_dec(struct proc_dir_entry *pde);

0 comments on commit 97ee2f7

Please sign in to comment.