Skip to content

Commit eaf35b1

Browse files
Christoph HellwigSteve French
authored andcommitted
cifs: use cifs_dirent in cifs_save_resume_key
Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent f16d59b commit eaf35b1

File tree

2 files changed

+10
-58
lines changed

2 files changed

+10
-58
lines changed

fs/cifs/cifsglob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ struct cifs_search_info {
501501
char *ntwrk_buf_start;
502502
char *srch_entries_start;
503503
char *last_entry;
504-
char *presume_name;
504+
const char *presume_name;
505505
unsigned int resume_name_len;
506506
bool endOfSearch:1;
507507
bool emptyDir:1;

fs/cifs/readdir.c

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -478,66 +478,18 @@ static int is_dir_changed(struct file *file)
478478
}
479479

480480
static int cifs_save_resume_key(const char *current_entry,
481-
struct cifsFileInfo *cifsFile)
481+
struct cifsFileInfo *file_info)
482482
{
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;
495485

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;
538492
}
539-
cifsFile->srch_inf.resume_name_len = len;
540-
cifsFile->srch_inf.presume_name = filename;
541493
return rc;
542494
}
543495

0 commit comments

Comments
 (0)