diff options
Diffstat (limited to 'fs/cifs/readdir.c')
-rw-r--r-- | fs/cifs/readdir.c | 184 |
1 files changed, 130 insertions, 54 deletions
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index b689c5035124..03bbcb377913 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -21,6 +21,7 @@ | |||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 | */ | 22 | */ |
23 | #include <linux/fs.h> | 23 | #include <linux/fs.h> |
24 | #include <linux/pagemap.h> | ||
24 | #include <linux/stat.h> | 25 | #include <linux/stat.h> |
25 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
26 | #include "cifspdu.h" | 27 | #include "cifspdu.h" |
@@ -31,8 +32,8 @@ | |||
31 | #include "cifs_fs_sb.h" | 32 | #include "cifs_fs_sb.h" |
32 | #include "cifsfs.h" | 33 | #include "cifsfs.h" |
33 | 34 | ||
34 | /* BB fixme - add debug wrappers around this function to disable it fixme BB */ | 35 | #ifdef CONFIG_CIFS_DEBUG2 |
35 | /* static void dump_cifs_file_struct(struct file *file, char *label) | 36 | static void dump_cifs_file_struct(struct file *file, char *label) |
36 | { | 37 | { |
37 | struct cifsFileInfo * cf; | 38 | struct cifsFileInfo * cf; |
38 | 39 | ||
@@ -53,7 +54,8 @@ | |||
53 | } | 54 | } |
54 | 55 | ||
55 | } | 56 | } |
56 | } */ | 57 | } |
58 | #endif /* DEBUG2 */ | ||
57 | 59 | ||
58 | /* Returns one if new inode created (which therefore needs to be hashed) */ | 60 | /* Returns one if new inode created (which therefore needs to be hashed) */ |
59 | /* Might check in the future if inode number changed so we can rehash inode */ | 61 | /* Might check in the future if inode number changed so we can rehash inode */ |
@@ -107,32 +109,52 @@ static int construct_dentry(struct qstr *qstring, struct file *file, | |||
107 | return rc; | 109 | return rc; |
108 | } | 110 | } |
109 | 111 | ||
110 | static void fill_in_inode(struct inode *tmp_inode, | 112 | static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, |
111 | FILE_DIRECTORY_INFO *pfindData, int *pobject_type, int isNewInode) | 113 | char * buf, int *pobject_type, int isNewInode) |
112 | { | 114 | { |
113 | loff_t local_size; | 115 | loff_t local_size; |
114 | struct timespec local_mtime; | 116 | struct timespec local_mtime; |
115 | 117 | ||
116 | struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); | 118 | struct cifsInodeInfo *cifsInfo = CIFS_I(tmp_inode); |
117 | struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); | 119 | struct cifs_sb_info *cifs_sb = CIFS_SB(tmp_inode->i_sb); |
118 | __u32 attr = le32_to_cpu(pfindData->ExtFileAttributes); | 120 | __u32 attr; |
119 | __u64 allocation_size = le64_to_cpu(pfindData->AllocationSize); | 121 | __u64 allocation_size; |
120 | __u64 end_of_file = le64_to_cpu(pfindData->EndOfFile); | 122 | __u64 end_of_file; |
121 | |||
122 | cifsInfo->cifsAttrs = attr; | ||
123 | cifsInfo->time = jiffies; | ||
124 | 123 | ||
125 | /* save mtime and size */ | 124 | /* save mtime and size */ |
126 | local_mtime = tmp_inode->i_mtime; | 125 | local_mtime = tmp_inode->i_mtime; |
127 | local_size = tmp_inode->i_size; | 126 | local_size = tmp_inode->i_size; |
128 | 127 | ||
128 | if(new_buf_type) { | ||
129 | FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf; | ||
130 | |||
131 | attr = le32_to_cpu(pfindData->ExtFileAttributes); | ||
132 | allocation_size = le64_to_cpu(pfindData->AllocationSize); | ||
133 | end_of_file = le64_to_cpu(pfindData->EndOfFile); | ||
134 | tmp_inode->i_atime = | ||
135 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); | ||
136 | tmp_inode->i_mtime = | ||
137 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); | ||
138 | tmp_inode->i_ctime = | ||
139 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); | ||
140 | } else { /* legacy, OS2 and DOS style */ | ||
141 | FIND_FILE_STANDARD_INFO * pfindData = | ||
142 | (FIND_FILE_STANDARD_INFO *)buf; | ||
143 | |||
144 | attr = le16_to_cpu(pfindData->Attributes); | ||
145 | allocation_size = le32_to_cpu(pfindData->AllocationSize); | ||
146 | end_of_file = le32_to_cpu(pfindData->DataSize); | ||
147 | tmp_inode->i_atime = CURRENT_TIME; | ||
148 | /* tmp_inode->i_mtime = BB FIXME - add dos time handling | ||
149 | tmp_inode->i_ctime = 0; BB FIXME */ | ||
150 | |||
151 | } | ||
152 | |||
129 | /* Linux can not store file creation time unfortunately so ignore it */ | 153 | /* Linux can not store file creation time unfortunately so ignore it */ |
130 | tmp_inode->i_atime = | 154 | |
131 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastAccessTime)); | 155 | cifsInfo->cifsAttrs = attr; |
132 | tmp_inode->i_mtime = | 156 | cifsInfo->time = jiffies; |
133 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->LastWriteTime)); | 157 | |
134 | tmp_inode->i_ctime = | ||
135 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); | ||
136 | /* treat dos attribute of read-only as read-only mode bit e.g. 555? */ | 158 | /* treat dos attribute of read-only as read-only mode bit e.g. 555? */ |
137 | /* 2767 perms - indicate mandatory locking */ | 159 | /* 2767 perms - indicate mandatory locking */ |
138 | /* BB fill in uid and gid here? with help from winbind? | 160 | /* BB fill in uid and gid here? with help from winbind? |
@@ -215,11 +237,13 @@ static void fill_in_inode(struct inode *tmp_inode, | |||
215 | else | 237 | else |
216 | tmp_inode->i_fop = &cifs_file_ops; | 238 | tmp_inode->i_fop = &cifs_file_ops; |
217 | 239 | ||
218 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | ||
219 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && | 240 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && |
220 | (cifs_sb->tcon->ses->server->maxBuf < | 241 | (cifs_sb->tcon->ses->server->maxBuf < |
221 | 4096 + MAX_CIFS_HDR_SIZE)) | 242 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) |
222 | tmp_inode->i_data.a_ops->readpages = NULL; | 243 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
244 | else | ||
245 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | ||
246 | |||
223 | if(isNewInode) | 247 | if(isNewInode) |
224 | return; /* No sense invalidating pages for new inode | 248 | return; /* No sense invalidating pages for new inode |
225 | since have not started caching readahead file | 249 | since have not started caching readahead file |
@@ -338,11 +362,12 @@ static void unix_fill_in_inode(struct inode *tmp_inode, | |||
338 | else | 362 | else |
339 | tmp_inode->i_fop = &cifs_file_ops; | 363 | tmp_inode->i_fop = &cifs_file_ops; |
340 | 364 | ||
341 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | ||
342 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && | 365 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && |
343 | (cifs_sb->tcon->ses->server->maxBuf < | 366 | (cifs_sb->tcon->ses->server->maxBuf < |
344 | 4096 + MAX_CIFS_HDR_SIZE)) | 367 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) |
345 | tmp_inode->i_data.a_ops->readpages = NULL; | 368 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
369 | else | ||
370 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | ||
346 | 371 | ||
347 | if(isNewInode) | 372 | if(isNewInode) |
348 | return; /* No sense invalidating pages for new inode since we | 373 | return; /* No sense invalidating pages for new inode since we |
@@ -415,7 +440,10 @@ static int initiate_cifs_search(const int xid, struct file *file) | |||
415 | ffirst_retry: | 440 | ffirst_retry: |
416 | /* test for Unix extensions */ | 441 | /* test for Unix extensions */ |
417 | if (pTcon->ses->capabilities & CAP_UNIX) { | 442 | if (pTcon->ses->capabilities & CAP_UNIX) { |
418 | cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; | 443 | cifsFile->srch_inf.info_level = SMB_FIND_FILE_UNIX; |
444 | } else if ((pTcon->ses->capabilities & | ||
445 | (CAP_NT_SMBS | CAP_NT_FIND)) == 0) { | ||
446 | cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD; | ||
419 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { | 447 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { |
420 | cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; | 448 | cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; |
421 | } else /* not srvinos - BB fixme add check for backlevel? */ { | 449 | } else /* not srvinos - BB fixme add check for backlevel? */ { |
@@ -451,12 +479,19 @@ static int cifs_unicode_bytelen(char *str) | |||
451 | return len << 1; | 479 | return len << 1; |
452 | } | 480 | } |
453 | 481 | ||
454 | static char *nxt_dir_entry(char *old_entry, char *end_of_smb) | 482 | static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level) |
455 | { | 483 | { |
456 | char * new_entry; | 484 | char * new_entry; |
457 | FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; | 485 | FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; |
458 | 486 | ||
459 | new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); | 487 | if(level == SMB_FIND_FILE_INFO_STANDARD) { |
488 | FIND_FILE_STANDARD_INFO * pfData; | ||
489 | pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo; | ||
490 | |||
491 | new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) + | ||
492 | pfData->FileNameLength; | ||
493 | } else | ||
494 | new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); | ||
460 | cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); | 495 | cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); |
461 | /* validate that new_entry is not past end of SMB */ | 496 | /* validate that new_entry is not past end of SMB */ |
462 | if(new_entry >= end_of_smb) { | 497 | if(new_entry >= end_of_smb) { |
@@ -464,7 +499,10 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb) | |||
464 | ("search entry %p began after end of SMB %p old entry %p", | 499 | ("search entry %p began after end of SMB %p old entry %p", |
465 | new_entry, end_of_smb, old_entry)); | 500 | new_entry, end_of_smb, old_entry)); |
466 | return NULL; | 501 | return NULL; |
467 | } else if (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb) { | 502 | } else if(((level == SMB_FIND_FILE_INFO_STANDARD) && |
503 | (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) || | ||
504 | ((level != SMB_FIND_FILE_INFO_STANDARD) && | ||
505 | (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) { | ||
468 | cERROR(1,("search entry %p extends after end of SMB %p", | 506 | cERROR(1,("search entry %p extends after end of SMB %p", |
469 | new_entry, end_of_smb)); | 507 | new_entry, end_of_smb)); |
470 | return NULL; | 508 | return NULL; |
@@ -482,7 +520,7 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile) | |||
482 | char * filename = NULL; | 520 | char * filename = NULL; |
483 | int len = 0; | 521 | int len = 0; |
484 | 522 | ||
485 | if(cfile->srch_inf.info_level == 0x202) { | 523 | if(cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { |
486 | FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; | 524 | FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; |
487 | filename = &pFindData->FileName[0]; | 525 | filename = &pFindData->FileName[0]; |
488 | if(cfile->srch_inf.unicode) { | 526 | if(cfile->srch_inf.unicode) { |
@@ -491,26 +529,34 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile) | |||
491 | /* BB should we make this strnlen of PATH_MAX? */ | 529 | /* BB should we make this strnlen of PATH_MAX? */ |
492 | len = strnlen(filename, 5); | 530 | len = strnlen(filename, 5); |
493 | } | 531 | } |
494 | } else if(cfile->srch_inf.info_level == 0x101) { | 532 | } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) { |
495 | FILE_DIRECTORY_INFO * pFindData = | 533 | FILE_DIRECTORY_INFO * pFindData = |
496 | (FILE_DIRECTORY_INFO *)current_entry; | 534 | (FILE_DIRECTORY_INFO *)current_entry; |
497 | filename = &pFindData->FileName[0]; | 535 | filename = &pFindData->FileName[0]; |
498 | len = le32_to_cpu(pFindData->FileNameLength); | 536 | len = le32_to_cpu(pFindData->FileNameLength); |
499 | } else if(cfile->srch_inf.info_level == 0x102) { | 537 | } else if(cfile->srch_inf.info_level == |
538 | SMB_FIND_FILE_FULL_DIRECTORY_INFO) { | ||
500 | FILE_FULL_DIRECTORY_INFO * pFindData = | 539 | FILE_FULL_DIRECTORY_INFO * pFindData = |
501 | (FILE_FULL_DIRECTORY_INFO *)current_entry; | 540 | (FILE_FULL_DIRECTORY_INFO *)current_entry; |
502 | filename = &pFindData->FileName[0]; | 541 | filename = &pFindData->FileName[0]; |
503 | len = le32_to_cpu(pFindData->FileNameLength); | 542 | len = le32_to_cpu(pFindData->FileNameLength); |
504 | } else if(cfile->srch_inf.info_level == 0x105) { | 543 | } else if(cfile->srch_inf.info_level == |
544 | SMB_FIND_FILE_ID_FULL_DIR_INFO) { | ||
505 | SEARCH_ID_FULL_DIR_INFO * pFindData = | 545 | SEARCH_ID_FULL_DIR_INFO * pFindData = |
506 | (SEARCH_ID_FULL_DIR_INFO *)current_entry; | 546 | (SEARCH_ID_FULL_DIR_INFO *)current_entry; |
507 | filename = &pFindData->FileName[0]; | 547 | filename = &pFindData->FileName[0]; |
508 | len = le32_to_cpu(pFindData->FileNameLength); | 548 | len = le32_to_cpu(pFindData->FileNameLength); |
509 | } else if(cfile->srch_inf.info_level == 0x104) { | 549 | } else if(cfile->srch_inf.info_level == |
550 | SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { | ||
510 | FILE_BOTH_DIRECTORY_INFO * pFindData = | 551 | FILE_BOTH_DIRECTORY_INFO * pFindData = |
511 | (FILE_BOTH_DIRECTORY_INFO *)current_entry; | 552 | (FILE_BOTH_DIRECTORY_INFO *)current_entry; |
512 | filename = &pFindData->FileName[0]; | 553 | filename = &pFindData->FileName[0]; |
513 | len = le32_to_cpu(pFindData->FileNameLength); | 554 | len = le32_to_cpu(pFindData->FileNameLength); |
555 | } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) { | ||
556 | FIND_FILE_STANDARD_INFO * pFindData = | ||
557 | (FIND_FILE_STANDARD_INFO *)current_entry; | ||
558 | filename = &pFindData->FileName[0]; | ||
559 | len = le32_to_cpu(pFindData->FileNameLength); | ||
514 | } else { | 560 | } else { |
515 | cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); | 561 | cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); |
516 | } | 562 | } |
@@ -597,7 +643,9 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
597 | . and .. for the root of a drive and for those we need | 643 | . and .. for the root of a drive and for those we need |
598 | to start two entries earlier */ | 644 | to start two entries earlier */ |
599 | 645 | ||
600 | /* dump_cifs_file_struct(file, "In fce ");*/ | 646 | #ifdef CONFIG_CIFS_DEBUG2 |
647 | dump_cifs_file_struct(file, "In fce "); | ||
648 | #endif | ||
601 | if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) && | 649 | if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) && |
602 | is_dir_changed(file)) || | 650 | is_dir_changed(file)) || |
603 | (index_to_find < first_entry_in_buffer)) { | 651 | (index_to_find < first_entry_in_buffer)) { |
@@ -644,10 +692,12 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
644 | first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry | 692 | first_entry_in_buffer = cifsFile->srch_inf.index_of_last_entry |
645 | - cifsFile->srch_inf.entries_in_buffer; | 693 | - cifsFile->srch_inf.entries_in_buffer; |
646 | pos_in_buf = index_to_find - first_entry_in_buffer; | 694 | pos_in_buf = index_to_find - first_entry_in_buffer; |
647 | cFYI(1,("found entry - pos_in_buf %d",pos_in_buf)); | 695 | cFYI(1,("found entry - pos_in_buf %d",pos_in_buf)); |
696 | |||
648 | for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) { | 697 | for(i=0;(i<(pos_in_buf)) && (current_entry != NULL);i++) { |
649 | /* go entry by entry figuring out which is first */ | 698 | /* go entry by entry figuring out which is first */ |
650 | current_entry = nxt_dir_entry(current_entry,end_of_smb); | 699 | current_entry = nxt_dir_entry(current_entry,end_of_smb, |
700 | cifsFile->srch_inf.info_level); | ||
651 | } | 701 | } |
652 | if((current_entry == NULL) && (i < pos_in_buf)) { | 702 | if((current_entry == NULL) && (i < pos_in_buf)) { |
653 | /* BB fixme - check if we should flag this error */ | 703 | /* BB fixme - check if we should flag this error */ |
@@ -674,7 +724,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
674 | /* inode num, inode type and filename returned */ | 724 | /* inode num, inode type and filename returned */ |
675 | static int cifs_get_name_from_search_buf(struct qstr *pqst, | 725 | static int cifs_get_name_from_search_buf(struct qstr *pqst, |
676 | char *current_entry, __u16 level, unsigned int unicode, | 726 | char *current_entry, __u16 level, unsigned int unicode, |
677 | struct cifs_sb_info * cifs_sb, ino_t *pinum) | 727 | struct cifs_sb_info * cifs_sb, int max_len, ino_t *pinum) |
678 | { | 728 | { |
679 | int rc = 0; | 729 | int rc = 0; |
680 | unsigned int len = 0; | 730 | unsigned int len = 0; |
@@ -718,10 +768,22 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, | |||
718 | (FILE_BOTH_DIRECTORY_INFO *)current_entry; | 768 | (FILE_BOTH_DIRECTORY_INFO *)current_entry; |
719 | filename = &pFindData->FileName[0]; | 769 | filename = &pFindData->FileName[0]; |
720 | len = le32_to_cpu(pFindData->FileNameLength); | 770 | len = le32_to_cpu(pFindData->FileNameLength); |
771 | } else if(level == SMB_FIND_FILE_INFO_STANDARD) { | ||
772 | FIND_FILE_STANDARD_INFO * pFindData = | ||
773 | (FIND_FILE_STANDARD_INFO *)current_entry; | ||
774 | filename = &pFindData->FileName[0]; | ||
775 | /* one byte length, no name conversion */ | ||
776 | len = (unsigned int)pFindData->FileNameLength; | ||
721 | } else { | 777 | } else { |
722 | cFYI(1,("Unknown findfirst level %d",level)); | 778 | cFYI(1,("Unknown findfirst level %d",level)); |
723 | return -EINVAL; | 779 | return -EINVAL; |
724 | } | 780 | } |
781 | |||
782 | if(len > max_len) { | ||
783 | cERROR(1,("bad search response length %d past smb end", len)); | ||
784 | return -EINVAL; | ||
785 | } | ||
786 | |||
725 | if(unicode) { | 787 | if(unicode) { |
726 | /* BB fixme - test with long names */ | 788 | /* BB fixme - test with long names */ |
727 | /* Note converted filename can be longer than in unicode */ | 789 | /* Note converted filename can be longer than in unicode */ |
@@ -741,7 +803,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst, | |||
741 | } | 803 | } |
742 | 804 | ||
743 | static int cifs_filldir(char *pfindEntry, struct file *file, | 805 | static int cifs_filldir(char *pfindEntry, struct file *file, |
744 | filldir_t filldir, void *direntry, char *scratch_buf) | 806 | filldir_t filldir, void *direntry, char *scratch_buf, int max_len) |
745 | { | 807 | { |
746 | int rc = 0; | 808 | int rc = 0; |
747 | struct qstr qstring; | 809 | struct qstr qstring; |
@@ -777,6 +839,7 @@ static int cifs_filldir(char *pfindEntry, struct file *file, | |||
777 | rc = cifs_get_name_from_search_buf(&qstring,pfindEntry, | 839 | rc = cifs_get_name_from_search_buf(&qstring,pfindEntry, |
778 | pCifsF->srch_inf.info_level, | 840 | pCifsF->srch_inf.info_level, |
779 | pCifsF->srch_inf.unicode,cifs_sb, | 841 | pCifsF->srch_inf.unicode,cifs_sb, |
842 | max_len, | ||
780 | &inum /* returned */); | 843 | &inum /* returned */); |
781 | 844 | ||
782 | if(rc) | 845 | if(rc) |
@@ -798,13 +861,16 @@ static int cifs_filldir(char *pfindEntry, struct file *file, | |||
798 | /* we pass in rc below, indicating whether it is a new inode, | 861 | /* we pass in rc below, indicating whether it is a new inode, |
799 | so we can figure out whether to invalidate the inode cached | 862 | so we can figure out whether to invalidate the inode cached |
800 | data if the file has changed */ | 863 | data if the file has changed */ |
801 | if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) { | 864 | if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_UNIX) |
802 | unix_fill_in_inode(tmp_inode, | 865 | unix_fill_in_inode(tmp_inode, |
803 | (FILE_UNIX_INFO *)pfindEntry,&obj_type, rc); | 866 | (FILE_UNIX_INFO *)pfindEntry, |
804 | } else { | 867 | &obj_type, rc); |
805 | fill_in_inode(tmp_inode, | 868 | else if(pCifsF->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) |
806 | (FILE_DIRECTORY_INFO *)pfindEntry,&obj_type, rc); | 869 | fill_in_inode(tmp_inode, 0 /* old level 1 buffer type */, |
807 | } | 870 | pfindEntry, &obj_type, rc); |
871 | else | ||
872 | fill_in_inode(tmp_inode, 1 /* NT */, pfindEntry, &obj_type, rc); | ||
873 | |||
808 | 874 | ||
809 | rc = filldir(direntry,qstring.name,qstring.len,file->f_pos, | 875 | rc = filldir(direntry,qstring.name,qstring.len,file->f_pos, |
810 | tmp_inode->i_ino,obj_type); | 876 | tmp_inode->i_ino,obj_type); |
@@ -864,6 +930,12 @@ static int cifs_save_resume_key(const char *current_entry, | |||
864 | filename = &pFindData->FileName[0]; | 930 | filename = &pFindData->FileName[0]; |
865 | len = le32_to_cpu(pFindData->FileNameLength); | 931 | len = le32_to_cpu(pFindData->FileNameLength); |
866 | cifsFile->srch_inf.resume_key = pFindData->FileIndex; | 932 | cifsFile->srch_inf.resume_key = pFindData->FileIndex; |
933 | } else if(level == SMB_FIND_FILE_INFO_STANDARD) { | ||
934 | FIND_FILE_STANDARD_INFO * pFindData = | ||
935 | (FIND_FILE_STANDARD_INFO *)current_entry; | ||
936 | filename = &pFindData->FileName[0]; | ||
937 | /* one byte length, no name conversion */ | ||
938 | len = (unsigned int)pFindData->FileNameLength; | ||
867 | } else { | 939 | } else { |
868 | cFYI(1,("Unknown findfirst level %d",level)); | 940 | cFYI(1,("Unknown findfirst level %d",level)); |
869 | return -EINVAL; | 941 | return -EINVAL; |
@@ -884,6 +956,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) | |||
884 | int num_to_fill = 0; | 956 | int num_to_fill = 0; |
885 | char * tmp_buf = NULL; | 957 | char * tmp_buf = NULL; |
886 | char * end_of_smb; | 958 | char * end_of_smb; |
959 | int max_len; | ||
887 | 960 | ||
888 | xid = GetXid(); | 961 | xid = GetXid(); |
889 | 962 | ||
@@ -909,7 +982,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) | |||
909 | case 1: | 982 | case 1: |
910 | if (filldir(direntry, "..", 2, file->f_pos, | 983 | if (filldir(direntry, "..", 2, file->f_pos, |
911 | file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { | 984 | file->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { |
912 | cERROR(1, ("Filldir for parent dir failed ")); | 985 | cERROR(1, ("Filldir for parent dir failed")); |
913 | rc = -ENOMEM; | 986 | rc = -ENOMEM; |
914 | break; | 987 | break; |
915 | } | 988 | } |
@@ -959,10 +1032,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) | |||
959 | goto rddir2_exit; | 1032 | goto rddir2_exit; |
960 | } | 1033 | } |
961 | cFYI(1,("loop through %d times filling dir for net buf %p", | 1034 | cFYI(1,("loop through %d times filling dir for net buf %p", |
962 | num_to_fill,cifsFile->srch_inf.ntwrk_buf_start)); | 1035 | num_to_fill,cifsFile->srch_inf.ntwrk_buf_start)); |
963 | end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + | 1036 | max_len = smbCalcSize((struct smb_hdr *) |
964 | smbCalcSize((struct smb_hdr *) | 1037 | cifsFile->srch_inf.ntwrk_buf_start); |
965 | cifsFile->srch_inf.ntwrk_buf_start); | 1038 | end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len; |
1039 | |||
966 | /* To be safe - for UCS to UTF-8 with strings loaded | 1040 | /* To be safe - for UCS to UTF-8 with strings loaded |
967 | with the rare long characters alloc more to account for | 1041 | with the rare long characters alloc more to account for |
968 | such multibyte target UTF-8 characters. cifs_unicode.c, | 1042 | such multibyte target UTF-8 characters. cifs_unicode.c, |
@@ -977,17 +1051,19 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) | |||
977 | } | 1051 | } |
978 | /* if buggy server returns . and .. late do | 1052 | /* if buggy server returns . and .. late do |
979 | we want to check for that here? */ | 1053 | we want to check for that here? */ |
980 | rc = cifs_filldir(current_entry, file, | 1054 | rc = cifs_filldir(current_entry, file, |
981 | filldir, direntry,tmp_buf); | 1055 | filldir, direntry, tmp_buf, max_len); |
982 | file->f_pos++; | 1056 | file->f_pos++; |
983 | if(file->f_pos == cifsFile->srch_inf.index_of_last_entry) { | 1057 | if(file->f_pos == |
1058 | cifsFile->srch_inf.index_of_last_entry) { | ||
984 | cFYI(1,("last entry in buf at pos %lld %s", | 1059 | cFYI(1,("last entry in buf at pos %lld %s", |
985 | file->f_pos,tmp_buf)); /* BB removeme BB */ | 1060 | file->f_pos,tmp_buf)); |
986 | cifs_save_resume_key(current_entry,cifsFile); | 1061 | cifs_save_resume_key(current_entry,cifsFile); |
987 | break; | 1062 | break; |
988 | } else | 1063 | } else |
989 | current_entry = nxt_dir_entry(current_entry, | 1064 | current_entry = |
990 | end_of_smb); | 1065 | nxt_dir_entry(current_entry, end_of_smb, |
1066 | cifsFile->srch_inf.info_level); | ||
991 | } | 1067 | } |
992 | kfree(tmp_buf); | 1068 | kfree(tmp_buf); |
993 | break; | 1069 | break; |