diff options
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r-- | fs/proc/generic.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index b638fb500743..72b431d0a0a4 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -54,6 +54,18 @@ proc_file_read(struct file *file, char __user *buf, size_t nbytes, | |||
54 | ssize_t n, count; | 54 | ssize_t n, count; |
55 | char *start; | 55 | char *start; |
56 | struct proc_dir_entry * dp; | 56 | struct proc_dir_entry * dp; |
57 | unsigned long long pos; | ||
58 | |||
59 | /* | ||
60 | * Gaah, please just use "seq_file" instead. The legacy /proc | ||
61 | * interfaces cut loff_t down to off_t for reads, and ignore | ||
62 | * the offset entirely for writes.. | ||
63 | */ | ||
64 | pos = *ppos; | ||
65 | if (pos > MAX_NON_LFS) | ||
66 | return 0; | ||
67 | if (nbytes > MAX_NON_LFS - pos) | ||
68 | nbytes = MAX_NON_LFS - pos; | ||
57 | 69 | ||
58 | dp = PDE(inode); | 70 | dp = PDE(inode); |
59 | if (!(page = (char*) __get_free_page(GFP_KERNEL))) | 71 | if (!(page = (char*) __get_free_page(GFP_KERNEL))) |
@@ -202,30 +214,17 @@ proc_file_write(struct file *file, const char __user *buffer, | |||
202 | static loff_t | 214 | static loff_t |
203 | proc_file_lseek(struct file *file, loff_t offset, int orig) | 215 | proc_file_lseek(struct file *file, loff_t offset, int orig) |
204 | { | 216 | { |
205 | lock_kernel(); | 217 | loff_t retval = -EINVAL; |
206 | 218 | switch (orig) { | |
207 | switch (orig) { | 219 | case 1: |
208 | case 0: | 220 | offset += file->f_pos; |
209 | if (offset < 0) | 221 | /* fallthrough */ |
210 | goto out; | 222 | case 0: |
211 | file->f_pos = offset; | 223 | if (offset < 0 || offset > MAX_NON_LFS) |
212 | unlock_kernel(); | 224 | break; |
213 | return(file->f_pos); | 225 | file->f_pos = retval = offset; |
214 | case 1: | 226 | } |
215 | if (offset + file->f_pos < 0) | 227 | return retval; |
216 | goto out; | ||
217 | file->f_pos += offset; | ||
218 | unlock_kernel(); | ||
219 | return(file->f_pos); | ||
220 | case 2: | ||
221 | goto out; | ||
222 | default: | ||
223 | goto out; | ||
224 | } | ||
225 | |||
226 | out: | ||
227 | unlock_kernel(); | ||
228 | return -EINVAL; | ||
229 | } | 228 | } |
230 | 229 | ||
231 | static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) | 230 | static int proc_notify_change(struct dentry *dentry, struct iattr *iattr) |