@@ -478,66 +478,18 @@ static int is_dir_changed(struct file *file)
478
478
}
479
479
480
480
static int cifs_save_resume_key (const char * current_entry ,
481
- struct cifsFileInfo * cifsFile )
481
+ struct cifsFileInfo * file_info )
482
482
{
483
- int rc = 0 ;
484
- unsigned int len = 0 ;
485
- __u16 level ;
486
- char * filename ;
487
-
488
- if ((cifsFile == NULL ) || (current_entry == NULL ))
489
- return - EINVAL ;
490
-
491
- level = cifsFile -> srch_inf .info_level ;
492
-
493
- if (level == SMB_FIND_FILE_UNIX ) {
494
- FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO * )current_entry ;
483
+ struct cifs_dirent de ;
484
+ int rc ;
495
485
496
- filename = & pFindData -> FileName [0 ];
497
- if (cifsFile -> srch_inf .unicode ) {
498
- len = cifs_unicode_bytelen (filename );
499
- } else {
500
- /* BB should we make this strnlen of PATH_MAX? */
501
- len = strnlen (filename , PATH_MAX );
502
- }
503
- cifsFile -> srch_inf .resume_key = pFindData -> ResumeKey ;
504
- } else if (level == SMB_FIND_FILE_DIRECTORY_INFO ) {
505
- FILE_DIRECTORY_INFO * pFindData =
506
- (FILE_DIRECTORY_INFO * )current_entry ;
507
- filename = & pFindData -> FileName [0 ];
508
- len = le32_to_cpu (pFindData -> FileNameLength );
509
- cifsFile -> srch_inf .resume_key = pFindData -> FileIndex ;
510
- } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO ) {
511
- FILE_FULL_DIRECTORY_INFO * pFindData =
512
- (FILE_FULL_DIRECTORY_INFO * )current_entry ;
513
- filename = & pFindData -> FileName [0 ];
514
- len = le32_to_cpu (pFindData -> FileNameLength );
515
- cifsFile -> srch_inf .resume_key = pFindData -> FileIndex ;
516
- } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO ) {
517
- SEARCH_ID_FULL_DIR_INFO * pFindData =
518
- (SEARCH_ID_FULL_DIR_INFO * )current_entry ;
519
- filename = & pFindData -> FileName [0 ];
520
- len = le32_to_cpu (pFindData -> FileNameLength );
521
- cifsFile -> srch_inf .resume_key = pFindData -> FileIndex ;
522
- } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO ) {
523
- FILE_BOTH_DIRECTORY_INFO * pFindData =
524
- (FILE_BOTH_DIRECTORY_INFO * )current_entry ;
525
- filename = & pFindData -> FileName [0 ];
526
- len = le32_to_cpu (pFindData -> FileNameLength );
527
- cifsFile -> srch_inf .resume_key = pFindData -> FileIndex ;
528
- } else if (level == SMB_FIND_FILE_INFO_STANDARD ) {
529
- FIND_FILE_STANDARD_INFO * pFindData =
530
- (FIND_FILE_STANDARD_INFO * )current_entry ;
531
- filename = & pFindData -> FileName [0 ];
532
- /* one byte length, no name conversion */
533
- len = (unsigned int )pFindData -> FileNameLength ;
534
- cifsFile -> srch_inf .resume_key = pFindData -> ResumeKey ;
535
- } else {
536
- cFYI (1 , "Unknown findfirst level %d" , level );
537
- return - EINVAL ;
486
+ rc = cifs_fill_dirent (& de , current_entry , file_info -> srch_inf .info_level ,
487
+ file_info -> srch_inf .unicode );
488
+ if (!rc ) {
489
+ file_info -> srch_inf .presume_name = de .name ;
490
+ file_info -> srch_inf .resume_name_len = de .namelen ;
491
+ file_info -> srch_inf .resume_key = de .resume_key ;
538
492
}
539
- cifsFile -> srch_inf .resume_name_len = len ;
540
- cifsFile -> srch_inf .presume_name = filename ;
541
493
return rc ;
542
494
}
543
495
0 commit comments