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.c163
1 files changed, 82 insertions, 81 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 19c8be4696f9..f519e1910191 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -101,7 +101,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
101 if (*ptmp_inode == NULL) 101 if (*ptmp_inode == NULL)
102 return rc; 102 return rc;
103 if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME) 103 if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
104 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; 104 (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
105 rc = 2; 105 rc = 2;
106 } 106 }
107 107
@@ -431,14 +431,14 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
431static int initiate_cifs_search(const int xid, struct file *file) 431static int initiate_cifs_search(const int xid, struct file *file)
432{ 432{
433 int rc = 0; 433 int rc = 0;
434 char * full_path; 434 char *full_path;
435 struct cifsFileInfo * cifsFile; 435 struct cifsFileInfo *cifsFile;
436 struct cifs_sb_info *cifs_sb; 436 struct cifs_sb_info *cifs_sb;
437 struct cifsTconInfo *pTcon; 437 struct cifsTconInfo *pTcon;
438 438
439 if (file->private_data == NULL) { 439 if (file->private_data == NULL) {
440 file->private_data = 440 file->private_data =
441 kzalloc(sizeof(struct cifsFileInfo),GFP_KERNEL); 441 kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
442 } 442 }
443 443
444 if (file->private_data == NULL) 444 if (file->private_data == NULL)
@@ -467,7 +467,7 @@ ffirst_retry:
467 /* test for Unix extensions */ 467 /* test for Unix extensions */
468 if (pTcon->ses->capabilities & CAP_UNIX) { 468 if (pTcon->ses->capabilities & CAP_UNIX) {
469 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; 469 cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX;
470 } else if ((pTcon->ses->capabilities & 470 } else if ((pTcon->ses->capabilities &
471 (CAP_NT_SMBS | CAP_NT_FIND)) == 0) { 471 (CAP_NT_SMBS | CAP_NT_FIND)) == 0) {
472 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD; 472 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD;
473 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 473 } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
@@ -476,13 +476,13 @@ ffirst_retry:
476 cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO; 476 cifsFile->srch_inf.info_level = SMB_FIND_FILE_DIRECTORY_INFO;
477 } 477 }
478 478
479 rc = CIFSFindFirst(xid, pTcon,full_path,cifs_sb->local_nls, 479 rc = CIFSFindFirst(xid, pTcon, full_path, cifs_sb->local_nls,
480 &cifsFile->netfid, &cifsFile->srch_inf, 480 &cifsFile->netfid, &cifsFile->srch_inf,
481 cifs_sb->mnt_cifs_flags & 481 cifs_sb->mnt_cifs_flags &
482 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); 482 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
483 if (rc == 0) 483 if (rc == 0)
484 cifsFile->invalidHandle = FALSE; 484 cifsFile->invalidHandle = FALSE;
485 if ((rc == -EOPNOTSUPP) && 485 if ((rc == -EOPNOTSUPP) &&
486 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { 486 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
487 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 487 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
488 goto ffirst_retry; 488 goto ffirst_retry;
@@ -497,7 +497,7 @@ static int cifs_unicode_bytelen(char *str)
497 int len; 497 int len;
498 __le16 * ustr = (__le16 *)str; 498 __le16 * ustr = (__le16 *)str;
499 499
500 for(len=0;len <= PATH_MAX;len++) { 500 for (len = 0; len <= PATH_MAX; len++) {
501 if (ustr[len] == 0) 501 if (ustr[len] == 0)
502 return len << 1; 502 return len << 1;
503 } 503 }
@@ -507,7 +507,7 @@ static int cifs_unicode_bytelen(char *str)
507 507
508static 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)
509{ 509{
510 char * new_entry; 510 char *new_entry;
511 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; 511 FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
512 512
513 if (level == SMB_FIND_FILE_INFO_STANDARD) { 513 if (level == SMB_FIND_FILE_INFO_STANDARD) {
@@ -523,16 +523,16 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
523 if (new_entry >= end_of_smb) { 523 if (new_entry >= end_of_smb) {
524 cERROR(1, 524 cERROR(1,
525 ("search entry %p began after end of SMB %p old entry %p", 525 ("search entry %p began after end of SMB %p old entry %p",
526 new_entry, end_of_smb, old_entry)); 526 new_entry, end_of_smb, old_entry));
527 return NULL; 527 return NULL;
528 } else if (((level == SMB_FIND_FILE_INFO_STANDARD) && 528 } else if (((level == SMB_FIND_FILE_INFO_STANDARD) &&
529 (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) || 529 (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb))
530 ((level != SMB_FIND_FILE_INFO_STANDARD) && 530 || ((level != SMB_FIND_FILE_INFO_STANDARD) &&
531 (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) { 531 (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) {
532 cERROR(1,("search entry %p extends after end of SMB %p", 532 cERROR(1, ("search entry %p extends after end of SMB %p",
533 new_entry, end_of_smb)); 533 new_entry, end_of_smb));
534 return NULL; 534 return NULL;
535 } else 535 } else
536 return new_entry; 536 return new_entry;
537 537
538} 538}
@@ -543,8 +543,8 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
543static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile) 543static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
544{ 544{
545 int rc = 0; 545 int rc = 0;
546 char * filename = NULL; 546 char *filename = NULL;
547 int len = 0; 547 int len = 0;
548 548
549 if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { 549 if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
550 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 550 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
@@ -556,25 +556,25 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
556 len = strnlen(filename, 5); 556 len = strnlen(filename, 5);
557 } 557 }
558 } 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) {
559 FILE_DIRECTORY_INFO * pFindData = 559 FILE_DIRECTORY_INFO * pFindData =
560 (FILE_DIRECTORY_INFO *)current_entry; 560 (FILE_DIRECTORY_INFO *)current_entry;
561 filename = &pFindData->FileName[0]; 561 filename = &pFindData->FileName[0];
562 len = le32_to_cpu(pFindData->FileNameLength); 562 len = le32_to_cpu(pFindData->FileNameLength);
563 } else if (cfile->srch_inf.info_level == 563 } else if (cfile->srch_inf.info_level ==
564 SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 564 SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
565 FILE_FULL_DIRECTORY_INFO * pFindData = 565 FILE_FULL_DIRECTORY_INFO * pFindData =
566 (FILE_FULL_DIRECTORY_INFO *)current_entry; 566 (FILE_FULL_DIRECTORY_INFO *)current_entry;
567 filename = &pFindData->FileName[0]; 567 filename = &pFindData->FileName[0];
568 len = le32_to_cpu(pFindData->FileNameLength); 568 len = le32_to_cpu(pFindData->FileNameLength);
569 } else if (cfile->srch_inf.info_level == 569 } else if (cfile->srch_inf.info_level ==
570 SMB_FIND_FILE_ID_FULL_DIR_INFO) { 570 SMB_FIND_FILE_ID_FULL_DIR_INFO) {
571 SEARCH_ID_FULL_DIR_INFO * pFindData = 571 SEARCH_ID_FULL_DIR_INFO * pFindData =
572 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 572 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
573 filename = &pFindData->FileName[0]; 573 filename = &pFindData->FileName[0];
574 len = le32_to_cpu(pFindData->FileNameLength); 574 len = le32_to_cpu(pFindData->FileNameLength);
575 } else if (cfile->srch_inf.info_level == 575 } else if (cfile->srch_inf.info_level ==
576 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 576 SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
577 FILE_BOTH_DIRECTORY_INFO * pFindData = 577 FILE_BOTH_DIRECTORY_INFO * pFindData =
578 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 578 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
579 filename = &pFindData->FileName[0]; 579 filename = &pFindData->FileName[0];
580 len = le32_to_cpu(pFindData->FileNameLength); 580 len = le32_to_cpu(pFindData->FileNameLength);
@@ -598,12 +598,12 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
598 } else if (len == 4) { 598 } else if (len == 4) {
599 /* check for .. */ 599 /* check for .. */
600 if ((ufilename[0] == UNICODE_DOT) 600 if ((ufilename[0] == UNICODE_DOT)
601 &&(ufilename[1] == UNICODE_DOT)) 601 && (ufilename[1] == UNICODE_DOT))
602 rc = 2; 602 rc = 2;
603 } 603 }
604 } else /* ASCII */ { 604 } else /* ASCII */ {
605 if (len == 1) { 605 if (len == 1) {
606 if (filename[0] == '.') 606 if (filename[0] == '.')
607 rc = 1; 607 rc = 1;
608 } else if (len == 2) { 608 } else if (len == 2) {
609 if ((filename[0] == '.') && (filename[1] == '.')) 609 if ((filename[0] == '.') && (filename[1] == '.'))
@@ -617,7 +617,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
617 617
618/* Check if directory that we are searching has changed so we can decide 618/* Check if directory that we are searching has changed so we can decide
619 whether we can use the cached search results from the previous search */ 619 whether we can use the cached search results from the previous search */
620static int is_dir_changed(struct file * file) 620static int is_dir_changed(struct file *file)
621{ 621{
622 struct inode *inode = file->f_path.dentry->d_inode; 622 struct inode *inode = file->f_path.dentry->d_inode;
623 struct cifsInodeInfo *cifsInfo = CIFS_I(inode); 623 struct cifsInodeInfo *cifsInfo = CIFS_I(inode);
@@ -636,22 +636,22 @@ static int is_dir_changed(struct file * file)
636/* We start counting in the buffer with entry 2 and increment for every 636/* We start counting in the buffer with entry 2 and increment for every
637 entry (do not increment for . or .. entry) */ 637 entry (do not increment for . or .. entry) */
638static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, 638static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
639 struct file *file, char **ppCurrentEntry, int *num_to_ret) 639 struct file *file, char **ppCurrentEntry, int *num_to_ret)
640{ 640{
641 int rc = 0; 641 int rc = 0;
642 int pos_in_buf = 0; 642 int pos_in_buf = 0;
643 loff_t first_entry_in_buffer; 643 loff_t first_entry_in_buffer;
644 loff_t index_to_find = file->f_pos; 644 loff_t index_to_find = file->f_pos;
645 struct cifsFileInfo * cifsFile = file->private_data; 645 struct cifsFileInfo *cifsFile = file->private_data;
646 /* check if index in the buffer */ 646 /* check if index in the buffer */
647 647
648 if ((cifsFile == NULL) || (ppCurrentEntry == NULL) || 648 if ((cifsFile == NULL) || (ppCurrentEntry == NULL) ||
649 (num_to_ret == NULL)) 649 (num_to_ret == NULL))
650 return -ENOENT; 650 return -ENOENT;
651 651
652 *ppCurrentEntry = NULL; 652 *ppCurrentEntry = NULL;
653 first_entry_in_buffer = 653 first_entry_in_buffer =
654 cifsFile->srch_inf.index_of_last_entry - 654 cifsFile->srch_inf.index_of_last_entry -
655 cifsFile->srch_inf.entries_in_buffer; 655 cifsFile->srch_inf.entries_in_buffer;
656 656
657 /* if first entry in buf is zero then is first buffer 657 /* if first entry in buf is zero then is first buffer
@@ -663,8 +663,8 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
663#ifdef CONFIG_CIFS_DEBUG2 663#ifdef CONFIG_CIFS_DEBUG2
664 dump_cifs_file_struct(file, "In fce "); 664 dump_cifs_file_struct(file, "In fce ");
665#endif 665#endif
666 if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) && 666 if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) &&
667 is_dir_changed(file)) || 667 is_dir_changed(file)) ||
668 (index_to_find < first_entry_in_buffer)) { 668 (index_to_find < first_entry_in_buffer)) {
669 /* close and restart search */ 669 /* close and restart search */
670 cFYI(1, ("search backing up - close and restart search")); 670 cFYI(1, ("search backing up - close and restart search"));
@@ -681,7 +681,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
681 cifs_buf_release(cifsFile->srch_inf. 681 cifs_buf_release(cifsFile->srch_inf.
682 ntwrk_buf_start); 682 ntwrk_buf_start);
683 } 683 }
684 rc = initiate_cifs_search(xid,file); 684 rc = initiate_cifs_search(xid, file);
685 if (rc) { 685 if (rc) {
686 cFYI(1, ("error %d reinitiating a search on rewind", 686 cFYI(1, ("error %d reinitiating a search on rewind",
687 rc)); 687 rc));
@@ -689,10 +689,10 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
689 } 689 }
690 } 690 }
691 691
692 while((index_to_find >= cifsFile->srch_inf.index_of_last_entry) && 692 while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
693 (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)){ 693 (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)) {
694 cFYI(1, ("calling findnext2")); 694 cFYI(1, ("calling findnext2"));
695 rc = CIFSFindNext(xid,pTcon,cifsFile->netfid, 695 rc = CIFSFindNext(xid, pTcon, cifsFile->netfid,
696 &cifsFile->srch_inf); 696 &cifsFile->srch_inf);
697 if (rc) 697 if (rc)
698 return -ENOENT; 698 return -ENOENT;
@@ -701,8 +701,8 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
701 /* we found the buffer that contains the entry */ 701 /* we found the buffer that contains the entry */
702 /* scan and find it */ 702 /* scan and find it */
703 int i; 703 int i;
704 char * current_entry; 704 char *current_entry;
705 char * end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + 705 char *end_of_smb = cifsFile->srch_inf.ntwrk_buf_start +
706 smbCalcSize((struct smb_hdr *) 706 smbCalcSize((struct smb_hdr *)
707 cifsFile->srch_inf.ntwrk_buf_start); 707 cifsFile->srch_inf.ntwrk_buf_start);
708 708
@@ -712,16 +712,16 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
712 pos_in_buf = index_to_find - first_entry_in_buffer; 712 pos_in_buf = index_to_find - first_entry_in_buffer;
713 cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf)); 713 cFYI(1, ("found entry - pos_in_buf %d", pos_in_buf));
714 714
715 for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) { 715 for (i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) {
716 /* go entry by entry figuring out which is first */ 716 /* go entry by entry figuring out which is first */
717 current_entry = nxt_dir_entry(current_entry,end_of_smb, 717 current_entry = nxt_dir_entry(current_entry, end_of_smb,
718 cifsFile->srch_inf.info_level); 718 cifsFile->srch_inf.info_level);
719 } 719 }
720 if ((current_entry == NULL) && (i < pos_in_buf)) { 720 if ((current_entry == NULL) && (i < pos_in_buf)) {
721 /* BB fixme - check if we should flag this error */ 721 /* BB fixme - check if we should flag this error */
722 cERROR(1,("reached end of buf searching for pos in buf" 722 cERROR(1, ("reached end of buf searching for pos in buf"
723 " %d index to find %lld rc %d", 723 " %d index to find %lld rc %d",
724 pos_in_buf,index_to_find,rc)); 724 pos_in_buf, index_to_find, rc));
725 } 725 }
726 rc = 0; 726 rc = 0;
727 *ppCurrentEntry = current_entry; 727 *ppCurrentEntry = current_entry;
@@ -742,17 +742,17 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
742/* inode num, inode type and filename returned */ 742/* inode num, inode type and filename returned */
743static int cifs_get_name_from_search_buf(struct qstr *pqst, 743static int cifs_get_name_from_search_buf(struct qstr *pqst,
744 char *current_entry, __u16 level, unsigned int unicode, 744 char *current_entry, __u16 level, unsigned int unicode,
745 struct cifs_sb_info * cifs_sb, int max_len, ino_t *pinum) 745 struct cifs_sb_info *cifs_sb, int max_len, ino_t *pinum)
746{ 746{
747 int rc = 0; 747 int rc = 0;
748 unsigned int len = 0; 748 unsigned int len = 0;
749 char * filename; 749 char *filename;
750 struct nls_table * nlt = cifs_sb->local_nls; 750 struct nls_table *nlt = cifs_sb->local_nls;
751 751
752 *pinum = 0; 752 *pinum = 0;
753 753
754 if (level == SMB_FIND_FILE_UNIX) { 754 if (level == SMB_FIND_FILE_UNIX) {
755 FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; 755 FILE_UNIX_INFO *pFindData = (FILE_UNIX_INFO *)current_entry;
756 756
757 filename = &pFindData->FileName[0]; 757 filename = &pFindData->FileName[0];
758 if (unicode) { 758 if (unicode) {
@@ -762,27 +762,27 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
762 len = strnlen(filename, PATH_MAX); 762 len = strnlen(filename, PATH_MAX);
763 } 763 }
764 764
765 /* BB fixme - hash low and high 32 bits if not 64 bit arch BB fixme */ 765 /* BB fixme - hash low and high 32 bits if not 64 bit arch BB */
766 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) 766 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
767 *pinum = pFindData->UniqueId; 767 *pinum = pFindData->UniqueId;
768 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) { 768 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
769 FILE_DIRECTORY_INFO * pFindData = 769 FILE_DIRECTORY_INFO *pFindData =
770 (FILE_DIRECTORY_INFO *)current_entry; 770 (FILE_DIRECTORY_INFO *)current_entry;
771 filename = &pFindData->FileName[0]; 771 filename = &pFindData->FileName[0];
772 len = le32_to_cpu(pFindData->FileNameLength); 772 len = le32_to_cpu(pFindData->FileNameLength);
773 } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 773 } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
774 FILE_FULL_DIRECTORY_INFO * pFindData = 774 FILE_FULL_DIRECTORY_INFO *pFindData =
775 (FILE_FULL_DIRECTORY_INFO *)current_entry; 775 (FILE_FULL_DIRECTORY_INFO *)current_entry;
776 filename = &pFindData->FileName[0]; 776 filename = &pFindData->FileName[0];
777 len = le32_to_cpu(pFindData->FileNameLength); 777 len = le32_to_cpu(pFindData->FileNameLength);
778 } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) { 778 } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
779 SEARCH_ID_FULL_DIR_INFO * pFindData = 779 SEARCH_ID_FULL_DIR_INFO *pFindData =
780 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 780 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
781 filename = &pFindData->FileName[0]; 781 filename = &pFindData->FileName[0];
782 len = le32_to_cpu(pFindData->FileNameLength); 782 len = le32_to_cpu(pFindData->FileNameLength);
783 *pinum = pFindData->UniqueId; 783 *pinum = pFindData->UniqueId;
784 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 784 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
785 FILE_BOTH_DIRECTORY_INFO * pFindData = 785 FILE_BOTH_DIRECTORY_INFO *pFindData =
786 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 786 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
787 filename = &pFindData->FileName[0]; 787 filename = &pFindData->FileName[0];
788 len = le32_to_cpu(pFindData->FileNameLength); 788 len = le32_to_cpu(pFindData->FileNameLength);
@@ -798,7 +798,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
798 } 798 }
799 799
800 if (len > max_len) { 800 if (len > max_len) {
801 cERROR(1,("bad search response length %d past smb end", len)); 801 cERROR(1, ("bad search response length %d past smb end", len));
802 return -EINVAL; 802 return -EINVAL;
803 } 803 }
804 804
@@ -810,12 +810,12 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
810 (__le16 *)filename, len/2, nlt); 810 (__le16 *)filename, len/2, nlt);
811 else 811 else
812 pqst->len = cifs_strfromUCS_le((char *)pqst->name, 812 pqst->len = cifs_strfromUCS_le((char *)pqst->name,
813 (__le16 *)filename,len/2,nlt); 813 (__le16 *)filename, len/2, nlt);
814 } else { 814 } else {
815 pqst->name = filename; 815 pqst->name = filename;
816 pqst->len = len; 816 pqst->len = len;
817 } 817 }
818 pqst->hash = full_name_hash(pqst->name,pqst->len); 818 pqst->hash = full_name_hash(pqst->name, pqst->len);
819/* cFYI(1, ("filldir on %s",pqst->name)); */ 819/* cFYI(1, ("filldir on %s",pqst->name)); */
820 return rc; 820 return rc;
821} 821}
@@ -825,10 +825,10 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
825{ 825{
826 int rc = 0; 826 int rc = 0;
827 struct qstr qstring; 827 struct qstr qstring;
828 struct cifsFileInfo * pCifsF; 828 struct cifsFileInfo *pCifsF;
829 unsigned obj_type; 829 unsigned obj_type;
830 ino_t inum; 830 ino_t inum;
831 struct cifs_sb_info * cifs_sb; 831 struct cifs_sb_info *cifs_sb;
832 struct inode *tmp_inode; 832 struct inode *tmp_inode;
833 struct dentry *tmp_dentry; 833 struct dentry *tmp_dentry;
834 834
@@ -843,7 +843,7 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
843 if ((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL)) 843 if ((scratch_buf == NULL) || (pfindEntry == NULL) || (pCifsF == NULL))
844 return -ENOENT; 844 return -ENOENT;
845 845
846 rc = cifs_entry_is_dot(pfindEntry,pCifsF); 846 rc = cifs_entry_is_dot(pfindEntry, pCifsF);
847 /* skip . and .. since we added them first */ 847 /* skip . and .. since we added them first */
848 if (rc != 0) 848 if (rc != 0)
849 return 0; 849 return 0;
@@ -851,23 +851,24 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
851 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 851 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
852 852
853 qstring.name = scratch_buf; 853 qstring.name = scratch_buf;
854 rc = cifs_get_name_from_search_buf(&qstring,pfindEntry, 854 rc = cifs_get_name_from_search_buf(&qstring, pfindEntry,
855 pCifsF->srch_inf.info_level, 855 pCifsF->srch_inf.info_level,
856 pCifsF->srch_inf.unicode,cifs_sb, 856 pCifsF->srch_inf.unicode, cifs_sb,
857 max_len, 857 max_len,
858 &inum /* returned */); 858 &inum /* returned */);
859 859
860 if (rc) 860 if (rc)
861 return rc; 861 return rc;
862 862
863 rc = construct_dentry(&qstring,file,&tmp_inode, &tmp_dentry); 863 rc = construct_dentry(&qstring, file, &tmp_inode, &tmp_dentry);
864 if ((tmp_inode == NULL) || (tmp_dentry == NULL)) 864 if ((tmp_inode == NULL) || (tmp_dentry == NULL))
865 return -ENOMEM; 865 return -ENOMEM;
866 866
867 if (rc) { 867 if (rc) {
868 /* inode created, we need to hash it with right inode number */ 868 /* inode created, we need to hash it with right inode number */
869 if (inum != 0) { 869 if (inum != 0) {
870 /* BB fixme - hash the 2 32 quantities bits together if necessary BB */ 870 /* BB fixme - hash the 2 32 quantities bits together if
871 * necessary BB */
871 tmp_inode->i_ino = inum; 872 tmp_inode->i_ino = inum;
872 } 873 }
873 insert_inode_hash(tmp_inode); 874 insert_inode_hash(tmp_inode);
@@ -892,9 +893,9 @@ static int cifs_filldir(char *pfindEntry, struct file *file,
892 d_rehash(tmp_dentry); 893 d_rehash(tmp_dentry);
893 } 894 }
894 895
895 896
896 rc = filldir(direntry,qstring.name,qstring.len,file->f_pos, 897 rc = filldir(direntry, qstring.name, qstring.len, file->f_pos,
897 tmp_inode->i_ino,obj_type); 898 tmp_inode->i_ino, obj_type);
898 if (rc) { 899 if (rc) {
899 cFYI(1, ("filldir rc = %d", rc)); 900 cFYI(1, ("filldir rc = %d", rc));
900 /* we can not return filldir errors to the caller 901 /* we can not return filldir errors to the caller
@@ -913,7 +914,7 @@ static int cifs_save_resume_key(const char *current_entry,
913 int rc = 0; 914 int rc = 0;
914 unsigned int len = 0; 915 unsigned int len = 0;
915 __u16 level; 916 __u16 level;
916 char * filename; 917 char *filename;
917 918
918 if ((cifsFile == NULL) || (current_entry == NULL)) 919 if ((cifsFile == NULL) || (current_entry == NULL))
919 return -EINVAL; 920 return -EINVAL;
@@ -932,31 +933,31 @@ static int cifs_save_resume_key(const char *current_entry,
932 } 933 }
933 cifsFile->srch_inf.resume_key = pFindData->ResumeKey; 934 cifsFile->srch_inf.resume_key = pFindData->ResumeKey;
934 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) { 935 } else if (level == SMB_FIND_FILE_DIRECTORY_INFO) {
935 FILE_DIRECTORY_INFO * pFindData = 936 FILE_DIRECTORY_INFO *pFindData =
936 (FILE_DIRECTORY_INFO *)current_entry; 937 (FILE_DIRECTORY_INFO *)current_entry;
937 filename = &pFindData->FileName[0]; 938 filename = &pFindData->FileName[0];
938 len = le32_to_cpu(pFindData->FileNameLength); 939 len = le32_to_cpu(pFindData->FileNameLength);
939 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 940 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
940 } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) { 941 } else if (level == SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
941 FILE_FULL_DIRECTORY_INFO * pFindData = 942 FILE_FULL_DIRECTORY_INFO *pFindData =
942 (FILE_FULL_DIRECTORY_INFO *)current_entry; 943 (FILE_FULL_DIRECTORY_INFO *)current_entry;
943 filename = &pFindData->FileName[0]; 944 filename = &pFindData->FileName[0];
944 len = le32_to_cpu(pFindData->FileNameLength); 945 len = le32_to_cpu(pFindData->FileNameLength);
945 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 946 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
946 } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) { 947 } else if (level == SMB_FIND_FILE_ID_FULL_DIR_INFO) {
947 SEARCH_ID_FULL_DIR_INFO * pFindData = 948 SEARCH_ID_FULL_DIR_INFO *pFindData =
948 (SEARCH_ID_FULL_DIR_INFO *)current_entry; 949 (SEARCH_ID_FULL_DIR_INFO *)current_entry;
949 filename = &pFindData->FileName[0]; 950 filename = &pFindData->FileName[0];
950 len = le32_to_cpu(pFindData->FileNameLength); 951 len = le32_to_cpu(pFindData->FileNameLength);
951 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 952 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
952 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { 953 } else if (level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
953 FILE_BOTH_DIRECTORY_INFO * pFindData = 954 FILE_BOTH_DIRECTORY_INFO *pFindData =
954 (FILE_BOTH_DIRECTORY_INFO *)current_entry; 955 (FILE_BOTH_DIRECTORY_INFO *)current_entry;
955 filename = &pFindData->FileName[0]; 956 filename = &pFindData->FileName[0];
956 len = le32_to_cpu(pFindData->FileNameLength); 957 len = le32_to_cpu(pFindData->FileNameLength);
957 cifsFile->srch_inf.resume_key = pFindData->FileIndex; 958 cifsFile->srch_inf.resume_key = pFindData->FileIndex;
958 } else if (level == SMB_FIND_FILE_INFO_STANDARD) { 959 } else if (level == SMB_FIND_FILE_INFO_STANDARD) {
959 FIND_FILE_STANDARD_INFO * pFindData = 960 FIND_FILE_STANDARD_INFO *pFindData =
960 (FIND_FILE_STANDARD_INFO *)current_entry; 961 (FIND_FILE_STANDARD_INFO *)current_entry;
961 filename = &pFindData->FileName[0]; 962 filename = &pFindData->FileName[0];
962 /* one byte length, no name conversion */ 963 /* one byte length, no name conversion */
@@ -974,13 +975,13 @@ static int cifs_save_resume_key(const char *current_entry,
974int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) 975int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
975{ 976{
976 int rc = 0; 977 int rc = 0;
977 int xid,i; 978 int xid, i;
978 struct cifs_sb_info *cifs_sb; 979 struct cifs_sb_info *cifs_sb;
979 struct cifsTconInfo *pTcon; 980 struct cifsTconInfo *pTcon;
980 struct cifsFileInfo *cifsFile = NULL; 981 struct cifsFileInfo *cifsFile = NULL;
981 char * current_entry; 982 char *current_entry;
982 int num_to_fill = 0; 983 int num_to_fill = 0;
983 char * tmp_buf = NULL; 984 char *tmp_buf = NULL;
984 char * end_of_smb; 985 char * end_of_smb;
985 int max_len; 986 int max_len;
986 987
@@ -1009,13 +1010,13 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1009 } 1010 }
1010 file->f_pos++; 1011 file->f_pos++;
1011 default: 1012 default:
1012 /* 1) If search is active, 1013 /* 1) If search is active,
1013 is in current search buffer? 1014 is in current search buffer?
1014 if it before then restart search 1015 if it before then restart search
1015 if after then keep searching till find it */ 1016 if after then keep searching till find it */
1016 1017
1017 if (file->private_data == NULL) { 1018 if (file->private_data == NULL) {
1018 rc = initiate_cifs_search(xid,file); 1019 rc = initiate_cifs_search(xid, file);
1019 cFYI(1, ("initiate cifs search rc %d", rc)); 1020 cFYI(1, ("initiate cifs search rc %d", rc));
1020 if (rc) { 1021 if (rc) {
1021 FreeXid(xid); 1022 FreeXid(xid);
@@ -1037,12 +1038,12 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1037 } /* else { 1038 } /* else {
1038 cifsFile->invalidHandle = TRUE; 1039 cifsFile->invalidHandle = TRUE;
1039 CIFSFindClose(xid, pTcon, cifsFile->netfid); 1040 CIFSFindClose(xid, pTcon, cifsFile->netfid);
1040 } 1041 }
1041 kfree(cifsFile->search_resume_name); 1042 kfree(cifsFile->search_resume_name);
1042 cifsFile->search_resume_name = NULL; */ 1043 cifsFile->search_resume_name = NULL; */
1043 1044
1044 rc = find_cifs_entry(xid,pTcon, file, 1045 rc = find_cifs_entry(xid, pTcon, file,
1045 &current_entry,&num_to_fill); 1046 &current_entry, &num_to_fill);
1046 if (rc) { 1047 if (rc) {
1047 cFYI(1, ("fce error %d", rc)); 1048 cFYI(1, ("fce error %d", rc));
1048 goto rddir2_exit; 1049 goto rddir2_exit;