aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/readdir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/readdir.c')
-rw-r--r--fs/cifs/readdir.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 0f22def4bdff..89aae6cb32f8 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Directory search handling 4 * Directory search handling
5 * 5 *
6 * Copyright (C) International Business Machines Corp., 2004, 2007 6 * Copyright (C) International Business Machines Corp., 2004, 2008
7 * Author(s): Steve French (sfrench@us.ibm.com) 7 * Author(s): Steve French (sfrench@us.ibm.com)
8 * 8 *
9 * This library is free software; you can redistribute it and/or modify 9 * This library is free software; you can redistribute it and/or modify
@@ -42,15 +42,12 @@ static void dump_cifs_file_struct(struct file *file, char *label)
42 cFYI(1, ("empty cifs private file data")); 42 cFYI(1, ("empty cifs private file data"));
43 return; 43 return;
44 } 44 }
45 if (cf->invalidHandle) { 45 if (cf->invalidHandle)
46 cFYI(1, ("invalid handle")); 46 cFYI(1, ("invalid handle"));
47 } 47 if (cf->srch_inf.endOfSearch)
48 if (cf->srch_inf.endOfSearch) {
49 cFYI(1, ("end of search")); 48 cFYI(1, ("end of search"));
50 } 49 if (cf->srch_inf.emptyDir)
51 if (cf->srch_inf.emptyDir) {
52 cFYI(1, ("empty dir")); 50 cFYI(1, ("empty dir"));
53 }
54 } 51 }
55} 52}
56#endif /* DEBUG2 */ 53#endif /* DEBUG2 */
@@ -150,7 +147,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
150 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); 147 cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
151 } else { /* legacy, OS2 and DOS style */ 148 } else { /* legacy, OS2 and DOS style */
152/* struct timespec ts;*/ 149/* struct timespec ts;*/
153 FIND_FILE_STANDARD_INFO * pfindData = 150 FIND_FILE_STANDARD_INFO *pfindData =
154 (FIND_FILE_STANDARD_INFO *)buf; 151 (FIND_FILE_STANDARD_INFO *)buf;
155 152
156 tmp_inode->i_mtime = cnvrtDosUnixTm( 153 tmp_inode->i_mtime = cnvrtDosUnixTm(
@@ -198,9 +195,8 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
198 if (attr & ATTR_DIRECTORY) { 195 if (attr & ATTR_DIRECTORY) {
199 *pobject_type = DT_DIR; 196 *pobject_type = DT_DIR;
200 /* override default perms since we do not lock dirs */ 197 /* override default perms since we do not lock dirs */
201 if (atomic_read(&cifsInfo->inUse) == 0) { 198 if (atomic_read(&cifsInfo->inUse) == 0)
202 tmp_inode->i_mode = cifs_sb->mnt_dir_mode; 199 tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
203 }
204 tmp_inode->i_mode |= S_IFDIR; 200 tmp_inode->i_mode |= S_IFDIR;
205 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) && 201 } else if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) &&
206 (attr & ATTR_SYSTEM)) { 202 (attr & ATTR_SYSTEM)) {
@@ -231,9 +227,8 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
231 } /* could add code here - to validate if device or weird share type? */ 227 } /* could add code here - to validate if device or weird share type? */
232 228
233 /* can not fill in nlink here as in qpathinfo version and Unx search */ 229 /* can not fill in nlink here as in qpathinfo version and Unx search */
234 if (atomic_read(&cifsInfo->inUse) == 0) { 230 if (atomic_read(&cifsInfo->inUse) == 0)
235 atomic_set(&cifsInfo->inUse, 1); 231 atomic_set(&cifsInfo->inUse, 1);
236 }
237 232
238 spin_lock(&tmp_inode->i_lock); 233 spin_lock(&tmp_inode->i_lock);
239 if (is_size_safe_to_change(cifsInfo, end_of_file)) { 234 if (is_size_safe_to_change(cifsInfo, end_of_file)) {
@@ -461,9 +456,8 @@ static int initiate_cifs_search(const int xid, struct file *file)
461 456
462 full_path = build_path_from_dentry(file->f_path.dentry); 457 full_path = build_path_from_dentry(file->f_path.dentry);
463 458
464 if (full_path == NULL) { 459 if (full_path == NULL)
465 return -ENOMEM; 460 return -ENOMEM;
466 }
467 461
468 cFYI(1, ("Full path: %s start at: %lld", full_path, file->f_pos)); 462 cFYI(1, ("Full path: %s start at: %lld", full_path, file->f_pos));
469 463
@@ -471,9 +465,9 @@ ffirst_retry:
471 /* test for Unix extensions */ 465 /* test for Unix extensions */
472 /* but now check for them on the share/mount not on the SMB session */ 466 /* but now check for them on the share/mount not on the SMB session */
473/* if (pTcon->ses->capabilities & CAP_UNIX) { */ 467/* if (pTcon->ses->capabilities & CAP_UNIX) { */
474 if (pTcon->unix_ext) { 468 if (pTcon->unix_ext)
475 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; 469 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX;
476 } else if ((pTcon->ses->capabilities & 470 else if ((pTcon->ses->capabilities &
477 (CAP_NT_SMBS | CAP_NT_FIND)) == 0) { 471 (CAP_NT_SMBS | CAP_NT_FIND)) == 0) {
478 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD; 472 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD;
479 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 473 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
@@ -514,10 +508,10 @@ static int cifs_unicode_bytelen(char *str)
514static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level) 508static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
515{ 509{
516 char *new_entry; 510 char *new_entry;
517 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; 511 FILE_DIRECTORY_INFO *pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
518 512
519 if (level == SMB_FIND_FILE_INFO_STANDARD) { 513 if (level == SMB_FIND_FILE_INFO_STANDARD) {
520 FIND_FILE_STANDARD_INFO * pfData; 514 FIND_FILE_STANDARD_INFO *pfData;
521 pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo; 515 pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo;
522 516
523 new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) + 517 new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) +
@@ -553,7 +547,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
553 int len = 0; 547 int len = 0;
554 548
555 if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { 549 if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
556 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 550 FILE_UNIX_INFO *pFindData = (FILE_UNIX_INFO *)current_entry;
557 filename = &pFindData->FileName[0]; 551 filename = &pFindData->FileName[0];
558 if (cfile->srch_inf.unicode) { 552 if (cfile->srch_inf.unicode) {
559 len = cifs_unicode_bytelen(filename); 553 len = cifs_unicode_bytelen(filename);
@@ -562,30 +556,30 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
562 len = strnlen(filename, 5); 556 len = strnlen(filename, 5);
563 } 557 }
564 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) { 558 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) {
565 FILE_DIRECTORY_INFO * pFindData = 559 FILE_DIRECTORY_INFO *pFindData =
566 (FILE_DIRECTORY_INFO *)current_entry; 560 (FILE_DIRECTORY_INFO *)current_entry;
567 filename = &pFindData->FileName[0]; 561 filename = &pFindData->FileName[0];
568 len = le32_to_cpu(pFindData->FileNameLength); 562 len = le32_to_cpu(pFindData->FileNameLength);
569 } else if (cfile->srch_inf.info_level == 563 } else if (cfile->srch_inf.info_level ==
570 SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 564 SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
571 FILE_FULL_DIRECTORY_INFO * pFindData = 565 FILE_FULL_DIRECTORY_INFO *pFindData =
572 (FILE_FULL_DIRECTORY_INFO *)current_entry; 566 (FILE_FULL_DIRECTORY_INFO *)current_entry;
573 filename = &pFindData->FileName[0]; 567 filename = &pFindData->FileName[0];
574 len = le32_to_cpu(pFindData->FileNameLength); 568 len = le32_to_cpu(pFindData->FileNameLength);
575 } else if (cfile->srch_inf.info_level == 569 } else if (cfile->srch_inf.info_level ==
576 SMB_FIND_FILE_ID_FULL_DIR_INFO) { 570 SMB_FIND_FILE_ID_FULL_DIR_INFO) {
577 SEARCH_ID_FULL_DIR_INFO * pFindData = 571 SEARCH_ID_FULL_DIR_INFO *pFindData =
578 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 572 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
579 filename = &pFindData->FileName[0]; 573 filename = &pFindData->FileName[0];
580 len = le32_to_cpu(pFindData->FileNameLength); 574 len = le32_to_cpu(pFindData->FileNameLength);
581 } else if (cfile->srch_inf.info_level == 575 } else if (cfile->srch_inf.info_level ==
582 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 576 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
583 FILE_BOTH_DIRECTORY_INFO * pFindData = 577 FILE_BOTH_DIRECTORY_INFO *pFindData =
584 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 578 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
585 filename = &pFindData->FileName[0]; 579 filename = &pFindData->FileName[0];
586 len = le32_to_cpu(pFindData->FileNameLength); 580 len = le32_to_cpu(pFindData->FileNameLength);
587 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) { 581 } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) {
588 FIND_FILE_STANDARD_INFO * pFindData = 582 FIND_FILE_STANDARD_INFO *pFindData =
589 (FIND_FILE_STANDARD_INFO *)current_entry; 583 (FIND_FILE_STANDARD_INFO *)current_entry;
590 filename = &pFindData->FileName[0]; 584 filename = &pFindData->FileName[0];
591 len = pFindData->FileNameLength; 585 len = pFindData->FileNameLength;
@@ -718,7 +712,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
718 pos_in_buf = index_to_find - first_entry_in_buffer; 712 pos_in_buf = index_to_find - first_entry_in_buffer;
719 cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf)); 713 cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf));
720 714
721 for (i=0; (i < (pos_in_buf)) && (current_entry != NULL); i++) { 715 for (i = 0; (i < (pos_in_buf)) && (current_entry != NULL); i++) {
722 /* go entry by entry figuring out which is first */ 716 /* go entry by entry figuring out which is first */
723 current_entry = nxt_dir_entry(current_entry, end_of_smb, 717 current_entry = nxt_dir_entry(current_entry, end_of_smb,
724 cifsFile->srch_inf.info_level); 718 cifsFile->srch_inf.info_level);
@@ -793,7 +787,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
793 filename = &pFindData->FileName[0]; 787 filename = &pFindData->FileName[0];
794 len = le32_to_cpu(pFindData->FileNameLength); 788 len = le32_to_cpu(pFindData->FileNameLength);
795 } else if (level == SMB_FIND_FILE_INFO_STANDARD) { 789 } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
796 FIND_FILE_STANDARD_INFO * pFindData = 790 FIND_FILE_STANDARD_INFO *pFindData =
797 (FIND_FILE_STANDARD_INFO *)current_entry; 791 (FIND_FILE_STANDARD_INFO *)current_entry;
798 filename = &pFindData->FileName[0]; 792 filename = &pFindData->FileName[0];
799 /* one byte length, no name conversion */ 793 /* one byte length, no name conversion */
@@ -928,7 +922,7 @@ static int cifs_save_resume_key(const char *current_entry,
928 level = cifsFile->srch_inf.info_level; 922 level = cifsFile->srch_inf.info_level;
929 923
930 if (level == SMB_FIND_FILE_UNIX) { 924 if (level == SMB_FIND_FILE_UNIX) {
931 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 925 FILE_UNIX_INFO *pFindData = (FILE_UNIX_INFO *)current_entry;
932 926
933 filename = &pFindData->FileName[0]; 927 filename = &pFindData->FileName[0];
934 if (cifsFile->srch_inf.unicode) { 928 if (cifsFile->srch_inf.unicode) {