diff options
Diffstat (limited to 'fs/read_write.c')
-rw-r--r-- | fs/read_write.c | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index f0d1240a5c69..9ba495d5a29b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -31,12 +31,12 @@ const struct file_operations generic_ro_fops = { | |||
31 | 31 | ||
32 | EXPORT_SYMBOL(generic_ro_fops); | 32 | EXPORT_SYMBOL(generic_ro_fops); |
33 | 33 | ||
34 | loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) | 34 | loff_t |
35 | generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin) | ||
35 | { | 36 | { |
36 | loff_t retval; | 37 | loff_t retval; |
37 | struct inode *inode = file->f_mapping->host; | 38 | struct inode *inode = file->f_mapping->host; |
38 | 39 | ||
39 | mutex_lock(&inode->i_mutex); | ||
40 | switch (origin) { | 40 | switch (origin) { |
41 | case SEEK_END: | 41 | case SEEK_END: |
42 | offset += inode->i_size; | 42 | offset += inode->i_size; |
@@ -46,42 +46,26 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) | |||
46 | } | 46 | } |
47 | retval = -EINVAL; | 47 | retval = -EINVAL; |
48 | if (offset>=0 && offset<=inode->i_sb->s_maxbytes) { | 48 | if (offset>=0 && offset<=inode->i_sb->s_maxbytes) { |
49 | /* Special lock needed here? */ | ||
49 | if (offset != file->f_pos) { | 50 | if (offset != file->f_pos) { |
50 | file->f_pos = offset; | 51 | file->f_pos = offset; |
51 | file->f_version = 0; | 52 | file->f_version = 0; |
52 | } | 53 | } |
53 | retval = offset; | 54 | retval = offset; |
54 | } | 55 | } |
55 | mutex_unlock(&inode->i_mutex); | ||
56 | return retval; | 56 | return retval; |
57 | } | 57 | } |
58 | EXPORT_SYMBOL(generic_file_llseek_unlocked); | ||
58 | 59 | ||
59 | EXPORT_SYMBOL(generic_file_llseek); | 60 | loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) |
60 | |||
61 | loff_t remote_llseek(struct file *file, loff_t offset, int origin) | ||
62 | { | 61 | { |
63 | loff_t retval; | 62 | loff_t n; |
64 | 63 | mutex_lock(&file->f_dentry->d_inode->i_mutex); | |
65 | lock_kernel(); | 64 | n = generic_file_llseek_unlocked(file, offset, origin); |
66 | switch (origin) { | 65 | mutex_unlock(&file->f_dentry->d_inode->i_mutex); |
67 | case SEEK_END: | 66 | return n; |
68 | offset += i_size_read(file->f_path.dentry->d_inode); | ||
69 | break; | ||
70 | case SEEK_CUR: | ||
71 | offset += file->f_pos; | ||
72 | } | ||
73 | retval = -EINVAL; | ||
74 | if (offset>=0 && offset<=file->f_path.dentry->d_inode->i_sb->s_maxbytes) { | ||
75 | if (offset != file->f_pos) { | ||
76 | file->f_pos = offset; | ||
77 | file->f_version = 0; | ||
78 | } | ||
79 | retval = offset; | ||
80 | } | ||
81 | unlock_kernel(); | ||
82 | return retval; | ||
83 | } | 67 | } |
84 | EXPORT_SYMBOL(remote_llseek); | 68 | EXPORT_SYMBOL(generic_file_llseek); |
85 | 69 | ||
86 | loff_t no_llseek(struct file *file, loff_t offset, int origin) | 70 | loff_t no_llseek(struct file *file, loff_t offset, int origin) |
87 | { | 71 | { |