@@ -222,6 +222,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
222
222
CLASS (fd_pos , f )(fd );
223
223
struct readdir_callback buf = {
224
224
.ctx .actor = fillonedir ,
225
+ .ctx .count = 1 , /* Hint to fs: just one entry. */
225
226
.dirent = dirent
226
227
};
227
228
@@ -252,7 +253,6 @@ struct getdents_callback {
252
253
struct dir_context ctx ;
253
254
struct linux_dirent __user * current_dir ;
254
255
int prev_reclen ;
255
- int count ;
256
256
int error ;
257
257
};
258
258
@@ -275,7 +275,7 @@ static bool filldir(struct dir_context *ctx, const char *name, int namlen,
275
275
if (unlikely (buf -> error ))
276
276
return false;
277
277
buf -> error = - EINVAL ; /* only used if we fail.. */
278
- if (reclen > buf -> count )
278
+ if (reclen > ctx -> count )
279
279
return false;
280
280
d_ino = ino ;
281
281
if (sizeof (d_ino ) < sizeof (ino ) && d_ino != ino ) {
@@ -300,7 +300,7 @@ static bool filldir(struct dir_context *ctx, const char *name, int namlen,
300
300
301
301
buf -> current_dir = (void __user * )dirent + reclen ;
302
302
buf -> prev_reclen = reclen ;
303
- buf -> count -= reclen ;
303
+ ctx -> count -= reclen ;
304
304
return true;
305
305
efault_end :
306
306
user_write_access_end ();
@@ -315,7 +315,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
315
315
CLASS (fd_pos , f )(fd );
316
316
struct getdents_callback buf = {
317
317
.ctx .actor = filldir ,
318
- .count = count ,
318
+ .ctx . count = count ,
319
319
.current_dir = dirent
320
320
};
321
321
int error ;
@@ -333,7 +333,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
333
333
if (put_user (buf .ctx .pos , & lastdirent -> d_off ))
334
334
error = - EFAULT ;
335
335
else
336
- error = count - buf .count ;
336
+ error = count - buf .ctx . count ;
337
337
}
338
338
return error ;
339
339
}
@@ -342,7 +342,6 @@ struct getdents_callback64 {
342
342
struct dir_context ctx ;
343
343
struct linux_dirent64 __user * current_dir ;
344
344
int prev_reclen ;
345
- int count ;
346
345
int error ;
347
346
};
348
347
@@ -364,7 +363,7 @@ static bool filldir64(struct dir_context *ctx, const char *name, int namlen,
364
363
if (unlikely (buf -> error ))
365
364
return false;
366
365
buf -> error = - EINVAL ; /* only used if we fail.. */
367
- if (reclen > buf -> count )
366
+ if (reclen > ctx -> count )
368
367
return false;
369
368
prev_reclen = buf -> prev_reclen ;
370
369
if (!(flags & FILLDIR_FLAG_NOINTR ) && prev_reclen && signal_pending (current ))
@@ -384,7 +383,7 @@ static bool filldir64(struct dir_context *ctx, const char *name, int namlen,
384
383
385
384
buf -> prev_reclen = reclen ;
386
385
buf -> current_dir = (void __user * )dirent + reclen ;
387
- buf -> count -= reclen ;
386
+ ctx -> count -= reclen ;
388
387
return true;
389
388
390
389
efault_end :
@@ -400,7 +399,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
400
399
CLASS (fd_pos , f )(fd );
401
400
struct getdents_callback64 buf = {
402
401
.ctx .actor = filldir64 ,
403
- .count = count ,
402
+ .ctx . count = count ,
404
403
.current_dir = dirent
405
404
};
406
405
int error ;
@@ -419,7 +418,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
419
418
if (put_user (d_off , & lastdirent -> d_off ))
420
419
error = - EFAULT ;
421
420
else
422
- error = count - buf .count ;
421
+ error = count - buf .ctx . count ;
423
422
}
424
423
return error ;
425
424
}
@@ -483,6 +482,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
483
482
CLASS (fd_pos , f )(fd );
484
483
struct compat_readdir_callback buf = {
485
484
.ctx .actor = compat_fillonedir ,
485
+ .ctx .count = 1 , /* Hint to fs: just one entry. */
486
486
.dirent = dirent
487
487
};
488
488
@@ -507,7 +507,6 @@ struct compat_getdents_callback {
507
507
struct dir_context ctx ;
508
508
struct compat_linux_dirent __user * current_dir ;
509
509
int prev_reclen ;
510
- int count ;
511
510
int error ;
512
511
};
513
512
@@ -530,7 +529,7 @@ static bool compat_filldir(struct dir_context *ctx, const char *name, int namlen
530
529
if (unlikely (buf -> error ))
531
530
return false;
532
531
buf -> error = - EINVAL ; /* only used if we fail.. */
533
- if (reclen > buf -> count )
532
+ if (reclen > ctx -> count )
534
533
return false;
535
534
d_ino = ino ;
536
535
if (sizeof (d_ino ) < sizeof (ino ) && d_ino != ino ) {
@@ -554,7 +553,7 @@ static bool compat_filldir(struct dir_context *ctx, const char *name, int namlen
554
553
555
554
buf -> prev_reclen = reclen ;
556
555
buf -> current_dir = (void __user * )dirent + reclen ;
557
- buf -> count -= reclen ;
556
+ ctx -> count -= reclen ;
558
557
return true;
559
558
efault_end :
560
559
user_write_access_end ();
@@ -569,8 +568,8 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
569
568
CLASS (fd_pos , f )(fd );
570
569
struct compat_getdents_callback buf = {
571
570
.ctx .actor = compat_filldir ,
571
+ .ctx .count = count ,
572
572
.current_dir = dirent ,
573
- .count = count
574
573
};
575
574
int error ;
576
575
@@ -587,7 +586,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
587
586
if (put_user (buf .ctx .pos , & lastdirent -> d_off ))
588
587
error = - EFAULT ;
589
588
else
590
- error = count - buf .count ;
589
+ error = count - buf .ctx . count ;
591
590
}
592
591
return error ;
593
592
}
0 commit comments