@@ -419,17 +419,6 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo
419
419
return ret ;
420
420
}
421
421
422
- ssize_t __vfs_read (struct file * file , char __user * buf , size_t count ,
423
- loff_t * pos )
424
- {
425
- if (file -> f_op -> read )
426
- return file -> f_op -> read (file , buf , count , pos );
427
- else if (file -> f_op -> read_iter )
428
- return new_sync_read (file , buf , count , pos );
429
- else
430
- return - EINVAL ;
431
- }
432
-
433
422
ssize_t __kernel_read (struct file * file , void * buf , size_t count , loff_t * pos )
434
423
{
435
424
mm_segment_t old_fs = get_fs ();
@@ -443,7 +432,12 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
443
432
if (count > MAX_RW_COUNT )
444
433
count = MAX_RW_COUNT ;
445
434
set_fs (KERNEL_DS );
446
- ret = __vfs_read (file , (void __user * )buf , count , pos );
435
+ if (file -> f_op -> read )
436
+ ret = file -> f_op -> read (file , (void __user * )buf , count , pos );
437
+ else if (file -> f_op -> read_iter )
438
+ ret = new_sync_read (file , (void __user * )buf , count , pos );
439
+ else
440
+ ret = - EINVAL ;
447
441
set_fs (old_fs );
448
442
if (ret > 0 ) {
449
443
fsnotify_access (file );
@@ -476,17 +470,22 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
476
470
return - EFAULT ;
477
471
478
472
ret = rw_verify_area (READ , file , pos , count );
479
- if (!ret ) {
480
- if (count > MAX_RW_COUNT )
481
- count = MAX_RW_COUNT ;
482
- ret = __vfs_read (file , buf , count , pos );
483
- if (ret > 0 ) {
484
- fsnotify_access (file );
485
- add_rchar (current , ret );
486
- }
487
- inc_syscr (current );
488
- }
473
+ if (ret )
474
+ return ret ;
475
+ if (count > MAX_RW_COUNT )
476
+ count = MAX_RW_COUNT ;
489
477
478
+ if (file -> f_op -> read )
479
+ ret = file -> f_op -> read (file , buf , count , pos );
480
+ else if (file -> f_op -> read_iter )
481
+ ret = new_sync_read (file , buf , count , pos );
482
+ else
483
+ ret = - EINVAL ;
484
+ if (ret > 0 ) {
485
+ fsnotify_access (file );
486
+ add_rchar (current , ret );
487
+ }
488
+ inc_syscr (current );
490
489
return ret ;
491
490
}
492
491
0 commit comments