aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/file.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/fs/file.c b/fs/file.c
index d34e59e51743..4ed58a32575e 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -637,16 +637,16 @@ void do_close_on_exec(struct files_struct *files)
637 spin_unlock(&files->file_lock); 637 spin_unlock(&files->file_lock);
638} 638}
639 639
640struct file *fget(unsigned int fd) 640static struct file *__fget(unsigned int fd, fmode_t mask)
641{ 641{
642 struct file *file;
643 struct files_struct *files = current->files; 642 struct files_struct *files = current->files;
643 struct file *file;
644 644
645 rcu_read_lock(); 645 rcu_read_lock();
646 file = fcheck_files(files, fd); 646 file = fcheck_files(files, fd);
647 if (file) { 647 if (file) {
648 /* File object ref couldn't be taken */ 648 /* File object ref couldn't be taken */
649 if (file->f_mode & FMODE_PATH || 649 if ((file->f_mode & mask) ||
650 !atomic_long_inc_not_zero(&file->f_count)) 650 !atomic_long_inc_not_zero(&file->f_count))
651 file = NULL; 651 file = NULL;
652 } 652 }
@@ -655,25 +655,16 @@ struct file *fget(unsigned int fd)
655 return file; 655 return file;
656} 656}
657 657
658struct file *fget(unsigned int fd)
659{
660 return __fget(fd, FMODE_PATH);
661}
658EXPORT_SYMBOL(fget); 662EXPORT_SYMBOL(fget);
659 663
660struct file *fget_raw(unsigned int fd) 664struct file *fget_raw(unsigned int fd)
661{ 665{
662 struct file *file; 666 return __fget(fd, 0);
663 struct files_struct *files = current->files;
664
665 rcu_read_lock();
666 file = fcheck_files(files, fd);
667 if (file) {
668 /* File object ref couldn't be taken */
669 if (!atomic_long_inc_not_zero(&file->f_count))
670 file = NULL;
671 }
672 rcu_read_unlock();
673
674 return file;
675} 667}
676
677EXPORT_SYMBOL(fget_raw); 668EXPORT_SYMBOL(fget_raw);
678 669
679/* 670/*