diff options
Diffstat (limited to 'fs/proc/inode.c')
-rw-r--r-- | fs/proc/inode.c | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 439ae6886507..70322e1a4f0f 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -144,7 +144,7 @@ void pde_users_dec(struct proc_dir_entry *pde) | |||
144 | 144 | ||
145 | static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence) | 145 | static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence) |
146 | { | 146 | { |
147 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 147 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
148 | loff_t rv = -EINVAL; | 148 | loff_t rv = -EINVAL; |
149 | loff_t (*llseek)(struct file *, loff_t, int); | 149 | loff_t (*llseek)(struct file *, loff_t, int); |
150 | 150 | ||
@@ -179,7 +179,7 @@ static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence) | |||
179 | 179 | ||
180 | static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | 180 | static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) |
181 | { | 181 | { |
182 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 182 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
183 | ssize_t rv = -EIO; | 183 | ssize_t rv = -EIO; |
184 | ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); | 184 | ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); |
185 | 185 | ||
@@ -201,7 +201,7 @@ static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, | |||
201 | 201 | ||
202 | static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 202 | static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) |
203 | { | 203 | { |
204 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 204 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
205 | ssize_t rv = -EIO; | 205 | ssize_t rv = -EIO; |
206 | ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); | 206 | ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); |
207 | 207 | ||
@@ -223,7 +223,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t | |||
223 | 223 | ||
224 | static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts) | 224 | static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts) |
225 | { | 225 | { |
226 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 226 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
227 | unsigned int rv = DEFAULT_POLLMASK; | 227 | unsigned int rv = DEFAULT_POLLMASK; |
228 | unsigned int (*poll)(struct file *, struct poll_table_struct *); | 228 | unsigned int (*poll)(struct file *, struct poll_table_struct *); |
229 | 229 | ||
@@ -245,7 +245,7 @@ static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *p | |||
245 | 245 | ||
246 | static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 246 | static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
247 | { | 247 | { |
248 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 248 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
249 | long rv = -ENOTTY; | 249 | long rv = -ENOTTY; |
250 | long (*ioctl)(struct file *, unsigned int, unsigned long); | 250 | long (*ioctl)(struct file *, unsigned int, unsigned long); |
251 | 251 | ||
@@ -268,7 +268,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne | |||
268 | #ifdef CONFIG_COMPAT | 268 | #ifdef CONFIG_COMPAT |
269 | static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 269 | static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
270 | { | 270 | { |
271 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 271 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
272 | long rv = -ENOTTY; | 272 | long rv = -ENOTTY; |
273 | long (*compat_ioctl)(struct file *, unsigned int, unsigned long); | 273 | long (*compat_ioctl)(struct file *, unsigned int, unsigned long); |
274 | 274 | ||
@@ -291,7 +291,7 @@ static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned | |||
291 | 291 | ||
292 | static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma) | 292 | static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma) |
293 | { | 293 | { |
294 | struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); | 294 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
295 | int rv = -EIO; | 295 | int rv = -EIO; |
296 | int (*mmap)(struct file *, struct vm_area_struct *); | 296 | int (*mmap)(struct file *, struct vm_area_struct *); |
297 | 297 | ||
@@ -445,12 +445,9 @@ static const struct file_operations proc_reg_file_ops_no_compat = { | |||
445 | 445 | ||
446 | struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) | 446 | struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) |
447 | { | 447 | { |
448 | struct inode * inode; | 448 | struct inode *inode = iget_locked(sb, de->low_ino); |
449 | 449 | ||
450 | inode = iget_locked(sb, de->low_ino); | 450 | if (inode && (inode->i_state & I_NEW)) { |
451 | if (!inode) | ||
452 | return NULL; | ||
453 | if (inode->i_state & I_NEW) { | ||
454 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; | 451 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; |
455 | PROC_I(inode)->pde = de; | 452 | PROC_I(inode)->pde = de; |
456 | 453 | ||
@@ -482,10 +479,12 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) | |||
482 | } else | 479 | } else |
483 | pde_put(de); | 480 | pde_put(de); |
484 | return inode; | 481 | return inode; |
485 | } | 482 | } |
486 | 483 | ||
487 | int proc_fill_super(struct super_block *s) | 484 | int proc_fill_super(struct super_block *s) |
488 | { | 485 | { |
486 | struct inode *root_inode; | ||
487 | |||
489 | s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC; | 488 | s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC; |
490 | s->s_blocksize = 1024; | 489 | s->s_blocksize = 1024; |
491 | s->s_blocksize_bits = 10; | 490 | s->s_blocksize_bits = 10; |
@@ -494,11 +493,17 @@ int proc_fill_super(struct super_block *s) | |||
494 | s->s_time_gran = 1; | 493 | s->s_time_gran = 1; |
495 | 494 | ||
496 | pde_get(&proc_root); | 495 | pde_get(&proc_root); |
497 | s->s_root = d_make_root(proc_get_inode(s, &proc_root)); | 496 | root_inode = proc_get_inode(s, &proc_root); |
498 | if (s->s_root) | 497 | if (!root_inode) { |
499 | return 0; | 498 | printk(KERN_ERR "proc_fill_super: get root inode failed\n"); |
499 | return -ENOMEM; | ||
500 | } | ||
500 | 501 | ||
501 | printk("proc_read_super: get root inode failed\n"); | 502 | s->s_root = d_make_root(root_inode); |
502 | pde_put(&proc_root); | 503 | if (!s->s_root) { |
503 | return -ENOMEM; | 504 | printk(KERN_ERR "proc_fill_super: allocate dentry failed\n"); |
505 | return -ENOMEM; | ||
506 | } | ||
507 | |||
508 | return 0; | ||
504 | } | 509 | } |